예제 #1
0
def language_handler(bot, update, language):
  chat_id = get_chat_id(update)
  lang = config.get_config_prop("app")["languages"][language] #ISO 639-1 code for language
  TBDB.set_chat_lang(chat_id, lang)
  message = R.get_string_resource("language_set", lang).replace("{lang}", language)
  reply = update.message or update.channel_post
  reply.reply_text(message)
예제 #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