Skip to content

Commit

Permalink
Handle bot block in support ticket reply
Browse files Browse the repository at this point in the history
Signed-off-by: alfred richardsn <rchrdsn@protonmail.ch>
  • Loading branch information
r4rdsn committed Apr 12, 2020
1 parent 5571064 commit 53d2394
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
15 changes: 10 additions & 5 deletions locale/en/LC_MESSAGES/bot.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: TellerBot\n"
"Report-Msgid-Bugs-To: rchrdsn@protonmail.ch\n"
"POT-Creation-Date: 2020-03-15 19:18+0300\n"
"POT-Creation-Date: 2020-04-12 21:55+0300\n"
"PO-Revision-Date: 2019-10-03 14:00+0300\n"
"Last-Translator: alfred richardsn <rchrdsn@protonmail.ch>\n"
"Language: en\n"
Expand Down Expand Up @@ -307,14 +307,14 @@ msgstr "Send order sum in {currency}."
msgid "choose_sum_currency_with_buttons"
msgstr "Choose currency of sum with buttons."

#: src/handlers/creation.py
msgid "cashless_payment_system"
msgstr "Send cashless payment system."

#: src/handlers/creation.py
msgid "ask_location"
msgstr "Send location of a preferred meeting point for cash payment."

#: src/handlers/creation.py
msgid "cashless_payment_system"
msgstr "Send cashless payment system."

#: src/handlers/creation.py
msgid "location_not_found"
msgstr "Location is not found."
Expand Down Expand Up @@ -676,6 +676,10 @@ msgstr "Your request is cancelled."
msgid "support_response_promise"
msgstr "Your message was forwarded. We'll respond to you within 24 hours."

#: src/handlers/support.py
msgid "reply_error_bot_blocked"
msgstr "Couldn't send reply, I was blocked by the user."

#: src/handlers/support.py
msgid "reply_sent"
msgstr "Reply is sent."
Expand Down Expand Up @@ -711,3 +715,4 @@ msgstr "Your order has expired."
#: src/whitelist.py
msgid "without_gateway"
msgstr "Without gateway"

15 changes: 10 additions & 5 deletions locale/ru/LC_MESSAGES/bot.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: TellerBot\n"
"Report-Msgid-Bugs-To: rchrdsn@protonmail.ch\n"
"POT-Creation-Date: 2020-03-15 19:18+0300\n"
"POT-Creation-Date: 2020-04-12 21:55+0300\n"
"PO-Revision-Date: 2019-02-24 04:46+0300\n"
"Last-Translator: alfred richardsn <rchrdsn@protonmail.ch>\n"
"Language: ru\n"
Expand Down Expand Up @@ -308,14 +308,14 @@ msgstr "Отправьте сумму заказа в {currency}."
msgid "choose_sum_currency_with_buttons"
msgstr "Выберите валюту суммы кнопками."

#: src/handlers/creation.py
msgid "cashless_payment_system"
msgstr "Отправьте систему безналичной оплаты."

#: src/handlers/creation.py
msgid "ask_location"
msgstr "Отправьте локацию предпочитаемого места встречи для наличной оплаты."

#: src/handlers/creation.py
msgid "cashless_payment_system"
msgstr "Отправьте систему безналичной оплаты."

#: src/handlers/creation.py
msgid "location_not_found"
msgstr "Локация не найдена."
Expand Down Expand Up @@ -680,6 +680,10 @@ msgstr "Ваш запрос отменён."
msgid "support_response_promise"
msgstr "Ваше сообщение переслано. Мы ответим вам в течение 24 часов."

#: src/handlers/support.py
msgid "reply_error_bot_blocked"
msgstr "Не удалось отправить ответ, я заблокирован у пользователя."

#: src/handlers/support.py
msgid "reply_sent"
msgstr "Ответ отправлен."
Expand Down Expand Up @@ -715,3 +719,4 @@ msgstr "Срок действия вашего заказа истёк."
#: src/whitelist.py
msgid "without_gateway"
msgstr "Без шлюза"

17 changes: 11 additions & 6 deletions src/handlers/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from aiogram.dispatcher import FSMContext
from aiogram.utils import markdown
from aiogram.utils.emoji import emojize
from aiogram.utils.exceptions import BotBlocked

from src.bot import dp
from src.config import config
Expand Down Expand Up @@ -100,12 +101,16 @@ async def answer_support_ticket(message: types.Message):
chat_id = int(args[1].split("_")[1])
reply_to_message_id = int(args[2])

await tg.send_message(
chat_id,
emojize(":speech_balloon:") + message.text,
reply_to_message_id=reply_to_message_id,
)
await tg.send_message(message.chat.id, i18n("reply_sent"))
try:
await tg.send_message(
chat_id,
emojize(":speech_balloon:") + message.text,
reply_to_message_id=reply_to_message_id,
)
except BotBlocked:
await tg.send_message(message.chat.id, i18n("reply_error_bot_blocked"))
else:
await tg.send_message(message.chat.id, i18n("reply_sent"))


@dp.message_handler(
Expand Down

0 comments on commit 53d2394

Please sign in to comment.