Replicas Handler

class telegram_bot_discussion.handlers.replicas_handler.replicas_handler.ReplicasHandler[source]

Bases: object

async access_control_list(user_id, replica_class)[source]
Return type:

bool

Parameters:
  • user_id (int)

  • replica_class (Type[Replica])

async middleware(update, context)[source]

Middleware work within handle(). If it returns None, handle() will not work.

Return type:

Optional[Tuple[Update, CallbackContext]]

Parameters:
  • update (Update)

  • context (CallbackContext)

async when_there_are_no_any_dialog(update, context)[source]

Do something if Telegram-bot does not have any dialogue with initiator (often - the User).

Return type:

Optional[Tuple[Update, CallbackContext]]

Parameters:
  • update (Update)

  • context (CallbackContext)

async handle(update, context)[source]

Catch all events, which are not commands calls and buttons clicks.

Raises:

ChatIdWasNotFetched – If User was not detected, handle() try find other event initiator. If event initiator not found ChatIdWasNotFetched will be raised.

Parameters:
  • update (Update)

  • context (CallbackContext)

async get_replica_from_dialogue(update, context)[source]
Parameters:
  • update (Update)

  • context (CallbackContext)

async start_dialogue(update, context, with_user_id, dialogue)[source]
Parameters:
  • update (Update)

  • context (CallbackContext)

  • with_user_id (int)

  • dialogue (Dialogue)

stop_dialogue(context, with_user_id)[source]
Parameters:
  • context (CallbackContext)

  • with_user_id (int)

Replicas handler exceptions

exception telegram_bot_discussion.handlers.replicas_handler.exceptions.access_deny.ReplicaClassAccessDeny(user_id, replica_class)[source]

Bases: Exception

Parameters:
  • user_id (int)

  • replica_class (Type[Replica])

user_id: int
replica_class: Type[Replica]