def messageMethod(self, bot, update): chat_id = update.message.chat_id message = update.message.text if message in LanguageSupport.allVariants(HELP_BUTTON): self.command_help(bot, update) elif message in LanguageSupport.allVariants(ABOUT_BUTTON): self.command_about(bot, update) elif message in LanguageSupport.allVariants(OTHER_BOTS_BUTTON): self.command_otherbots(bot, update) elif message in LanguageSupport.allVariants(RATE_ME_BUTTON): self.command_rateme(bot, update) elif message in LanguageSupport.allVariants(TOGGLE_TRANSLATIONS_LINKS_BUTTON): self.command_toggle_links(bot, update) elif message in LanguageSupport.allVariants(TOGGLE_TRANSCRIPTIONS_BUTTON): self.command_toggle_transcriptions(bot, update) elif message == EN_LANG_BUTTON: self.command_set_lang_en(bot, update) elif message == RU_LANG_BUTTON: self.command_set_lang_ru(bot, update) elif message in LanguageSupport.allVariants(PICK_LANGUAGE_BUTTON): self.command_open_language_menu(bot, update) elif message in LanguageSupport.allVariants(HIDE_KEYS_BUTTON): self.command_hide_keyboard(bot, update) elif message in LanguageSupport.allVariants(SHOW_KEYS_BUTTON): self.command_show_keyboard(bot, update) elif message in LanguageSupport.allVariants(BACK_BUTTON): self.sendMessage(bot, update, BACK_TO_MAIN_MENU_MESSAGE) elif message in LANGUAGE_INDICIES.keys(): self.command_set_dict_language(bot, update) else: # find word in dict pass # self.unknown_command(bot, update) self.command_find_word(bot, update)
def messageMethod(self, bot, update, lS=None): chat_id = update.message.chat_id message = update.message.text log.info("messageMethod. Chat_id:", chat_id, "Message:", message) if message in LanguageSupport.allVariants(HELP_BUTTON): self.command_help(bot, update, lS) elif message in LanguageSupport.allVariants(ABOUT_BUTTON): self.command_about(bot, update, lS) elif message in LanguageSupport.allVariants(OTHER_BOTS_BUTTON): self.command_otherbots(bot, update, lS) # elif message == EN_LANG_BUTTON: # self.command_set_lang_en(bot, update, lS) # elif message == RU_LANG_BUTTON: # self.command_set_lang_ru(bot, update, lS) elif message in LanguageSupport.allVariants(GIMMEPIC_BUTTON): self.command_gimmepic(bot, update, lS) elif message in LanguageSupport.allVariants(SUBSCRIBE_BUTTON): self.command_subscribe(bot, update, lS) elif message in LanguageSupport.allVariants(UNSUBSCRIBE_BUTTON): self.command_unsubscribe(bot, update, lS) elif message in LanguageSupport.allVariants(SHOW_PERIOD_BUTTON): self.command_show_period(bot, update, lS) else: if not self.setPeriod(bot, update, lS): self.unknown_command(bot, update, lS)
def test_all_variants_string(self): message = "Hello" lang = "DE" L = LanguageSupport(lang) self.assertEqual(L.allVariants(message), [message])