def send_message(self, update: Update, context, text: str, kb: KB = None): if kb is not None: return context.bot.send_message(chat_id=update.effective_chat.id, text=text, reply_markup=kb.get()) else: return context.bot.send_message(chat_id=update.effective_chat.id, text=text)
def greeting(self, update: Update, context, name: str): kb = KeyboardBuilder() kb.button("Find anagram", "Anagram") kb.button("Find palindrome", "palindrome") markup = kb.get() msg = f"Hi, {name}! Enter '/palindrome' to find palindrome." \ f" Enter '/anagram' to find anagram, use '$add ... to add some words" self.send_message(update, context, msg, markup=markup)
def greeting_callback(self, update, context): kb = KeyboardBuilder().elements_in_line(1) kb.button("1", self.callback, args=(1, 3, 4, 9))\ .button("2", self.callback, args=(2,))\ .button("3", self.callback, args=(3,))\ .button("show", self.show_callback)\ .button("delete history", self.delete_history_callback)\ update.message.reply_text('Please choose:', reply_markup=kb.get())
def send_message_photo(self, update: Update, context, caption: str, kb: KB = None, photo: Union[Path, str] = None): return context.bot.send_photo(chat_id=update.effective_chat.id, photo=photo, caption=caption, reply_markup=kb.get())
def edit_message_reply_markup(self, update: Update, context, kb: KB): return context.bot.edit_message_reply_markup( chat_id=update.effective_chat.id, message_id=update.effective_message.message_id, reply_markup=kb.get())
def edit_message(self, update: Update, context, text: str, kb: KB): context.bot.edit_message_text( chat_id=update.effective_chat.id, message_id=update.effective_message.message_id, text=text, reply_markup=kb.get())