author | Alberto Bertogli
<albertogli@telpin.com.ar> 2005-05-15 15:00:24 UTC |
committer | Alberto Bertogli
<albertogli@telpin.com.ar> 2005-05-15 15:00:24 UTC |
parent | 2e1849f9d099824d6f9e83c4ec9714db1e687cdd |
msnlib.py | +11 | -7 |
diff --git a/msnlib.py b/msnlib.py index fb3cdff..f10af26 100644 --- a/msnlib.py +++ b/msnlib.py @@ -47,6 +47,12 @@ def debug(s): sys.stderr.write('\r' + str(s) + '\n') sys.stderr.flush() +def nickquote(nick): + """Quotes a nick the way the server likes it: replacing spaces with + '%20' but leaving extender characters alone, as they get sent UTF-8 + encoded.""" + nick = nick.replace(' ', '%20') + return nick class user: """User class, used to store your 'friends'""" @@ -360,7 +366,7 @@ class msnd: def change_nick(self, nick): "Changes our nick" - nick = urllib.quote(nick) + nick = nickquote(nick) self._send('REA', self.email + ' ' + nick) return 1 @@ -374,7 +380,7 @@ class msnd: def useradd(self, email, nick = None, gid = '0'): "Adds a user" if not nick: nick = email - nick = urllib.quote(nick) + nick = nickquote(nick) self._send('ADD', 'AL ' + email + ' ' + nick) self._send('ADD', 'FL ' + email + ' ' + nick + ' ' + gid) return 1 @@ -388,9 +394,7 @@ class msnd: def userren(self, email, newnick): "Renames a user" - # don't url-quote the newnick; the server has a bug and it - # won't store extended characters that way; send directly the - # UTF-8 encoded new nick + newnick = nickquote(newnick) self._send('REA', email + ' ' + newnick) return 1 @@ -408,7 +412,7 @@ class msnd: def groupadd(self, name): "Adds a group" - name = urllib.quote(name) + name = nickquote(name) self._send('ADG', name + ' 0') return 1 @@ -418,7 +422,7 @@ class msnd: return 1 def groupren(self, gid, newname): - newname = urllib.quote(newname) + newname = nickquote(newname) self._send('REG', gid + ' ' + newname) return 1