<commit_before>import sys
import json
import random

import requests
from fbchat.models import ThreadType, MessageReaction

from bot import Bot
import strings

# THREAD_ID is only used for readding admins. Leona will work in any chat she's
# added to.
THREAD_ID = "1261018777320723"


class LeonaBot(Bot):
    def __init__(self, email, password, name, admins=[], protected=[],
                 *args, **kwargs):
        super(LeonaBot, self).__init__(email=email, password=password,
                                       name=name, admins=admins,
                                       protected=protected, *args, **kwargs)

        self.add_message_handler("say", self.say_cmd, admin=True)
        self.add_message_handler("protect", self.protect_cmd, admin=True)
        self.add_message_handler("unprotect", self.unprotect_cmd, admin=True)
        self.add_message_handler("meme", self.meme_cmd)
        self.add_message_handler("readd", self.readd_cmd, admin=True)
        self.add_message_handler("trump", self.trump_cmd)
        self.add_message_handler("love", self.love_cmd)

    def love_cmd(self, msg):
        """I'll heart react your message."""
        self.reactToMessage(msg['mid'], MessageReaction.LOVE)

    def say_cmd(self, msg):
        """Repeat the words following 'say'."""
        self.sendMessage(msg['message'][4:].strip(), msg['thread_id'],
                         msg['thread_type'])

    def protect_cmd(self, msg):
        """Readd the specified person if they are removed."""
        protect_name = msg['message'][8:].strip('@').strip()
        protect_id = self.protect_user(protect_name)<commit_msg>Leona: add Google Translate command<commit_after>import sys
import json
import random

import requests
from fbchat.models import ThreadType, MessageReaction
from googletrans import Translator

from bot import Bot
import strings

# THREAD_ID is only used for readding admins. Leona will work in any chat she's
# added to.
THREAD_ID = "1261018777320723"


class LeonaBot(Bot):
    def __init__(self, email, password, name, admins=[], protected=[],
                 *args, **kwargs):
        super(LeonaBot, self).__init__(email=email, password=password,
                                       name=name, admins=admins,
                                       protected=protected, *args, **kwargs)

        self.add_message_handler("say", self.say_cmd, admin=True)
        self.add_message_handler("protect", self.protect_cmd, admin=True)
        self.add_message_handler("unprotect", self.unprotect_cmd, admin=True)
        self.add_message_handler("meme", self.meme_cmd)
        self.add_message_handler("readd", self.readd_cmd, admin=True)
        self.add_message_handler("trump", self.trump_cmd)
        self.add_message_handler("love", self.love_cmd)
	self.add_message_handler("translate", self.translate_cmd)
        self.translator = Translator()

    def translate_cmd(self, msg):
        """Translate any text to English."""
        text = msg['message'][10:].strip()
	result = "Translation: " + self.translator.translate(text).text
        self.sendMessage(result, msg['thread_id'], msg['thread_type'])

    def love_cmd(self, msg):
        """I'll heart react your message."""
        self.reactToMessage(msg['mid'], MessageReaction.LOVE)

    def say_cmd(self, msg):
        """Repeat the words following 'say'."""
        self.sendMessage(msg['message'][4:].strip(), msg['thread_id'],
                         msg['thread_type'])

    def protect_cmd(self, msg):
        """Readd the specified person if they are removed."""
        protect_name = msg['message'][8:].strip('@').strip()
        protect_id = self.protect_user(protect_name)
{'fraction_non_alphanumeric': 0.12466051059206952, 'fraction_numerical': 0.010320478001086366, 'mean_word_length': 3.1104910714285716, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '608944', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1067, 'n_words': 247}