def handle_message_text(self, msg: Message) -> None: bot.delete_message(self.user.tg_id, self._msg_id) if not self._amount: try: amount = int(msg.text) if int(self.user.get_balance()["balance"]) - amount < 0: from app.telegram.user.user_states.OperationNotOk import OperationNotOk self.user.transition_to(OperationNotOk("Low balance!")) else: self._amount = amount buttons = InlineKeyboardMarkup() buttons.add( InlineKeyboardButton(text="Назад", callback_data='back ')) self._msg_id = bot.send_message( self.user.tg_id, texts.transfer_2, reply_markup=buttons).message_id except ValueError: buttons = InlineKeyboardMarkup() buttons.add( InlineKeyboardButton(text="Назад", callback_data='back ')) self._msg_id = bot.send_message( self.user.tg_id, "Це не число, спробуй ще раз...", reply_markup=buttons).message_id else: to_card = msg.text self.user.do_transfer(self._amount, to_card)
def handle_message_text(self, msg: Message) -> None: password = msg.text r = self.user.do_card_auth(password) bot.delete_message(self.user.tg_id, self._msg_id) if r.get("success", None): self.user.transition_to(CardMenu()) else: self._try_count += 1 if self._try_count < 3: buttons = InlineKeyboardMarkup() buttons.add( InlineKeyboardButton(text="Назад", callback_data='back ')) self._msg_id = bot.send_message( self.user.tg_id, "Пароль не вірний спробуй ще раз...", reply_markup=buttons).message_id else: from app.telegram.user.user_states.OperationNotOk import OperationNotOk self.user.transition_to( OperationNotOk("To many bad auth requests."))
def handle_button(self, call: CallbackQuery) -> None: expected_buttons = ["ok", "exit"] cur_button, card_id = call.data.split(' ') if cur_button in expected_buttons: bot.delete_message(self.user.tg_id, call.message.message_id) if cur_button == "exit": from app.telegram.user.user_states.StartMenu import StartMenu self.user.transition_to(StartMenu())
def handle_button(self, call: CallbackQuery) -> None: expected_buttons = ["choose_card"] cur_button, card_id = call.data.split(' ') if cur_button in expected_buttons: bot.delete_message(self.user.tg_id, call.message.message_id) if cur_button == "choose_card": self.user.cur_card = card_id self.user.transition_to(WaitPass())
def handle_button(self, call: CallbackQuery) -> None: cur_button = call.data.split(' ')[0] if cur_button in self._buttons: bot.delete_message(self.user.tg_id, call.message.message_id) if cur_button == "create_card": from app.telegram.user.user_states.NewCard import NewCard self.user.transition_to(NewCard(call)) elif cur_button == "my_cards": self.user.transition_to(ChooseCard())
def handle_message_text(self, msg: Message) -> None: bot.delete_message(self.user.tg_id, self._msg_id) try: amount = int(msg.text) self.user.do_withdraw(amount) except ValueError as e: buttons = InlineKeyboardMarkup() buttons.add( InlineKeyboardButton(text="Назад", callback_data='back ')) self._msg_id = bot.send_message(self.user.tg_id, "Це не число, спробуй ще раз...", reply_markup=buttons).message_id
def handle_button(self, call: CallbackQuery) -> None: from app.telegram.user.user_states.StartMenu import StartMenu expected_buttons = ["withdraw", "deposit", "transfer", "exit"] cur_button, card_id = call.data.split(' ') if cur_button in expected_buttons: bot.delete_message(self.user.tg_id, call.message.message_id) if cur_button == "withdraw": self.user.transition_to(Withdraw()) elif cur_button == "deposit": self.user.transition_to(Deposit()) elif cur_button == "transfer": self.user.transition_to(Transfer()) elif cur_button == "exit": self.user.transition_to(StartMenu())