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:
Vgr E. Barry 2016-10-31 20:59:52 -04:00
parent 12eab068be
commit 5c9b13ce87
2 changed files with 3 additions and 2 deletions

View File

@ -14,7 +14,7 @@ from src.utilities import irc_equals
hook = decorators.hook
def on_privmsg(cli, rawnick, chan, msg, notice = False):
def on_privmsg(cli, rawnick, chan, msg, *, notice=False):
try:
prefixes = getattr(var, "STATUSMSG_PREFIXES")
except AttributeError:

View File

@ -18,6 +18,7 @@
# THE SOFTWARE.
import traceback
import functools
import sys
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))
cli = IRCClient(
{"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},
host=botconfig.HOST,
port=botconfig.PORT,