-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 |
||
# Since we have no way of knowing the hostmask the IRC server uses | ||
# for us, we'll just use something reasonable | ||
host = 'localhost' | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. This line made me notice the overuse of a variable named |
||
self.dispatch(pretrigger) | ||
|
||
def run(self, host, port=6667): | ||
try: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @embolalia:
This decorator should just set the |
||
"""Decorate a function to specify if it should receive echo messages. | ||
|
||
This decorator can be used to listen in on the messages that Sopel is | ||
sending and react accordingly. | ||
|
||
Args: | ||
value: Either True or False. If True the function will receive echo | ||
messages, and if False only messages received from other users. | ||
|
||
""" | ||
def add_attribute(function): | ||
function.echo = value | ||
return function | ||
return add_attribute | ||
|
||
|
||
def commands(*command_list): | ||
"""Decorate a function to set one or more commands to trigger 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.
I'd put this check first in the enclosing
for
loop, but the order isn't really an issue tbh.