Improve NOTICE handling
The `notice` parameter is now keyword-only, and the handler now uses `functools.partial` instead of a lambda function.
This commit is contained in:
parent
12eab068be
commit
5c9b13ce87
@ -14,7 +14,7 @@ from src.utilities import irc_equals
|
|||||||
|
|
||||||
hook = decorators.hook
|
hook = decorators.hook
|
||||||
|
|
||||||
def on_privmsg(cli, rawnick, chan, msg, notice = False):
|
def on_privmsg(cli, rawnick, chan, msg, *, notice=False):
|
||||||
try:
|
try:
|
||||||
prefixes = getattr(var, "STATUSMSG_PREFIXES")
|
prefixes = getattr(var, "STATUSMSG_PREFIXES")
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
import functools
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ def main():
|
|||||||
src.plog("Connecting to {0}:{1}{2}".format(botconfig.HOST, "+" if botconfig.USE_SSL else "", botconfig.PORT))
|
src.plog("Connecting to {0}:{1}{2}".format(botconfig.HOST, "+" if botconfig.USE_SSL else "", botconfig.PORT))
|
||||||
cli = IRCClient(
|
cli = IRCClient(
|
||||||
{"privmsg": handler.on_privmsg,
|
{"privmsg": handler.on_privmsg,
|
||||||
"notice": lambda a, b, c, d: handler.on_privmsg(a, b, c, d, True),
|
"notice": functools.partial(handler.on_privmsg, notice=True),
|
||||||
"": handler.unhandled},
|
"": handler.unhandled},
|
||||||
host=botconfig.HOST,
|
host=botconfig.HOST,
|
||||||
port=botconfig.PORT,
|
port=botconfig.PORT,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user