Skip to content

Commit b06ae3f

Browse files
committed
v0.1.15.19 - msg templates
1 parent 5853e34 commit b06ae3f

File tree

8 files changed

+25
-9
lines changed

8 files changed

+25
-9
lines changed

locales/en.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@
314314

315315
enter_msg_text = "Enter message text."
316316
msg_sent = "✅ Message sent to <a href=\"https://funpay.com/chat/?node={}\">{}</a> chat."
317+
msg_sent_short = "✅ Message sent."
317318
msg_sending_error = "❌ Failed to send a message to <a href=\"https://funpay.com/chat/?node={}\">{}</a> chat."
319+
msg_sending_error_short = "❌ Failed to send a message to chat."
318320
send_img = "Send me an image."
319321

320322
greeting_changed = "✅ The greeting text has been changed."

locales/ru.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@
316316

317317
enter_msg_text = "Введи текст сообщения."
318318
msg_sent = "✅ Сообщение отправлено в чат <a href=\"https://funpay.com/chat/?node={}\">{}</a>."
319+
msg_sent_short = "✅ Сообщение отправлено."
319320
msg_sending_error = "❌ Не удалось отправить сообщение в чат <a href=\"https://funpay.com/chat/?node={}\">{}</a>."
321+
msg_sending_error_short = "❌ Не удалось отправить сообщение в чат."
320322
send_img = "Отправь мне изображение."
321323

322324
greeting_changed = "✅ Текст приветствия изменен."

locales/uk.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@
316316

317317
enter_msg_text = "Введи текст повідомлення."
318318
msg_sent = "✅ Повідомлення відправлено у чат <a href=\"https://funpay.com/chat/?node={}\">{}</a>."
319+
msg_sent_short = "✅ Повідомлення відправлено."
319320
msg_sending_error = "❌ Не вдалося відправити повідомлення у чат <a href=\"https://funpay.com/chat/?node={}\">{}</a>."
321+
msg_sending_error_short = "❌ Не вдалося відправити повідомлення у чат."
320322
send_img = "Відправ мені зображення."
321323

322324
greeting_changed = "✅ Текст привітання змінено."

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
......................','.",`............ ..................
5757
............................................................"""
5858

59-
VERSION = "0.1.15.18"
59+
VERSION = "0.1.15.19"
6060

6161
Utils.cardinal_tools.set_console_title(f"FunPay Cardinal v{VERSION}")
6262

tg_bot/CBT.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@
286286
prev_page: ID предыдущей клавиатуры.
287287
0 - клавиатура нового сообщения.
288288
1 - клавиатура нового сообщения (2).
289+
2 - клавиатура заказа.
290+
3 - клавиатура отсутствует.
289291
extra: str / int - доп. данные для клавиатуры (через ":").
290292
"""
291293

@@ -331,6 +333,8 @@
331333
prev_page: ID предыдущей клавиатуры.
332334
0 - клавиатура нового сообщения.
333335
1 - клавиатура нового сообщения (2).
336+
2 - клавиатура заказа.
337+
3 - клавиатура отсутствует.
334338
extra: str / int - доп. данные для клавиатуры (через ":").
335339
"""
336340

tg_bot/bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ def __register_handlers(self):
11451145
self.cbq_handler(self.empty_callback, lambda c: c.data == CBT.EMPTY)
11461146
self.cbq_handler(self.switch_lang, lambda c: c.data.startswith(f"{CBT.LANG}:"))
11471147

1148-
def send_notification(self, text: str | None, keyboard=None,
1148+
def send_notification(self, text: str | None, keyboard: K | None = None,
11491149
notification_type: str = utils.NotificationTypes.other, photo: bytes | None = None,
11501150
pin: bool = False):
11511151
"""

tg_bot/keyboards.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,8 @@ def templates_list_ans_mode(c: Cardinal, offset: int, node_id: int, username: st
671671
None, f"{CBT.SEND_TMPLT}:{offset + index}:{node_id}:{username}:{prev_page}{extra_str}"))
672672

673673
extra_list = [node_id, username, prev_page]
674-
extra_list.extend(extra)
674+
if extra:
675+
extra_list.extend(extra)
675676
kb = add_navigation_buttons(kb, offset, MENU_CFG.TMPLT_BTNS_AMOUNT, len(templates),
676677
len(c.telegram.answer_templates), CBT.TMPLT_LIST_ANS_MODE,
677678
extra_list)

tg_bot/templates_cp.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ def send_template(c: CallbackQuery):
128128
split[5:])
129129

130130
if template_index > len(tg.answer_templates) - 1:
131-
bot.send_message(c.message.chat.id, _("tmplt_not_found_err", template_index))
131+
bot.send_message(c.message.chat.id, _("tmplt_not_found_err", template_index),
132+
message_thread_id=c.message.message_thread_id)
132133
if prev_page == 0:
133134
bot.edit_message_reply_markup(c.message.chat.id, c.message.id,
134135
reply_markup=keyboards.reply(node_id, username))
@@ -144,12 +145,16 @@ def send_template(c: CallbackQuery):
144145

145146
text = tg.answer_templates[template_index].replace("$username", safe_text(username))
146147
result = cardinal.send_message(node_id, text, username)
147-
if result:
148-
bot.send_message(c.message.chat.id, _("tmplt_msg_sent", node_id, username, utils.escape(text)),
149-
reply_markup=keyboards.reply(node_id, username, again=True, extend=True))
148+
149+
if prev_page == 3:
150+
bot.answer_callback_query(c.id, _("msg_sent_short") if result else _("msg_sending_error_short"))
151+
return
150152
else:
151-
bot.send_message(c.message.chat.id, _("msg_sending_error", node_id, username),
152-
reply_markup=keyboards.reply(node_id, username, again=True, extend=True))
153+
msg_text = _("tmplt_msg_sent", node_id, username, utils.escape(text)) if result else \
154+
_("msg_sending_error", node_id, username)
155+
bot.send_message(c.message.chat.id, msg_text,
156+
reply_markup=keyboards.reply(node_id, username, again=True, extend=True),
157+
message_thread_id=c.message.message_thread_id)
153158
bot.answer_callback_query(c.id)
154159

155160
tg.cbq_handler(open_templates_list, lambda c: c.data.startswith(f"{CBT.TMPLT_LIST}:"))

0 commit comments

Comments
 (0)