def voice(bot, update):
    chat_id = get_chat_id(update)
    voice_enabled = TBDB.get_chat_voice_enabled(chat_id)
    if voice_enabled == 0:
        return

    message = update.message or update.channel_post
    v = message.voice

    if voice_enabled == 2:
        pass
    else:
        TranscriberBot.get().voice_thread_pool.submit(process_media_voice, bot,
                                                      update, v, "voice")
示例#2
0
def test_db():
    id = 1234

    TBDB.create_default_chat_entry(id, 'en-US')
    assert TBDB.get_chat_lang(id) == 'en-US'
    assert TBDB.get_chat_active(id) == 1

    TBDB.set_chat_lang(id, 'lang')
    TBDB.set_chat_voice_enabled(id, 2)
    TBDB.set_chat_photos_enabled(id, 1)
    TBDB.set_chat_qr_enabled(id, 1)
    TBDB.set_chat_active(id, 0)
    TBDB.set_chat_ban(id, 1)

    assert TBDB.get_chat_lang(id) == 'lang'
    assert TBDB.get_chat_voice_enabled(id) == 2
    assert TBDB.get_chat_photos_enabled(id) == 1
    assert TBDB.get_chat_qr_enabled(id) == 1
    assert TBDB.get_chat_active(id) == 0
    assert TBDB.get_chat_ban(id) == 1
def document(bot, update):
    chat_id = get_chat_id(update)
    voice_enabled = TBDB.get_chat_voice_enabled(chat_id)

    m = update.message or update.channel_post
    file_name = m.document.file_name
    _, file_ext = os.path.splitext(file_name)

    if file_ext[1:] not in config.get_config_prop("app")["audio_ext"]:
        logger.info('extension %s not recognized', file_ext)
        return

    if voice_enabled == 0:
        return

    if voice_enabled == 2:
        pass
    else:
        TranscriberBot.get().voice_thread_pool.submit(process_media_voice, bot,
                                                      update, m.document,
                                                      'audio_document')