From a546977f70f9b8c4acac632972cd26a2dd8d7676 Mon Sep 17 00:00:00 2001 From: "Sean B. Palmer" Date: Fri, 15 Mar 2013 15:28:03 +0000 Subject: A new scheduling command and some improvements to gc --- modules/translate.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'modules/translate.py') 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'] -- cgit v1.2.3-1-g7c22