Closed dsverdlo closed 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)
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.
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.
Looks good to me! The lint errors don't really make sense. I'll pull this live later tonight.
Dear @anlutro
I have reviewed your suggestions and applied most of them.
StreamManager
class so it can be stored in the JSON fileHowever, 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 quake
or reflex
in 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.)
Two new commands (filter and delfilter) allow a regular expression to be set. This regex filter the streams shown in the #qlreddit IRC channel.