Implementing Plugin Hooks

The Delta Chat Python bindings use pluggy for managing global and per-account plugin registration, and performing hook calls. There are two kinds of plugins:

  • Global plugins that are active for all accounts; they can implement hooks at account-creation and account-shutdown time.

  • Account plugins that are only active during the lifetime of a single Account instance.

Registering a plugin

deltachat.register_global_plugin(plugin)[source]

Register a global plugin which implements one or more of the deltachat.hookspec.Global hooks.

Account.add_account_plugin(plugin, name=None)[source]

add an account plugin which implements one or more of the deltachat.hookspec.PerAccount hooks.

Per-Account Hook specifications

class deltachat.hookspec.PerAccount[source]

per-Account-instance hook specifications.

All hooks are executed in a dedicated Event thread. Hooks are generally not allowed to block/last long as this blocks overall event processing on the python side.

ac_process_ffi_event(ffi_event)[source]

process a CFFI low level events for a given account.

ffi_event has “name”, “data1”, “data2” values as specified with DC_EVENT_*.

ac_log_line(message)[source]

log a message related to the account.

ac_configure_completed(success)[source]

Called after a configure process completed.

ac_incoming_message(message)[source]

Called on any incoming message (to deaddrop or chat).

ac_outgoing_message(message)[source]

Called on each outgoing message (both system and “normal”).

ac_message_delivered(message)[source]

Called when an outgoing message has been delivered to SMTP.

Parameters

message – Message that was just delivered.

ac_chat_modified(chat)[source]

Chat was created or modified regarding membership, avatar, title.

Parameters

chat – Chat which was modified.

ac_member_added(chat, contact, actor, message)[source]

Called for each contact added to an accepted chat.

Parameters
  • chat – Chat where contact was added.

  • contact – Contact that was added.

  • actor – Who added the contact (None if it was our self-addr)

  • message – The original system message that reports the addition.

ac_member_removed(chat, contact, actor, message)[source]

Called for each contact removed from a chat.

Parameters
  • chat – Chat where contact was removed.

  • contact – Contact that was removed.

  • actor – Who removed the contact (None if it was our self-addr)

  • message – The original system message that reports the removal.

Global Hook specifications

class deltachat.hookspec.Global[source]

global hook specifications using a per-process singleton plugin manager instance.

dc_account_init(account)[source]

called when Account::__init__() function starts executing.

dc_account_extra_configure(account)[source]

Called when account configuration successfully finished.

This hook can be used to perform extra work before ac_configure_completed is called.

dc_account_after_shutdown(account)[source]

Called after the account has been shutdown.