-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
logging: don't log if opt_in_channels
is empty or channel not in it
#7
base: master
Are you sure you want to change the base?
Conversation
Add an opt_in_channels config which blocks logging if the array is not empty and the channel is not in it. Assumes if array is empty that logging should happen everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of repeating message.sender.is_channel() and bot.config.chanlogs.opt_in_channels in not [] and trigger not in bot.config.chanlogs.opt_in_channels
everywhere, make a helper function like _channel_opted_in()
and use that.
I'm also fairly sure that that set of conditions won't actually do what you want. Logically, it's gibberish. Probably won't even parse; doesn't look like valid Python.
Update? |
opt_in_channels
is empty or channel not in it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are so many syntax errors in this, I'm positive it hasn't been tested. 🙁
@@ -111,6 +112,17 @@ def _format_template(tpl, bot, trigger, **kwargs): | |||
return formatted | |||
|
|||
|
|||
def _channel_is_opted_in(is_channel, channel, opted_in_channels): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this take is_channel
as an argument? Callers derive it from Trigger.sender.is_nick()
anyway, so… that can be part of the function.
Also: sopel.tools.Identifier
, of which Trigger.sender
is an instance, doesn't have an is_channel()
method. Did you…test this patch?
@@ -111,6 +112,17 @@ def _format_template(tpl, bot, trigger, **kwargs): | |||
return formatted | |||
|
|||
|
|||
def _channel_is_opted_in(is_channel, channel, opted_in_channels): | |||
if is_channel and not opted_in_channels or str(channel) in opted_in_channels: # cast channel to string because I don't trust python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
channel
should be cast to sopel.tools.Identifier
, not str
.
Also PEP8 demands two spaces before #
to start a line-end comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't everything in the array be a string though?
Co-authored-by: dgw <[email protected]>
Co-authored-by: dgw <[email protected]>
Co-authored-by: dgw <[email protected]>
Co-authored-by: dgw <[email protected]>
Add an opt_in_channels config which blocks logging if the array is not empty and the channel is not in it. Assumes if array is empty that logging should happen everywhere.
resolves #6