[Twisted-Python] Another IRC patch.
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 |
On Sat, 2 Nov 2002, screwtape@froup.com wrote:
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.
I'm trying to understand, does this mean no .im chat client can support notices without jumping through hoops? In that case this is *VERY* bad. People on #python whose clients filter out the chanserv notice get treated rudely (for a good reason).
On Sat, Nov 02, 2002 at 01:02:45PM -0000, Moshe Zadka wrote:
On Sat, 2 Nov 2002, screwtape@froup.com wrote:
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.
I'm trying to understand, does this mean no .im chat client can support notices without jumping through hoops? In that case this is *VERY* bad. People on #python whose clients filter out the chanserv notice get treated rudely (for a good reason).
As I understand it, it works like this: * ircsupport drops notices on the floor - people on #python get treated rudely, for whatever reason (I've never been to #python). * ircsupport maps notices onto privmsgs - IM clients can't tell the difference, and might do stupid things to notices that they shouldn't do (sample circumstances might be bots or "I'm away right now, but your message has been logged" messages.) * ircsupport keeps them seperate, and we change all the rest of twisted.im to understand the difference between notices and privmsgs even though pretty much no IM system besides IRC implements it. - I get the feeling that twisted.im is supposed to be the intersection of all IM protocols, rather than the union. There are of course other solutions - notices could be logged to the console and not passed through the twisted.im framework, or maybe we could add another piece of metadata, the same way that actions are handled. I'm curious - exactly what happens to people on #python whose clients filter out the chanserv notice? -- ___________ ____________________________ | Screwtape | Reply-To: munged on Usenet |________ ______ ____ __ _ _ _ | | "We've got a lot in common" "I've always thought so, too." -- M*A*S*H |
On Sun, 3 Nov 2002, screwtape@froup.com wrote:
* ircsupport drops notices on the floor - people on #python get treated rudely, for whatever reason (I've never been to #python).
See below.
* ircsupport maps notices onto privmsgs - IM clients can't tell the difference, and might do stupid things to notices that they shouldn't do (sample circumstances might be bots or "I'm away right now, but your message has been logged" messages.)
Indeed, that would be bad.
* ircsupport keeps them seperate, and we change all the rest of twisted.im to understand the difference between notices and privmsgs even though pretty much no IM system besides IRC implements it. - I get the feeling that twisted.im is supposed to be the intersection of all IM protocols, rather than the union.
Why? Certainly, other protocols might develop notices too. I definitely think the native .words protocol should support them. If a client has code to (potentially) display notices in some manner, and the protocol it was using didn't support notices, the client wouldn't get that code activated. Certainly not the end of the world.
There are of course other solutions - notices could be logged to the console and not passed through the twisted.im framework
That's equivalent to dropping them on the floor, or worse.
I'm curious - exactly what happens to people on #python whose clients filter out the chanserv notice?
The client filters out the chanserv notice containing URL to the FAQ, they don't read the faq and...well, I hardly need to spell out what happens next, right? Bottom line, they get told to "fix their client or get a better one".
On Sat, 2 Nov 2002 23:19:18 +1100, screwtape@froup.com wrote:
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.
Glad you're making progress! I'm sorry that twisted.im is annoying you :-(. Hopefully I can give some guidance as to how it's _supposed_ to work...
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.
Except when they should be automatically replied to. Such as the notice that NickServ gives you upon login, or one of the various notices that older spambots will generate in response to a VERSION directive. This is one of the worse excresences of the IRC protocol and I'd like to not see promoted to the higher levels of abstractions in twisted.im. What you're semantically communicating is metadata about the message ("please don't autorespond to this (unless you really want to)") and not a wholly different type of message. So I've committed a different fix :-). The "metadata" dictionary passesd to showMessage and showGroupMessage is designed to encapsulate this sort of protocol-specific need, so IRC "notice" messages will have an entry in the metadata dictionary of {"dontAutoRespond": 1}. I just committed a fix that does this... if you're using CVS, your bot can now check for that flag in the metadata dict and drop the message on the floor appropriately. For t.im's default use case (end-user chat application) whether or not robots should automatically respond to a certain type of message is completely irrelevant to its display.
Number 2: [ ... ] 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'.
Hmm... that behavior should at least be customizeable with a flag... I personally have used that console output a number of times, and it has been invaluable in debugging certain things in twisted.im on various occasions. If you don't want the output going to the console, there should be a separate log. Perhaps you could specifically ignore the slashnet message types you don't want? -- | <`'> | Glyph Lefkowitz: Traveling Sorcerer | | < _/ > | Lead Developer, the Twisted project | | < ___/ > | http://www.twistedmatrix.com |
On Sat, Nov 02, 2002 at 10:57:17AM -0600, Glyph Lefkowitz wrote:
On Sat, 2 Nov 2002 23:19:18 +1100, screwtape@froup.com wrote:
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.
Glad you're making progress! I'm sorry that twisted.im is annoying you :-(. Hopefully I can give some guidance as to how it's _supposed_ to work...
Oh, neat. To be truthful, most of it is pretty nifty. :) I'd be interested to see if my bot also works with AIM and twisted.words, though - I don't have an account with either so I can't test... is anyone working on a Jabber protocol for Twisted? :)
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.
Except when they should be automatically replied to. Such as the notice that NickServ gives you upon login, or one of the various notices that older spambots will generate in response to a VERSION directive.
Oh. That's a right pain, that is.
This is one of the worse excresences of the IRC protocol and I'd like to not see promoted to the higher levels of abstractions in twisted.im. What you're semantically communicating is metadata about the message ("please don't autorespond to this (unless you really want to)") and not a wholly different type of message. So I've committed a different fix :-). The "metadata" dictionary passesd to showMessage and showGroupMessage is designed to encapsulate this sort of protocol-specific need, so IRC "notice" messages will have an entry in the metadata dictionary of {"dontAutoRespond": 1}.
I just committed a fix that does this... if you're using CVS, your bot can now check for that flag in the metadata dict and drop the message on the floor appropriately.
Heh. I was going to post 'how about I just dump it in the metadata dict' and look into writing a patch later today. Thanks!
For t.im's default use case (end-user chat application) whether or not robots should automatically respond to a certain type of message is completely irrelevant to its display.
Indeed
Number 2: [ ... ] 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'.
Hmm... that behavior should at least be customizeable with a flag... I personally have used that console output a number of times, and it has been invaluable in debugging certain things in twisted.im on various occasions.
When I was doing IRC-specific things, I too have found it incredibly useful. But, being unconcerned with low-level details of the protocol at the moment, I find it annoying.
If you don't want the output going to the console, there should be a separate log. Perhaps you could specifically ignore the slashnet message types you don't want?
My theory was that if a developer wanted that level of detail from ircsupport.py, they could just go and uncomment the print statement. :/ -- ___________ ____________________________ | Screwtape | Reply-To: munged on Usenet |________ ______ ____ __ _ _ _ | | <Nibbles> DO NOT GET ME A HERRING! |
On Sat, Nov 02, 2002 at 11:13:02PM -0600, Maniac - wrote:
While developing my twisted.im bot (new this week! database access and an infobot-style plugin!)
Is this in cvs somewhere?
Sadly, no. None of my weekend projects have ever been available via CVS, I've never written anything of sufficient interest before. Screwtape, ...feel free to visit #afda on irc.slashnet.org and say 'Mooby: help' -- ___________ ____________________________ | Screwtape | Reply-To: munged on Usenet |________ ______ ____ __ _ _ _ | | This empty tagline? It's where my conversation piece used to be. |
participants (4)
-
Glyph Lefkowitz -
Maniac - -
Moshe Zadka -
screwtape@froup.com