anlutro / botologist

Plugin-driven Python3 IRC
MIT License
5 stars 5 forks source link

Added code to filter on games #77

Closed dsverdlo closed 7 years ago

dsverdlo commented 7 years ago

Two new commands (filter and delfilter) allow a regular expression to be set. This regex filter the streams shown in the #qlreddit IRC channel.

anlutro commented 7 years ago

This is a great idea that I didn't think of. For our use case it works perfectly. I have a couple of suggestions.

We could easily make the bot "remember" the game filter by writing it to the same JSON file as the streams themselves. Have a look in the _read and _write methods on the stream plugin class.

Also, maybe the commands should reflect that the filtering is for streams. !filterstreams and !delstreamfilter may be more appropriate names, though verbose.

Finally, check out the error from Travis: E:370,11: Instance of 'StreamsPlugin' has no 'game' member (no-member)

anlutro commented 7 years ago

Oh, and one more thing - I think we can use fnmatch instead of regex to make things just a little bit more accessible to users.

dsverdlo commented 7 years ago

Thanks for the suggestions, they make some good points.

I will look into them and the error. This fnmatch is new to me, but if it provides the same functionality as regex, I could look into implementing that.

anlutro commented 7 years ago

Looks good to me! The lint errors don't really make sense. I'll pull this live later tonight.

dsverdlo commented 7 years ago

Dear @anlutro

I have reviewed your suggestions and applied most of them.

However, I have looked at the suggested fnmatch library, and this does not seem to support an 'or' evaluation in its patterns. (Like with RegEx you can say 'match everything with quakeor reflexin it')

So I would suggest sticking with regex. Normally this filter will not be changed as often, nor should the patterns become too complex.

(Ps: don't know what those lint errors mean. I reviewed the code at the mentioned lines and they should all work as intented.)