Decode unicode string passed to ircmsgs.*. Closes GH-448.

This commit is contained in:
Valentin Lorentz 2013-02-09 18:55:02 +01:00
parent 3fd1e9fd8e
commit 48ba761644

View File

@ -534,6 +534,8 @@ def kick(channel, nick, s='', prefix='', msg=None):
assert isNick(nick), repr(nick)
if msg and not prefix:
prefix = msg.prefix
if sys.version_info[0] < 3 and isinstance(s, unicode):
s = s.decode('utf8')
assert isinstance(s, str)
if s:
return IrcMsg(prefix=prefix, command='KICK',
@ -550,6 +552,8 @@ def kicks(channel, nicks, s='', prefix='', msg=None):
assert all(isNick, nicks), nicks
if msg and not prefix:
prefix = msg.prefix
if sys.version_info[0] < 3 and isinstance(s, unicode):
s = s.decode('utf8')
assert isinstance(s, str)
if s:
return IrcMsg(prefix=prefix, command='KICK',
@ -563,6 +567,8 @@ def privmsg(recipient, s, prefix='', msg=None):
if conf.supybot.protocols.irc.strictRfc():
assert (isChannel(recipient) or isNick(recipient)), repr(recipient)
assert s, 's must not be empty.'
if sys.version_info[0] < 3 and isinstance(s, unicode):
s = s.decode('utf8')
assert isinstance(s, str)
if msg and not prefix:
prefix = msg.prefix
@ -593,6 +599,8 @@ def notice(recipient, s, prefix='', msg=None):
if conf.supybot.protocols.irc.strictRfc():
assert (isChannel(recipient) or isNick(recipient)), repr(recipient)
assert s, 'msg must not be empty.'
if sys.version_info[0] < 3 and isinstance(s, unicode):
s = s.decode('utf8')
assert isinstance(s, str)
if msg and not prefix:
prefix = msg.prefix
@ -641,6 +649,8 @@ def part(channel, s='', prefix='', msg=None):
assert isChannel(channel), repr(channel)
if msg and not prefix:
prefix = msg.prefix
if sys.version_info[0] < 3 and isinstance(s, unicode):
s = s.decode('utf8')
assert isinstance(s, str)
if s:
return IrcMsg(prefix=prefix, command='PART',
@ -655,6 +665,8 @@ def parts(channels, s='', prefix='', msg=None):
assert all(isChannel, channels), channels
if msg and not prefix:
prefix = msg.prefix
if sys.version_info[0] < 3 and isinstance(s, unicode):
s = s.decode('utf8')
assert isinstance(s, str)
if s:
return IrcMsg(prefix=prefix, command='PART',
@ -682,6 +694,8 @@ def topic(channel, topic=None, prefix='', msg=None):
return IrcMsg(prefix=prefix, command='TOPIC',
args=(channel,), msg=msg)
else:
if sys.version_info[0] < 3 and isinstance(s, unicode):
s = s.decode('utf8')
assert isinstance(topic, str)
return IrcMsg(prefix=prefix, command='TOPIC',
args=(channel, topic), msg=msg)