-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
irc/bot: implement echo-message support #1072
Conversation
Awesome! My only thought is a concern that there will be increased risk of modules generating loops if this particular decorator defaults to |
Close, but it's default |
Ah, OK. Still possible for module authors to write confusing code that doesn't explicitly specify |
I just realized that this isn't really correct. As it is right now, it will echo every type of message, but the echo message spec only includes |
I like the idea, like seriously. This is awesome and has been desired for ages. But I don't think the |
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.
If @maxpowa is willing to address these in the (probably long) time between now and when Sopel 7 comes, that's great. If not, I will simply add them on in a new commit, without squashing so the feature's history remains visible.
@@ -484,6 +484,9 @@ def dispatch(self, pretrigger): | |||
if (hasattr(func, 'intents') and | |||
trigger.tags.get('intent') not in func.intents): | |||
continue | |||
if (not (hasattr(func, 'echo') and func.echo is True) and | |||
trigger.nick.lower() == self.nick.lower()): | |||
continue |
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.
I'd put this check first in the enclosing for
loop, but the order isn't really an issue tbh.
if self.config.core.bind_host: | ||
host = self.config.core.bind_host | ||
pretrigger = PreTrigger(self.nick, ':{0}!{1}@{2} {3}' | ||
.format(self.nick, self.user, host, temp)) |
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.
This line made me notice the overuse of a variable named temp
in this function. Renaming that to something sensible should happen after this is merged.
@@ -115,6 +115,23 @@ def add_attribute(function): | |||
return add_attribute | |||
|
|||
|
|||
def echo(value): |
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.
I agree with @embolalia:
I don't think the
@echo
decorator should take a value. The default should be definitely not to get echoes, meaning the decorator only needs to mean "yup this thing can get echo messages".
This decorator should just set the echo
function attribute to True
if called. That's all it needs to do.
@@ -148,6 +148,16 @@ def write(self, args, text=None): | |||
self.send(temp.encode('utf-8')) | |||
finally: | |||
self.writing_lock.release() | |||
# Simulate echo-message | |||
if 'echo-message' not in self.enabled_capabilities: |
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.
As @maxpowa mentioned in the main PR comments, "As it is right now, it will echo every type of message, but the echo message spec only includes NOTICE
and PRIVMSG
." Therefore, this block should only fire if the message is one of those types.
@maxpowa Would you be willing to allow edits from maintainers on this PR? I just rebased it, but can't push the updated history back here (probably because the PR is so old). |
Closing in favor of rebased/updated version (#1470). |
Allows modules to listen in on what's being sent by Sopel. Compatible with all the other decorators, as it goes through all the same logic. If
echo-message
is supported on the server and is toggled on by a module, only functions with the@sopel.module.echo(True)
decorator will receive those echo messages. Ifecho-message
isn't enabled, the same behavior still exists but the hostmask will not be as accurate.