From 5c9b13ce87d2c151560ea26077fa153dde8e79c2 Mon Sep 17 00:00:00 2001 From: "Vgr E. Barry" Date: Mon, 31 Oct 2016 20:59:52 -0400 Subject: [PATCH] Improve NOTICE handling The `notice` parameter is now keyword-only, and the handler now uses `functools.partial` instead of a lambda function. --- src/handler.py | 2 +- wolfbot.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/handler.py b/src/handler.py index 000bdee..b151c12 100644 --- a/src/handler.py +++ b/src/handler.py @@ -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: diff --git a/wolfbot.py b/wolfbot.py index da5d985..2117f19 100755 --- a/wolfbot.py +++ b/wolfbot.py @@ -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,