Ejemplo n.º 1
0
def deltabot_start(bot: DeltaBot) -> None:
    global CBOT, LIST_TRAINER

    locale = bot.get('locale') or 'en'
    corpus = dict(
        es='spanish',
        de='german',
        it='italian',
    )
    if locale == 'es':
        default_replies.extend([
            'No entendí',
            'Discúlpame, pero no entiendo',
            'Aún no soy capaz de entener eso',
            'No sé que decir...',
            'Lo único que puedo afirmarte es que Delta Chat es lo mejor!',
            'Solo sé que no sé nada...',
            'Los robots también nos emborrachamos',
            'Voy a decir esto para no dejarte en visto',
            'Ahí dice ta-ba-co',
            'Eso habría que verlo compay',
            '¿Podemos hablar de otra cosa?',
            'Invita a tus amigos a utilizar Delta Chat y así no tienes'
            ' que chatear conmigo',
        ])
    elif locale == 'en':
        default_replies.extend([
            'I do not understand',
            'I do not know what to say...',
            'Can we talk about something else?',
            'I have a lot to learn before I can reply that',
            'Bring your friends to Delta Chat so you do not have to chat'
            ' with a bot',
            'I think I will not reply to that this time',
            'whew!',
        ])

    CBOT = ChatBot(
        bot.self_contact.addr,
        storage_adapter='chatterbot.storage.SQLStorageAdapter',
        database_uri=_get_db_uri(bot),
        read_oly=_getdefault(bot, 'learn', '1') == '0',
        logic_adapters=[{
            'import_path': 'chatterbot.logic.BestMatch',
            'default_response': default_replies,
            'maximum_similarity_threshold': 0.9,
        }],
    )
    LIST_TRAINER = ListTrainer(CBOT)
    trainer = ChatterBotCorpusTrainer(CBOT)
    trainer.train('chatterbot.corpus.' + corpus.get(locale, 'english'))
Ejemplo n.º 2
0
def _getdefault(bot: DeltaBot, key: str, value: str = None) -> str:
    val = bot.get(key, scope=__name__)
    if val is None and value is not None:
        bot.set(key, value, scope=__name__)
        val = value
    return val
Ejemplo n.º 3
0
def _get_mode(bot: DeltaBot, addr: str) -> str:
    return bot.get('mode', scope=addr) or bot.get('mode') or 'htmlzip'
Ejemplo n.º 4
0
def _get_locale(bot: DeltaBot, addr: str) -> str:
    return bot.get('locale', scope=addr) or bot.get('locale') or 'en'