From 3c0809dce0b1bf081d5a43951bc3ffab911c614d Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 24 Feb 2018 14:18:32 -0500 Subject: [PATCH] ctcp: don't use irc.reply in hook functions This is undefined behaviour because nothing in this stack actually updates the 'last caller' variables irc.reply() use. --- plugins/ctcp.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/ctcp.py b/plugins/ctcp.py index 3527162..344c9d6 100644 --- a/plugins/ctcp.py +++ b/plugins/ctcp.py @@ -36,9 +36,11 @@ def handle_ctcp(irc, source, command, args): # Call the helper function and display its result. result = SUPPORTED_COMMANDS[ctcp_command](irc, source, ctcp_command, data) - if result: - irc.reply('\x01%s %s\x01' % (ctcp_command, result), - notice=True, private=True, source=target) + if result and source in irc.users: + # Note, do NOT use irc.reply() in hook handlers because nothing except the + # command handler system actually updates the last caller. + irc.msg(source, '\x01%s %s\x01' % (ctcp_command, result), + notice=True, private=True, source=target) return False # Block this message from reaching the general command handler else: