INNER CODE UNIT · Python
terminate
thevickypedia/Jarvis · jarvis/api/background_task/bot.py:65
async def terminate(reason: str) -> None:
"""Terminate telegram polling.
Args:
reason: Reason for termination.
"""
logger.info("Terminating telegram polling due to %s", reason)
telegram_beat.poll_for_messages = False
telegram_beat.restart_loop = False
async def telegram_executor() -> None:
"""Poll for new Telegram messages.
Handles:
- BotWebhookConflict: Handles dead webhook connection and restarts loop.
- BotInUse: Conflicting bot usage on webhook vs long polling.
- BotTokenInvalid: Handles invalid auth token by terminating session.