reply html
This commit is contained in:
parent
65de9d7fbd
commit
301e9a0964
|
@ -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"
|
||||
"<strong>/ter</strong> — список территорий\n"
|
||||
"<strong>/inv</strong> — начать новую инвентаризацию\n"
|
||||
"<strong>/my</strong> — продолжить инвентаризацию\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(
|
||||
("<strong>Ваши инвентаризации</strong>"),
|
||||
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 <code>{user.id}</code>"
|
||||
|
||||
def format_inv(self, inv):
|
||||
return f"Инвентаризация `{inv.name}` от `{inv.created_at.strftime('%x')}`"
|
||||
return f"Инвентаризация <strong>{inv.name}</strong> от <code>{inv.created_at.strftime('%x')}</code>"
|
||||
|
||||
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"Название ТМЦ <code>{tmc.name}</code>"
|
||||
|
||||
def format_element(self, field):
|
||||
return f"Элемент `{field.name}`"
|
||||
return f"Элемент <code>{field.name}</code>"
|
||||
|
||||
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 "Текст сохранен"
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue