fix the cheap unicode escapes in GoogleTranslate
This commit is contained in:
parent
b487caf12d
commit
40888869b0
1
TODO
1
TODO
|
@ -11,5 +11,4 @@ dr.botzo --- TODO
|
||||||
* obligatory info command
|
* obligatory info command
|
||||||
* settle on docstrings: http://www.python.org/dev/peps/pep-0257/
|
* settle on docstrings: http://www.python.org/dev/peps/pep-0257/
|
||||||
* voice survivor --- track how long users have voice, score them somehow
|
* voice survivor --- track how long users have voice, score them somehow
|
||||||
* fix the cheap unicode escapes in GoogleTranslate
|
|
||||||
* periodic reconnects when disconnected/split
|
* periodic reconnects when disconnected/split
|
||||||
|
|
|
@ -43,14 +43,8 @@ class GoogleTranslate(Module):
|
||||||
end_idx = translation.find('"}, "')
|
end_idx = translation.find('"}, "')
|
||||||
translation = translation[:end_idx]
|
translation = translation[:end_idx]
|
||||||
|
|
||||||
# do some text conversion
|
# convert escaped unicode
|
||||||
translation = translation.replace('\\u0026quot;', '"')
|
translation = translation.decode('unicode-escape', 'ignore')
|
||||||
translation = translation.replace('\\u0026amp;', '&')
|
|
||||||
translation = translation.replace('\\u003c', '<')
|
|
||||||
translation = translation.replace('\\u0026lt;', '<')
|
|
||||||
translation = translation.replace('\\u003e', '>')
|
|
||||||
translation = translation.replace('\\u0026gt;', '>')
|
|
||||||
translation = translation.replace('\\u0026#39;', '\'')
|
|
||||||
|
|
||||||
return self.reply(connection, replypath, translation)
|
return self.reply(connection, replypath, translation)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue