diff --git a/WTE/README.md b/TranslateParty/README.md similarity index 68% rename from WTE/README.md rename to TranslateParty/README.md index 6aeec8d..6f5cc2b 100644 --- a/WTE/README.md +++ b/TranslateParty/README.md @@ -1,13 +1,13 @@ -##WTE - Worst Translations Ever! +## Translate Party **Note: This plugin requires Python 3!** -WTE is a plugin that sticks text through multiple rounds of Google Translate, in order to get -some interesting results. It automatically picks a list of languages to go through, and translates +Translate party sticks text through multiple rounds of Google Translate, in order to get +some amusing results. It automatically picks a list of languages to go through, and translates back and forth between them quite a few times. This guarantees that the result will be different every time. -Any source language [supported by Google Translate](https://translate.google.com/about/intl/en_ALL/#supportedLangs) +Any source language [supported by Google Translate](https://cloud.google.com/translate/v2/translate-reference#supported_languages) is allowed, since auto-detection is used to translate text back to your desired language. This can be set via `config plugins.wte.language`, and defaults to English (`en`). Samples: diff --git a/WTE/__init__.py b/TranslateParty/__init__.py similarity index 100% rename from WTE/__init__.py rename to TranslateParty/__init__.py diff --git a/WTE/config.py b/TranslateParty/config.py similarity index 90% rename from WTE/config.py rename to TranslateParty/config.py index 49bfb94..6bacdab 100644 --- a/WTE/config.py +++ b/TranslateParty/config.py @@ -32,7 +32,7 @@ import supybot.conf as conf import supybot.registry as registry try: from supybot.i18n import PluginInternationalization - _ = PluginInternationalization('WTE') + _ = PluginInternationalization('TranslateParty') except: # Placeholder that allows to run the plugin on a bot # without the i18n module @@ -44,14 +44,14 @@ def configure(advanced): # user or not. You should effect your configuration by manipulating the # registry as appropriate. from supybot.questions import expect, anything, something, yn - conf.registerPlugin('WTE', True) + conf.registerPlugin('TranslateParty', True) -WTE = conf.registerPlugin('WTE') -conf.registerChannelValue(WTE, 'verbose', +TranslateParty = conf.registerPlugin('TranslateParty') +conf.registerChannelValue(TranslateParty, 'verbose', registry.Boolean(True, _("""Determines whether verbose output (list of languages used, etc.) will be used."""))) -conf.registerChannelValue(WTE, 'language', +conf.registerChannelValue(TranslateParty, 'language', registry.String('en', _("""Determines what the output language of 'wte' will be. This should be one of Google Translate's supported language codes as listed at: diff --git a/WTE/local/__init__.py b/TranslateParty/local/__init__.py similarity index 100% rename from WTE/local/__init__.py rename to TranslateParty/local/__init__.py diff --git a/WTE/plugin.py b/TranslateParty/plugin.py similarity index 93% rename from WTE/plugin.py rename to TranslateParty/plugin.py index 32f24d7..7c321e7 100644 --- a/WTE/plugin.py +++ b/TranslateParty/plugin.py @@ -43,19 +43,19 @@ except ImportError: # Python 2 try: from supybot.i18n import PluginInternationalization - _ = PluginInternationalization('WTE') + _ = PluginInternationalization('TranslateParty') except ImportError: # Placeholder that allows to run the plugin on a bot # without the i18n module _ = lambda x:x -class WTE(callbacks.Plugin): +class TranslateParty(callbacks.Plugin): """Worst Translations Ever! plugin. Translates text through multiple rounds of Google Translate to get amazing results!""" threaded = True def __init__(self, irc): - self.__parent = super(WTE, self) + self.__parent = super(TranslateParty, self) self.__parent.__init__(irc) self.langs = { 'af': 'Afrikaans', @@ -166,24 +166,23 @@ class WTE(callbacks.Plugin): args = {"sl": sourceLang, "tl": targetLang, 'q': text} url = "https://translate.googleapis.com/translate_a/single?client=gtx&dt=t&"+ \ urlencode(args) - self.log.debug("WTE: Using URL %s", url) + self.log.debug("TranslateParty: Using URL %s", url) headers = {'User-Agent': ('Mozilla/5.0 (X11; Linux i586; rv:31.0) ' 'Gecko/20100101 Firefox/31.0')} try: data = utils.web.getUrlFd(url, headers).read().decode("utf-8") except utils.web.Error as e: - self.log.exception("WTE: getTranslation errored (probably malformed or too long text)") + self.log.exception("TranslateParty: getTranslation errored (probably malformed or too long text)") return text data = self._jsonRepair(data) data = json.loads(data) return ''.join(x[0] for x in data[0]) @wrap(['text']) - def wte(self, irc, msg, args, text): - """wte + def tp(self, irc, msg, args, text): + """tp - Worst Translations Ever! plugin. Translates through - multiple rounds of Google Translate to get amazing results! + Translates through multiple rounds of Google Translate to get amusing results. """ outlang = self.registryValue('language', msg.args[0]) if outlang not in self.langs: @@ -195,7 +194,7 @@ class WTE(callbacks.Plugin): # in that it gives interesting results but doesn't spam Google's API # (and risk getting blocked) too much. ll = random.sample(self.langs.keys(), random.randint(4,8)) - self.log.debug(format("WTE: Using %i languages: %L " + self.log.debug(format("TranslateParty: Using %i languages: %L " "(outlang %s)", len(ll), ll, outlang)) # For every language in this list, translate the text given from @@ -214,6 +213,6 @@ class WTE(callbacks.Plugin): "(output language %s)", len(ll), languages, outlang)) irc.reply(text) -Class = WTE +Class = TranslateParty # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/WTE/test.py b/TranslateParty/test.py similarity index 87% rename from WTE/test.py rename to TranslateParty/test.py index fda6d67..8b18de8 100644 --- a/WTE/test.py +++ b/TranslateParty/test.py @@ -1,5 +1,5 @@ ### -# Copyright (c) 2014, James Lu +# Copyright (c) 2014,2016 James Lu # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -31,18 +31,18 @@ from supybot.test import * from sys import version_info -class WTETestCase(PluginTestCase): - plugins = ('WTE',) +class TranslatePartyTestCase(PluginTestCase): + plugins = ('TranslateParty',) @unittest.skipIf(version_info[0] < 3, "Not supported on Python 2 (severe Unicode handling problems)") @unittest.skipUnless(network, "Network-based tests have been disabled via " "--no-network") - def testWTE(self): + def testTranslateParty(self): inp = "The quick brown fox jumps over the lazy dog." for _ in range(2): - m = self.getMsg("wte %s" % inp) - print('\nWTE Input: %s\nWTE Response: %s' % (inp, m.args[1])) + m = self.getMsg("tp %s" % inp) + print('\nTranslateParty Input: %s\nWTE Response: %s' % (inp, m.args[1])) assert m, 'No response found.' # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: