Exemple #1
0
def test_search_on_google():
    rv = search_on_google('wazaundtechnik')

    expected_text = (
        'Jangan ngeleli! Googling dong: '
        'https://google.com/search?q=wazaundtechnik'
    )
    assert rv == expected_text
Exemple #2
0
def leli(message):
    app.logger.debug('Detected leli command {!r}'.format(message.text))
    try:
        if message.text.startswith('/leli'):
            _, term = message.text.split(' ', maxsplit=1)
        else:
            term = message.text
    except ValueError:
        app.logger.debug('Cannot split text {!r}'.format(message.text))
        bot.reply_to(message, 'Apa yang mau dileli?', force_reply=True)
    else:
        app.logger.debug('Extracted leli term {!r}'.format(term))
        try:
            result = search_on_wikipedia(term)
        except HTTPError:
            bot.reply_to(message, 'Aduh ada error nich')
        except ConnectionError:
            bot.reply_to(message, "Koneksi lagi bapuk nih :'(")
        else:
            if result is None:
                result = search_on_google(term)
            bot.reply_to(message, result, disable_web_page_preview=True)
Exemple #3
0
def leli(message):
    app.logger.debug('Detected leli command {!r}'.format(message.text))
    try:
        if message.text.startswith('/leli'):
            _, term = message.text.split(' ', maxsplit=1)
        else:
            term = message.text
    except ValueError:
        app.logger.debug('Cannot split text {!r}'.format(message.text))
        bot.reply_to(message, 'Apa yang mau dileli?', force_reply=True)
    else:
        app.logger.debug('Extracted leli term {!r}'.format(term))
        try:
            result = search_on_wikipedia(term)
        except HTTPError:
            bot.reply_to(message, 'Aduh ada error nich')
        except ConnectionError:
            bot.reply_to(message, "Koneksi lagi bapuk nih :'(")
        else:
            if result is None:
                result = search_on_google(term)
            bot.reply_to(message, result, disable_web_page_preview=True)
Exemple #4
0
def test_search_on_google():
    rv = search_on_google('wazaundtechnik')

    expected_text = ('Jangan ngeleli! Googling dong: '
                     'https://google.com/search?q=wazaundtechnik')
    assert rv == expected_text