[Twisted-Python] twisted words irc patch for usernames
Avleen Vig
lists-twistedmatrix at silverwraith.com
Sun Oct 30 03:55:08 EST 2005
Currently when twisted connects to an irc server, the username on the
USER connect line, is assumed to be the same as the nickname.
Below is a patch that lets the username be set manually the same way as
'password' is defined. If a username isn't specified, it defaults to
assuming self.username = nickname
I found this useful to connect to a server which required a specific
username as part of its authentication but I didn't want to / need to
run ident. I couldn't think of a good reason for not being able to set
the username if we can already set everything else :-)
Index: Twisted/twisted/words/protocols/irc.py
===================================================================
--- Twisted/twisted/words/protocols/irc.py (revision 14959)
+++ Twisted/twisted/words/protocols/irc.py (working copy)
@@ -535,6 +535,7 @@
nickname = 'irc'
password = None
realname = None
+ username = None
### Responses to various CTCP queries.
userinfo = None
@@ -895,7 +896,9 @@
if self.password is not None:
self.sendLine("PASS %s" % self.password)
self.setNick(nickname)
- self.sendLine("USER %s foo bar :%s" % (nickname, self.realname))
+ if self.username is None:
+ self.username = nickname
+ self.sendLine("USER %s foo bar :%s" % (self.username, self.realname))
def setNick(self, nickname):
self.nickname = nickname
--
Avleen Vig
Systems Administrator
Personal: www.silverwraith.com
"Wickedness is a myth invented by good people to account for the curious
attractiveness of others." - Oscar Wilde
More information about the Twisted-Python
mailing list