Notification Service

async bot.handlers.notifications.service.check_new_analyses(bot)[source]

Background task to check for new analyses and send instant notifications.

Parameters:

bot (Bot) – Aiogram bot instance.

Return type:

None

Returns:

None.

async bot.handlers.notifications.service.get_target_chat_id(user_id)[source]

Return group chat ID if configured, otherwise personal user ID.

Parameters:

user_id (int) – Telegram user identifier.

Return type:

int

Returns:

The target chat ID for notifications.

async bot.handlers.notifications.service.process_completed_task(bot, task)[source]

Process a completed task and send appropriate notifications.

Parameters:
  • bot (Bot) – Aiogram bot instance.

  • task (Any) – Database task model (completed state) with payload.

Return type:

None

Returns:

None.

async bot.handlers.notifications.service.send_analysis_report(bot, user_id, analysis_id)[source]

Send a structured Telegram report for a particular analysis to the target chat.

Parameters:
  • bot (Bot) – Aiogram bot instance.

  • user_id (int) – Telegram user identifier.

  • analysis_id (int) – Identifier of the analysis to render and deliver.

Return type:

None

Returns:

None.

async bot.handlers.notifications.service.send_message_to_target_chat(bot, chat_id, text, user_id=None)[source]

Send a message to a chat. Fallback to personal chat if group send fails.

Parameters:
  • bot (Bot) – Aiogram bot instance.

  • chat_id (int) – Target chat id (group or user).

  • text (str) – Message text (Telegram HTML allowed).

  • user_id (int | None) – Optional user id for fallback delivery.

Return type:

None

Returns:

None.

async bot.handlers.notifications.service.simplify_for_layperson(text)[source]

Return a simplified plain-text version of a notification.

Parameters:

text (str) – Input facts block.

Return type:

str

Returns:

Simplified text without markup, friendly to non-technical readers.