diff --git a/engine/apps/telegram/tasks.py b/engine/apps/telegram/tasks.py index d6596581..9f6cfd97 100644 --- a/engine/apps/telegram/tasks.py +++ b/engine/apps/telegram/tasks.py @@ -136,20 +136,30 @@ def send_log_and_actions_message(self, channel_chat_id, group_chat_id, channel_m with OkToRetry( task=self, exc=(error.RetryAfter, error.TimedOut), compute_countdown=lambda e: getattr(e, "retry_after", 3) ): - if not log_message_sent: - telegram_client.send_message( - chat_id=group_chat_id, - message_type=TelegramMessage.LOG_MESSAGE, - alert_group=alert_group, - reply_to_message_id=reply_to_message_id, - ) - if not actions_message_sent: - telegram_client.send_message( - chat_id=group_chat_id, - message_type=TelegramMessage.ACTIONS_MESSAGE, - alert_group=alert_group, - reply_to_message_id=reply_to_message_id, - ) + try: + if not log_message_sent: + telegram_client.send_message( + chat_id=group_chat_id, + message_type=TelegramMessage.LOG_MESSAGE, + alert_group=alert_group, + reply_to_message_id=reply_to_message_id, + ) + if not actions_message_sent: + telegram_client.send_message( + chat_id=group_chat_id, + message_type=TelegramMessage.ACTIONS_MESSAGE, + alert_group=alert_group, + reply_to_message_id=reply_to_message_id, + ) + except error.BadRequest as e: + if e.message == "Chat not found": + logger.warning( + f"Could not send log and actions messages to Telegram group with id {group_chat_id} " + f"due to 'Chat not found'. alert_group {alert_group.pk}" + ) + return + else: + raise @shared_dedicated_queue_retry_task( diff --git a/engine/apps/telegram/updates/update_handlers/verification/personal.py b/engine/apps/telegram/updates/update_handlers/verification/personal.py index 13e2a3e8..6f17603f 100644 --- a/engine/apps/telegram/updates/update_handlers/verification/personal.py +++ b/engine/apps/telegram/updates/update_handlers/verification/personal.py @@ -4,7 +4,7 @@ from apps.telegram.updates.update_handlers import UpdateHandler from apps.telegram.utils import is_verification_message USER_CONNECTED_TEXT = "Done! This Telegram account is now linked to {username} 🎉" -RELINK_ACCOUNT_TEXT = """This user is already connected to a Telegram account +RELINK_ACCOUNT_TEXT = """This user is already connected to a Telegram account. Please unlink Telegram account in profile settings of user {username} or contact Grafana OnCall support.""" WRONG_VERIFICATION_CODE = "Verification failed: wrong verification code"