From 301e9a09644dab8b48ea5530a34f34e7be86bb1f Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Mon, 12 Aug 2024 16:42:30 +0300 Subject: [PATCH] reply html --- back/tgbot/tgbot.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/back/tgbot/tgbot.py b/back/tgbot/tgbot.py index 66a052b..8fe03e1 100644 --- a/back/tgbot/tgbot.py +++ b/back/tgbot/tgbot.py @@ -128,12 +128,12 @@ class TgBot: TgBot.app.add_error_handler(self.error_handler) async def start(self, update: Update, context: CallbackContext): - await update.effective_message.reply_text( + await update.effective_message.reply_html( ( "Это бот для проведения инвентаризации\n" - "/ter \-\- список территорий\n" - "/inv \-\- начать новую инвентаризацию\n" - "/my \-\- продолжить инвентаризацию\n" + "/ter — список территорий\n" + "/inv — начать новую инвентаризацию\n" + "/my — продолжить инвентаризацию\n" ), # reply_markup=ForceReply(selective=True), reply_parameters=ReplyParameters(message_id=update.effective_message.message_id), @@ -149,8 +149,8 @@ class TgBot: inv.append({"name": e.name, "id": str(e.id)}) keys = chunk(1, inv) if len(inv) > 0: - await update.message.reply_text( - ("Ваши инвентаризации"), + await update.message.reply_html( + ("Ваши инвентаризации"), reply_markup=InlineKeyboardMarkup( [ [ @@ -166,15 +166,15 @@ class TgBot: reply_parameters=ReplyParameters(message_id=update.message.message_id), ) else: - await update.message.reply_text( + await update.message.reply_html( "У вас нет доступных для редактирования инвентаризаций" ) def format_username(self, user): - return f"Специалист {user.name or user.full_name}, ID {user.id}" + return f"Специалист {user.name or user.full_name}, ID {user.id}" def format_inv(self, inv): - return f"Инвентаризация `{inv.name}` от `{inv.created_at.strftime('%x')}`" + return f"Инвентаризация {inv.name} от {inv.created_at.strftime('%x')}" async def get_tmc_count(self, inv): tmc_count = [] @@ -186,14 +186,14 @@ class TgBot: def format_tmc_count(self, tmc_count): res = ["Всего ТМЦ:"] - res.append(", ".join([f"{e['tmc__name']} \({e['count']}\)" for e in tmc_count])) + res.append(", ".join([f"{e['tmc__name']} ({e['count']})" for e in tmc_count])) return " ".join(res) def format_tmc_name(self, tmc): - return f"Название ТМЦ `{tmc.name}`" + return f"Название ТМЦ {tmc.name}" def format_element(self, field): - return f"Элемент `{field.name}`" + return f"Элемент {field.name}" def stop_inv_button(self): return [ @@ -337,7 +337,7 @@ class TgBot: reply_markup=InlineKeyboardMarkup(inline_keyboard=keyboard), ) else: - await update.effective_message.reply_text( + await update.effective_message.reply_html( text, reply_parameters=ReplyParameters( message_id=update.effective_message.message_id @@ -385,7 +385,7 @@ class TgBot: "Вы выбрали территорию инвентаризации\n" "Теперь вы можете начать инвентаризацию /inv" ) - await update.effective_message.reply_text( + await update.effective_message.reply_html( text=text, reply_parameters=ReplyParameters( message_id=update.effective_message.message_id @@ -399,7 +399,7 @@ class TgBot: logger.info(f"Step {current_step} from user {user.full_name}") if not context.chat_data.get("terdeep_value", None): - await update.effective_message.reply_text( + await update.effective_message.reply_html( text=("Вы не выбрали территорию /ter"), reply_parameters=ReplyParameters( message_id=update.effective_message.message_id @@ -411,7 +411,7 @@ class TgBot: context.chat_data["step"] = "name" current_ter_id = context.chat_data.get("terdeep_value", None) current_ter = await TerritoryItem.objects.aget(id=current_ter_id) - await update.effective_message.reply_text( + await update.effective_message.reply_html( "\n".join([self.format_username(user), f"Введите название объекта"]), reply_parameters=ReplyParameters( message_id=update.effective_message.message_id @@ -428,7 +428,7 @@ class TgBot: ) inv.name = update.message.text await inv.asave() - res = await update.effective_message.reply_text( + res = await update.effective_message.reply_html( "Ок, сохранено", reply_markup=ReplyKeyboardRemove() ) await res.delete() @@ -462,7 +462,7 @@ class TgBot: ] keyboard.append(self.stop_inv_button()) - await update.effective_message.reply_text( + await update.effective_message.reply_html( text, reply_parameters=ReplyParameters( message_id=update.effective_message.message_id @@ -504,7 +504,7 @@ class TgBot: ] keyboard.append(self.stop_inv_button()) - await update.effective_message.reply_text( + await update.effective_message.reply_html( text, reply_parameters=ReplyParameters( message_id=update.effective_message.message_id @@ -521,7 +521,7 @@ class TgBot: context.chat_data["step"] = "add_element_data" - await update.effective_message.reply_text( + await update.effective_message.reply_html( "\n".join( [ self.format_inv(inv), @@ -553,7 +553,7 @@ class TgBot: await element.asave() await inv.asave() - await update.effective_message.reply_text( + await update.effective_message.reply_html( "Изображение сохранено" if update.message.photo else "Текст сохранен" )