def send_menu(self) -> None: buttons = InlineKeyboardMarkup() buttons.add( InlineKeyboardButton(text="Зрозуміло", callback_data='exit ')) r = requests.get( os.getenv("SERVER_URL") + "generate-card?id=" + str(self.user.tg_id)) res_dict = json.loads(r.content) if not res_dict.get("successful"): bot.answer_callback_query(callback_query_id=self._call.id, show_alert=True, text=res_dict["reason"]) bot.send_message(self.user.tg_id, texts.card_limit.format(res_dict["reason"]), reply_markup=buttons) else: card = res_dict["id"] pin = res_dict["pin"] msg_text = texts.new_card.format(card, pin) bot.send_message(self.user.tg_id, msg_text, reply_markup=buttons)
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 send_menu(self) -> None: self.user.cur_card = None msg_text = texts.start_message buttons = InlineKeyboardMarkup() buttons.add( InlineKeyboardButton(text="Створити карту", callback_data='create_card '), InlineKeyboardButton(text="Мої карти", callback_data='my_cards ')) bot.send_message(self.user.tg_id, msg_text, reply_markup=buttons)
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 send_menu(self) -> None: r = self.user.get_balance() buttons = InlineKeyboardMarkup() buttons.add( InlineKeyboardButton(text="Зняти", callback_data='withdraw '), InlineKeyboardButton(text="Поповнити", callback_data='deposit '), InlineKeyboardButton(text="Переслати", callback_data='transfer '), InlineKeyboardButton(text="Вийти", callback_data='exit ')) bot.send_message(self.user.tg_id, texts.card_menu.format( "**** **** **** " + self.user.cur_card[-4:], r["balance"]), reply_markup=buttons)
def send_menu(self) -> None: r = self.user.get_balance() buttons = InlineKeyboardMarkup() buttons.add(InlineKeyboardButton(text="Назад", callback_data='back ')) self._msg_id = bot.send_message(self.user.tg_id, texts.transfer_1.format(r["balance"]), reply_markup=buttons).message_id
def send_menu(self) -> None: buttons = InlineKeyboardMarkup() buttons.add(InlineKeyboardButton(text="Назад", callback_data='back ')) self._msg_id = bot.send_message( self.user.tg_id, texts.wait_pin.format("**** **** **** " + self.user.cur_card[-4:]), reply_markup=buttons).message_id
def send_menu(self) -> None: buttons = InlineKeyboardMarkup() buttons.add( InlineKeyboardButton(text="Завершити", callback_data='exit ')) self._msg_id = bot.send_message(self.user.tg_id, texts.operation_not_ok.format( self._reason), reply_markup=buttons).message_id
def send_menu(self) -> None: r = requests.get( os.getenv("SERVER_URL") + 'cards?id=' + str(self.user.tg_id)) content = json.loads(r.content) try: cards = [str(x) for x in content["cards"]] except Exception as e: self.user.transition_to(OperationNotOk(content["reason"])) return buttons = InlineKeyboardMarkup() for card in cards: buttons.add( InlineKeyboardButton(text="**** **** **** " + card[-4:], callback_data='choose_card ' + card)) msg_text = 'Оберіть карту...' if len(cards) > 0 else texts.card_limit bot.send_message(self.user.tg_id, msg_text, reply_markup=buttons)
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