diff options
author | Sean B. Palmer <sean@miscoranda.com> | 2013-03-15 15:28:03 +0000 |
---|---|---|
committer | Sean B. Palmer <sean@miscoranda.com> | 2013-03-15 15:28:03 +0000 |
commit | a546977f70f9b8c4acac632972cd26a2dd8d7676 (patch) | |
tree | ccdb1156c342d0f861e177df2b425d32a0ca3119 /modules/translate.py | |
parent | 7752b56cc2f8325883bad052ad31bf2e7feb706e (diff) | |
download | bot-a546977f70f9b8c4acac632972cd26a2dd8d7676.tar.gz bot-a546977f70f9b8c4acac632972cd26a2dd8d7676.tar.bz2 bot-a546977f70f9b8c4acac632972cd26a2dd8d7676.zip |
A new scheduling command and some improvements to gc
Diffstat (limited to 'modules/translate.py')
-rwxr-xr-x | modules/translate.py | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/modules/translate.py b/modules/translate.py index 927bcb9..11e4f28 100755 --- a/modules/translate.py +++ b/modules/translate.py @@ -93,8 +93,8 @@ def tr2(phenny, input): command = cmd phrase = command - if (len(phrase) > 350) and (not input.admin): - return phenny.reply('Phrase must be under 350 characters.') + # if (len(phrase) > 350) and (not input.admin): + # return phenny.reply('Phrase must be under 350 characters.') src, dest = args if src != dest: @@ -103,6 +103,7 @@ def tr2(phenny, input): msg = msg.decode('utf-8') if msg: msg = web.decode(msg) # msg.replace(''', "'") + if len(msg) > 450: msg = msg[:450] + '[...]' msg = '"%s" (%s to %s, translate.google.com)' % (msg, src, dest) else: msg = 'The %s to %s translation failed, sorry!' % (src, dest) @@ -113,22 +114,30 @@ tr2.commands = ['tr'] tr2.priority = 'low' def mangle(phenny, input): + import time + phrase = input.group(2).encode('utf-8') for lang in ['fr', 'de', 'es', 'it', 'ja']: - backup = phrase - phrase = translate(phrase, 'en', lang) + backup = phrase[:] + phrase, _lang = translate(phrase, 'en', lang) + phrase = phrase.encode("utf-8") + if not phrase: - phrase = backup + phrase = backup[:] break - __import__('time').sleep(0.5) + time.sleep(0.25) + + backup = phrase[:] + phrase, _lang = translate(phrase, lang, 'en') + phrase = phrase.encode("utf-8") - backup = phrase - phrase = translate(phrase, lang, 'en') if not phrase: - phrase = backup + phrase = backup[:] break - __import__('time').sleep(0.5) + time.sleep(0.25) + phrase = phrase.replace(' ,', ',').replace(' .', '.') + phrase = phrase.strip(' ,') phenny.reply(phrase or 'ERRORS SRY') mangle.commands = ['mangle'] |