-
-
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 #1470
Conversation
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'm not allowed to mark this as "Request changes" because GitHub has decreed that PR authors aren't allowed to admit when their work is incomplete… but these are the comments I left on the original PR (#1072), brought over to this one so I don't forget to address them when I have the time.
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.
Also want to remind myself, when I come back to this, that at least the |
Implemented the pending feedback from before:
My tweaks should get a review from one or more @sopel-irc/rockstars before merging 🚀 Also updated the name of |
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.
The main decorator needs to be fixed.
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.
Good catch on the default value of echo
.
/me approves
Cool, I'mma squash that fixup now that you've seen it. |
- Remove argument from module.echo() decorator and just always set the attribute to `True` on decorated functions - Only simulate `echo-message` for PRIVMSG and NOTICE lines
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.
Looking good!
If a function is not decorated with @sopel.module.echo, it should not throw an exception if code somewhere tries to check `func.echo`'s value. Simplified check in `bot.dispatch()` with this: since `func.echo` will always at least exist, there's no need to do any `hasattr()` first.
This landed on master, so we can safely use it in the echo-message branch assuming all tests are run on merges (which they are in CI).
Corrected misspelled method names related to receiving CAP messages, and added `echo-message` to the list of core capabilities Sopel should enable if available from the server (for the module.echo decorator).
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.
🏅 on the spelling correction... the @echo
feature is a nice touch too, I guess 😉
As far as I'm concerned, LGTM. I didn't test it live, but the code-style and the overall logic check out. |
Well, I confirmed via raw logs that the It's hard to find a network that actually supports this. The client capability statistics for "curiosity's sake" at The logic added in this PR should "just work" whether or not the |
bot.write() joins the elements of a sequence type (tuple, here) with a space already, so including a space in `'MODE '` caused Sopel to send `MODE SopelsNick +modes`. Technically, that's invalid. Discovered while trying to test #1470 on a network with actual support for `echo-message`, when darwin.network disconnected the bot during registration with the message "ERROR :Received malformed line". Annoying because I was trying to test something else, but useful in the end.
Use new `@module.echo` decorator to collect Sopel's own lines as well, so cheeky users can say, "Sopel: s/you made/a mistake/" to the bot. Basically, proof that the echo decorator does its job.
Rebased & tweaked version of #1072, which stalled. Resolves #526. Original PR description by @maxpowa follows; see #1072 for the earlier evolution of this patch.
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.