get around occasional utf8 conversion exceptions by swallowing
those exceptions and moving on, since the output never seemed wrong in these cases anyway
This commit is contained in:
parent
7dfdf28c19
commit
713b1e560b
10
dr.botzo.py
10
dr.botzo.py
@ -52,9 +52,15 @@ class DrBotServerConnection(irclib.ServerConnection):
|
|||||||
self.send_raw("PRIVMSG %s :%s" % (target, unicode(splittext).encode('utf-8')))
|
self.send_raw("PRIVMSG %s :%s" % (target, unicode(splittext).encode('utf-8')))
|
||||||
|
|
||||||
# done splitting
|
# done splitting
|
||||||
self.send_raw("PRIVMSG %s :%s" % (target, unicode(text).encode('utf-8')))
|
try:
|
||||||
|
text = unicode(text).encode('utf-8')
|
||||||
|
except UnicodeDecodeError: pass
|
||||||
|
self.send_raw("PRIVMSG %s :%s" % (target, text))
|
||||||
else:
|
else:
|
||||||
self.send_raw("PRIVMSG %s :%s" % (target, unicode(text).encode('utf-8')))
|
try:
|
||||||
|
text = unicode(text).encode('utf-8')
|
||||||
|
except UnicodeDecodeError: pass
|
||||||
|
self.send_raw("PRIVMSG %s :%s" % (target, text))
|
||||||
|
|
||||||
class DrBotIRC(irclib.IRC):
|
class DrBotIRC(irclib.IRC):
|
||||||
"""Subclass irclib's IRC, in order to create a DrBotServerConnection."""
|
"""Subclass irclib's IRC, in order to create a DrBotServerConnection."""
|
||||||
|
@ -33,7 +33,9 @@ class GoogleTranslate(Module):
|
|||||||
fromlang = whats[1]
|
fromlang = whats[1]
|
||||||
tolang = whats[2]
|
tolang = whats[2]
|
||||||
text = ' '.join(whats[3:])
|
text = ' '.join(whats[3:])
|
||||||
text = text.encode('utf-8')
|
try:
|
||||||
|
text = text.encode('utf-8')
|
||||||
|
except UnicodeDecodeError: pass
|
||||||
|
|
||||||
langpair = '%s|%s' % (fromlang, tolang)
|
langpair = '%s|%s' % (fromlang, tolang)
|
||||||
gt_url = 'http://ajax.googleapis.com/ajax/services/language/translate?'
|
gt_url = 'http://ajax.googleapis.com/ajax/services/language/translate?'
|
||||||
|
Loading…
Reference in New Issue
Block a user