[Twisted-Python] Another IRC patch.
screwtape at froup.com
screwtape at froup.com
Sat Nov 2 05:19:18 MST 2002
While developing my twisted.im bot (new this week! database access and
an infobot-style plugin!) I've come up against two seperate
annoyances. This patch fixes both of them.
Number 1: the IRC protocol defines (among other things) two message
types - privmsg and notice. They are identical in every respect except
that a notice must not be automatically replied to. Currently,
twisted.protocol.irc.IRCClient maps notice onto privmsg, which is
dangerous but acceptible, because you're supposed to subclass
IRCClient anyway.
However, twisted.im.ircsupport subclasses IRCClient and does not
override the 'noticed' method, so all twisted.im clients cannot tell
the difference between a privmsg and a notice. This is really not a
good thing, especially for an IM bot like mine. The attached patch
fixes this in a brute force manner by making twisted.im.ircsupport
drop all notices on the floor.
Number 2: The IRC protocol defines a certain bunch of commands that
the server can send the client. twisted.protocol.irc.IRCClient calls
self.irc_COMMAND to handle an incoming command 'COMMAND', and if no
such method exists, it calles self.irc_unknown.
twisted.im.ircsupport by default prints an error message for each
unknown command it recieves. Slashnet in particular seems to like to
send a lot of them, and it clutters up my screen. This patch simply
comments out the print statement and adds a 'pass'.
--
___________ ____________________________
| Screwtape | Reply-To: munged on Usenet |________ ______ ____ __ _ _ _
|
| "I've got this brilliant idea but I don't know where it is." -- Beth Allen
|
-------------- next part --------------
Index: twisted/im/ircsupport.py
===================================================================
RCS file: /cvs/Twisted/twisted/im/ircsupport.py,v
retrieving revision 1.18
diff -u -r1.18 ircsupport.py
--- twisted/im/ircsupport.py 24 Oct 2002 12:03:41 -0000 1.18
+++ twisted/im/ircsupport.py 2 Nov 2002 12:18:06 -0000
@@ -131,6 +131,12 @@
return
self.chat.getConversation(self.getPerson(username)).showMessage(message)
+ def noticed(self, user, channel, message):
+ """I don't think there's any real reason that a chat client should
+ have to deal with notices.
+ """
+ pass
+
def action(self,username,channel,emote):
username=string.split(username,'!',1)[0]
if username==self.name: return
@@ -221,7 +227,8 @@
del self._ingroups[fromNick]
def irc_unknown(self, prefix, command, params):
- print "unknown message from IRCserver. prefix: %s, command: %s, params: %s" % (prefix, command, params)
+ #print "unknown message from IRCserver. prefix: %s, command: %s, params: %s" % (prefix, command, params)
+ pass
# GTKIM calls
def joinGroup(self,name):
More information about the Twisted-Python
mailing list