Event Dispatcher

The class that Handles Event dispatching in fbchat-muqit library.

class fbchat_muqit.EventDispatcher

Bases: object

__init__(*args, **kwargs) None
add_listener(event_type: EventType, callback: Callable[[...], Awaitable[None]]) None

Add an event listener for a specific event.

Parameters:
  • event_type (EventType) – The type of the event you want to add listener for.

  • callback (EventCallback) – The listener function you want to add. Note, that the function must be async.

async on_admin_added(event_data: AdminAdded, message: MessageData)

Called when an admin is added to a messenger group.

Parameters:
  • event_data (AdminsAdded) – Receives a AdminsAdded object contains added admin id.

  • message (MessageData) – A MessageData object contains the message information meta data.

async on_admin_removed(event_data: AdminRemoved)

Called when an admin is removed from admin role.

Parameters:

event_data (AdminRemoved) – Receives a AdminRemoved object.

async on_approval_mode_change(event_data: ApprovalMode)

Called when Approval mode is changed in a group.

Parameters:

event_data (ApprovalMode) – Receives a ApprovalMode object.

async on_approval_queue(event_data: ApprovalQueue)

Called when an user requests to join a group or invited by another participant of the group or disapproved a User’s join request but approved join request information is not received.

Parameters:

event_data (ApprovalQueue) – Receives a ApprovalQueue object.

async on_emoji_change(event_data: ThreadEmoji, message: MessageData)

Called when a thread’s quick reaction emoji is changed.

Parameters:

event_data (UpdatedThreadEmoji) – Receives a UpdatedThreadEmoji object.

async on_friend_request_change(event_data: FriendRequestState)

Called when a friend request is confirmed/rejected or a friend request is sent by the Client.

Parameters:

event_data (FriendRequestState) – Receives a FriendRequestState object.

async on_listening()

Called when the client starts listening to events

async on_magic_words_change(event_data: ThreadMagicWord, message: MessageData)

Called when Magic words are added or removed in a group

Parameters:
  • event_data (UpdatedMagicWords) – Receives a UpdatedMagicWords object.

  • message (MessageData) – A MessageData object with message data.

async on_mark_read(event_data: MarkRead)

Called when client marks a thread as read

Parameters:

event_data (MarkRead) – Receives a MarkRead object with read information.

async on_mark_unread(event_data: MarkUnread)

Called when client marks a thread as unread

Parameters:

event_data (MarkUnread) – Receives a MarkUnread object with read information.

async on_message(event_data: Message)

Called when a message received in messenger

Parameters:

event_data (Message) – A Message object contains the message information.

async on_message_delivered(event_data: DeliveryReceipt)

Called when a message is successfully delivered to a thread.

Parameters:

event_data (DeliveryReceipt) – Receives a DeliveryReceipt object with delivery information.

async on_message_pinned(event_data: ThreadMessagePin, message: MessageData)

Called when a message gets pinned in a thread

Parameters:
  • event_data (ThreadMessagePin) – Receives a ThreadMessagePin object.

  • message (MessageData) – A MessageData object with message data.

async on_message_reaction(event_data: MessageReaction)

Called when an user reacts to a message

Parameters:

event_data (MessageReaction) – Receives a MessageReaction object.

async on_message_removed(event_data: MessageRemove)

Called when the client removes a message for only itself :param event_data: A MessageRemove with additional information. :type event_data: MessageRemove

async on_message_seen(event_data: ReadReceipt)

Called when message is seen by an User.

Parameters:

event_data (ReadReceipt) – Receives a ReadReceipt object.

async on_message_sharing_change(event_data: ThreadMessageSharing, message: MessageData)

Called when message sharing permission is changed in a thread.

Parameters:
  • event_data (ThreadMessageSharing) – Receives a ThreadMessageSharing object.

  • message (MessageData) – Receives a MessageData object with extra message info.

async on_message_unpinned(event_data: ThreadMessageUnPin, message: MessageData)

Called when a message gets unpinned in a thread

Parameters:
async on_message_unsent(event_data: MessageUnsend)

Called when a message is unsent by a User.

Parameters:

event_data (MessageUnsend) – A MessageUnsend object with the unsent message information.

async on_nickname_change(event_data: ThreadNickname, message: MessageData)

Called when a User’s nickname is changed in a thread.

Parameters:

event_data (ThreadNickname) – Receives a ThreadNickname object with user nickname change info.

async on_page_notification(event_data: PageNotification)

Called when a message is sent to a page that Client created.

Parameters:

event_data (PageNotification) – Receives a PageNotification object.

async on_participant_joined(event_data: ParticipantsAdded)

Called when an user joins a messenger group/community

Parameters:

event_data (ParticipantsAdded) – Receives a ParticipantsAdded object.

async on_participant_left(event_data: ParticipantLeft)

Called when an user leaves or removed from a messenger group/community

Parameters:

event_data (ParticipantLeft) – Receives a ParticipantLeft object.

async on_poke_nofification(event_data: PokeNotification)

Called when a user pokes the Client.

Parameters:

event_data (PokeNotification) – Receives a PokeNotification object.

async on_theme_change(event_data: ThreadTheme, message: MessageData)

Called when a thread’s theme is changed.

Parameters:
  • event_data (ThreadTheme) – Receives a ThreadTheme object.

  • message (MessageData) – A MessageData object with message information.

async on_thread_action(event_data: ThreadAction)

Called when client moves a Thread to archive/inbox.

Parameters:

event_data (ThreadAction) – Receives a ThreadAction object.

async on_thread_delete(event_data: ThreadDelete)

Called when client deletes a Thread.

Parameters:

event_data (ThreadDelete) – Receives a ThreadDelete object.

async on_thread_mute(event_data: MuteThread)

Called when the client mutes a thread community/group.

Parameters:

event_data (MuteThread) – Receives a MuteThread object.

async on_thread_mute_settings(event_data: ThreadMuteSettings)

Called when the client mutes a Thread.

Parameters:

event_data (ThreadMuteSettings) – Receives a ThreadMuteSettings object.

async on_thread_name_change(event_data: ThreadName)

Called when a thread’s name is changed

Parameters:

event_data (UpdatedThreadName) – Receives a UpdatedThreadName object.

async on_typing(event_data: Typing)

Called When someone starts/stops typing

Parameters:

event_data (Typing) – Receives a Typing object.

async on_viewer_status_change(event_data: ChangeViwerStatus)

Called when a Thread gets blocked on Facebook/Messenger

Parameters:

event_data (ChangeViwerStatus) – Receives a ChangeViwerStatus object.

remove_listener(event_type: EventType, callback: Callable[[...], Awaitable[None]]) bool

Remove an event listener for a specific event.

Parameters:
  • event_type (EventType) – The type of the event you want to remove listener for.

  • callback (EventCallback) – The listener function you want to remove.