From 455b5631bc935f3d3689a535976c249b4cbab70d Mon Sep 17 00:00:00 2001 From: James Vega Date: Thu, 28 Jan 2010 08:14:44 -0500 Subject: [PATCH] Update plugins to ignore all non-ACTION CTCP messages. Also update commands.urlSnarfer to do the same, which allows us to revert "Don't bother snarfing URLs from non-Action CTCP messages." This reverts commit 3282e3407ede364acbc92b4e9a6319800d50d46a. Signed-off-by: James Vega (cherry picked from commit 288d7c6e0216baa6445cbd90bb819d1fd0f113c4) --- plugins/ChannelStats/plugin.py | 7 +++++-- plugins/Karma/plugin.py | 2 ++ plugins/Later/plugin.py | 4 ++++ plugins/Note/plugin.py | 5 ++++- plugins/QuoteGrabs/plugin.py | 4 +++- plugins/Relay/plugin.py | 6 +++--- plugins/Seen/plugin.py | 3 +++ plugins/URL/plugin.py | 3 +++ plugins/Web/plugin.py | 3 --- src/commands.py | 7 ++++--- 10 files changed, 31 insertions(+), 13 deletions(-) diff --git a/plugins/ChannelStats/plugin.py b/plugins/ChannelStats/plugin.py index baf768007..adbf0fd91 100644 --- a/plugins/ChannelStats/plugin.py +++ b/plugins/ChannelStats/plugin.py @@ -1,6 +1,6 @@ ### # Copyright (c) 2002-2004, Jeremiah Fincher -# Copyright (c) 2009, James Vega +# Copyright (c) 2009-2010, James Vega # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -81,8 +81,11 @@ class ChannelStat(irclib.IrcCommandDispatcher): self.smileys += len(sRe.findall(payload)) def doPrivmsg(self, msg): + isAction = ircmsgs.isAction(msg) + if ircmsgs.isCtcp(msg) and not isAction: + return self.doPayload(*msg.args) - if ircmsgs.isAction(msg): + if isAction: self.actions += 1 def doTopic(self, msg): diff --git a/plugins/Karma/plugin.py b/plugins/Karma/plugin.py index 36532b286..d7a33ec41 100644 --- a/plugins/Karma/plugin.py +++ b/plugins/Karma/plugin.py @@ -1,5 +1,6 @@ ### # Copyright (c) 2005, Jeremiah Fincher +# Copyright (c) 2010, James Vega # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -265,6 +266,7 @@ class Karma(callbacks.Plugin): if not (msg.addressed or msg.repliedTo): channel = msg.args[0] if irc.isChannel(channel) and \ + not ircmsgs.isCtcp(msg) and \ self.registryValue('allowUnaddressedKarma', channel): irc = callbacks.SimpleProxy(irc, msg) thing = msg.args[1].rstrip() diff --git a/plugins/Later/plugin.py b/plugins/Later/plugin.py index ca964bc7b..3babf6365 100644 --- a/plugins/Later/plugin.py +++ b/plugins/Later/plugin.py @@ -1,5 +1,6 @@ ### # Copyright (c) 2004, Jeremiah Fincher +# Copyright (c) 2010, James Vega # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -34,6 +35,7 @@ import supybot.log as log import supybot.conf as conf import supybot.utils as utils from supybot.commands import * +import supybot.ircmsgs as ircmsgs import supybot.ircutils as ircutils import supybot.callbacks as callbacks @@ -152,6 +154,8 @@ class Later(callbacks.Plugin): remove = wrap(remove, [('checkCapability', 'admin'), 'something']) def doPrivmsg(self, irc, msg): + if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg): + return notes = self._notes.pop(msg.nick, []) # Let's try wildcards. removals = [] diff --git a/plugins/Note/plugin.py b/plugins/Note/plugin.py index 525430122..95a53bbea 100644 --- a/plugins/Note/plugin.py +++ b/plugins/Note/plugin.py @@ -1,5 +1,6 @@ ### # Copyright (c) 2004, Brett Kelly +# Copyright (c) 2010, James Vega # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -121,7 +122,7 @@ class DbiNoteDB(dbi.DB): for (to, ids) in cache.items(): while id in ids: ids.remove(id) - + NoteDB = plugins.DB('Note', {'flat': DbiNoteDB}) class Note(callbacks.Plugin): @@ -135,6 +136,8 @@ class Note(callbacks.Plugin): self.db.close() def doPrivmsg(self, irc, msg): + if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg): + return self._notify(irc, msg) def doJoin(self, irc, msg): diff --git a/plugins/QuoteGrabs/plugin.py b/plugins/QuoteGrabs/plugin.py index 8fe6714bb..03d3a98d6 100644 --- a/plugins/QuoteGrabs/plugin.py +++ b/plugins/QuoteGrabs/plugin.py @@ -1,6 +1,6 @@ ### # Copyright (c) 2004, Daniel DiPaolo -# Copyright (c) 2008-2009, James Vega +# Copyright (c) 2008-2010, James Vega # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -212,6 +212,8 @@ class QuoteGrabs(callbacks.Plugin): self.db = QuoteGrabsDB() def doPrivmsg(self, irc, msg): + if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg): + return irc = callbacks.SimpleProxy(irc, msg) if irc.isChannel(msg.args[0]): (chan, payload) = msg.args diff --git a/plugins/Relay/plugin.py b/plugins/Relay/plugin.py index c19f836f4..ffd31f80f 100644 --- a/plugins/Relay/plugin.py +++ b/plugins/Relay/plugin.py @@ -1,5 +1,6 @@ ### # Copyright (c) 2002-2004, Jeremiah Fincher +# Copyright (c) 2010, James Vega # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -339,6 +340,8 @@ class Relay(callbacks.Plugin): notPunishing(irc, 'not opped') def doPrivmsg(self, irc, msg): + if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg): + return (channel, text) = msg.args if irc.isChannel(channel): irc = self._getRealIrc(irc) @@ -350,9 +353,6 @@ class Relay(callbacks.Plugin): self.log.debug('Refusing to relay %s, ignored by %s.', msg.prefix, ignore) return - if ircmsgs.isCtcp(msg) and \ - 'AWAY' not in text and 'ACTION' not in text: - return # Let's try to detect other relay bots. if self._checkRelayMsg(msg): if self.registryValue('punishOtherRelayBots', channel): diff --git a/plugins/Seen/plugin.py b/plugins/Seen/plugin.py index 291027b54..d5bc6275e 100644 --- a/plugins/Seen/plugin.py +++ b/plugins/Seen/plugin.py @@ -1,5 +1,6 @@ ### # Copyright (c) 2002-2004, Jeremiah Fincher +# Copyright (c) 2010, James Vega # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -136,6 +137,8 @@ class Seen(callbacks.Plugin): irc.queueMsg(ircmsgs.names(channel)) def doPrivmsg(self, irc, msg): + if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg): + return if irc.isChannel(msg.args[0]): channel = msg.args[0] said = ircmsgs.prettyPrint(msg) diff --git a/plugins/URL/plugin.py b/plugins/URL/plugin.py index 4914ef22a..50787ca68 100644 --- a/plugins/URL/plugin.py +++ b/plugins/URL/plugin.py @@ -1,5 +1,6 @@ ### # Copyright (c) 2002-2004, Jeremiah Fincher +# Copyright (c) 2010, James Vega # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -65,6 +66,8 @@ class URL(callbacks.Plugin): self.db = URLDB() def doPrivmsg(self, irc, msg): + if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg): + return channel = msg.args[0] if irc.isChannel(channel): if ircmsgs.isAction(msg): diff --git a/plugins/Web/plugin.py b/plugins/Web/plugin.py index bf9b66bda..6a332c792 100644 --- a/plugins/Web/plugin.py +++ b/plugins/Web/plugin.py @@ -36,7 +36,6 @@ import supybot.conf as conf import supybot.utils as utils from supybot.commands import * import supybot.plugins as plugins -import supybot.ircmsgs as ircmsgs import supybot.ircutils as ircutils import supybot.callbacks as callbacks @@ -80,8 +79,6 @@ class Web(callbacks.PluginRegexp): channel = msg.args[0] if not irc.isChannel(channel): return - if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg): - return if callbacks.addressed(irc.nick, msg): return if self.registryValue('titleSnarfer', channel): diff --git a/src/commands.py b/src/commands.py index eee35c6c2..764df1135 100644 --- a/src/commands.py +++ b/src/commands.py @@ -1,6 +1,6 @@ ### # Copyright (c) 2002-2005, Jeremiah Fincher -# Copyright (c) 2009, James Vega +# Copyright (c) 2009-2010, James Vega # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -109,10 +109,11 @@ def urlSnarfer(f): def newf(self, irc, msg, match, *L, **kwargs): url = match.group(0) channel = msg.args[0] - if not irc.isChannel(channel): + if not irc.isChannel(channel) or (ircmsgs.isCtcp(msg) and not + ircmsgs.isAction(msg)): return if ircdb.channels.getChannel(channel).lobotomized: - self.log.info('Not snarfing in %s: lobotomized.', channel) + self.log.debug('Not snarfing in %s: lobotomized.', channel) return if _snarfed.has(channel, url): self.log.info('Throttling snarf of %s in %s.', url, channel)