Skip to content

Commit

Permalink
fix(helpdesk): better exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
vas3k committed Jun 16, 2024
1 parent 6f89597 commit 5caf76c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
35 changes: 21 additions & 14 deletions helpdeskbot/handlers/question.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,21 +252,24 @@ def publish_question(update: Update, user_data: Dict[str, str]) -> str:
question.save()

if room and room.chat_id:
room_message = send_message(
chat_id=room.chat_id,
text=render_html_message(
"helpdeskbot_question_in_room.html",
question=data,
room=room,
user=user,
telegram_user=update.effective_user,
channel_message_link=get_channel_message_link(channel_message.message_id),
try:
room_message = send_message(
chat_id=room.chat_id,
text=render_html_message(
"helpdeskbot_question_in_room.html",
question=data,
room=room,
user=user,
telegram_user=update.effective_user,
channel_message_link=get_channel_message_link(channel_message.message_id),
)
)
)

question.room = room
question.room_chat_msg_id = room_message.message_id
question.save()
question.room = room
question.room_chat_msg_id = room_message.message_id
question.save()
except Exception as ex:
log.warning(f"Failed to send message to room: {data.room}. Pls add bot there.", exc_info=ex)

return get_channel_message_link(channel_message.message_id)

Expand Down Expand Up @@ -297,7 +300,11 @@ def finish_review(update: Update, context: CallbackContext) -> State:
return edit_question(update, context)

else:
raise Exception(f"😱 Неожиданная команда. Можем начать заново - /start")
send_reply(
update,
f"😱 Неожиданная команда. Можем начать заново - /start",
reply_markup=start_markup
)


def fallback(update: Update, context: CallbackContext) -> State:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
💬 <b>Новый <a href="https://t.me/c/{{ reply_chat_id }}/{{ reply_msg_id }}">ответ</a> на вопрос «{{ question.json_text.title }}»</b> от <a href="tg://user?id={{ from_user.id }}">{{ from_user.first_name }}</a>:
💬 <b>Новый <a href="https://t.me/c/{{ reply_chat_id }}/{{ reply_msg_id }}">ответ</a> на ваш вопрос «{{ question.json_text.title }}»</b> от <a href="tg://user?id={{ from_user.id }}">{{ from_user.first_name }}</a>:

{{ text }}

Expand Down

0 comments on commit 5caf76c

Please sign in to comment.