IRCClient.modeChanged fails to handle different modes at the same time
|Reported by:||Wolf||Owned by:|
|Component:||words||Keywords:||irc, IRCClient, irc_MODE, modeChanged, review|
This is the testcode:
class MyIRCClient(irc.IRCClient): def modeChanged(self, user, channel, set, modes, args): print 'Mode changed:', user, channel, set, modes, args
When I set a single mode (e.g. +c) or I add/remove several modes (e.g. +cU) it works (it prints 'Mode changed: user channel True cU ()').
When I set different modes (e.g. +c-U) it prints 'Mode changed: user channel True c-U ()'.
In this situation the expected result should be something like (True, False) ('c', 'U') or a list like [(True, 'c'), (False, 'U')], or better a plain string '+c-U' (the one that the server already sends, unchanged).
These solutions will probably break the compatibility with the previous version (a tuple instead of a bool in the 1st case, a single parameter instead of 'set' and 'modes' with a list or a string for the other two). Another possible solution is to call two (or more) times the modeChanged method (i.e. the 1st with set=True, modes='c' and the 2nd with set=False, modes='U'). This won't allow the user to handle the modes together (XChat uses a similar solution too, mIRC instead handles all the changes in a single message) but it shouldn't break the compatibility with the previous version of twisted.
If the compatibility is not a problem, sending the string is probably (IMHO) the best solution, it will save you some work and it will allow us to parse it as we want.
The documentation should also be changed (see also ticket #3148).
The modeChanged method of the IRCClient class is at the line 701 of the irc.py module in twisted/words/protocols.
Change History (11)
comment:3 follow-up: ↓ 4 Changed 8 years ago by therve
- Keywords review removed
- Owner changed from exarkun to Wolf