mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
refine example doc and address https://github.com/deltachat/deltachat-core-rust/pull/1307#pullrequestreview-380876587
This commit is contained in:
@@ -1,34 +1,39 @@
|
||||
|
||||
# content of group_tracking.py
|
||||
|
||||
import deltachat
|
||||
from deltachat import account_hookimpl, run_cmdline
|
||||
|
||||
|
||||
class GroupTrackingPlugin:
|
||||
@deltachat.hookspec.account_hookimpl
|
||||
@account_hookimpl
|
||||
def process_incoming_message(self, message):
|
||||
print("*** process_incoming_message addr={} msg={!r}".format(
|
||||
message.get_sender_contact().addr, message.text))
|
||||
for member in message.chat.get_contacts():
|
||||
print("chat member: {}".format(member.addr))
|
||||
print("process_incoming message", message)
|
||||
if message.text.strip() == "/quit":
|
||||
message.account.shutdown()
|
||||
else:
|
||||
# unconditionally accept the chat
|
||||
message.accept_sender_contact()
|
||||
addr = message.get_sender_contact().addr
|
||||
text = message.text
|
||||
message.chat.send_text("echoing from {}:\n{}".format(addr, text))
|
||||
|
||||
@deltachat.hookspec.account_hookimpl
|
||||
@account_hookimpl
|
||||
def configure_completed(self, success):
|
||||
print("*** configure_completed:", success)
|
||||
|
||||
@deltachat.hookspec.account_hookimpl
|
||||
@account_hookimpl
|
||||
def member_added(self, chat, contact):
|
||||
print("*** member_added", contact.addr, "from", chat)
|
||||
for member in chat.get_contacts():
|
||||
print("chat member: {}".format(member.addr))
|
||||
|
||||
@deltachat.hookspec.account_hookimpl
|
||||
@account_hookimpl
|
||||
def member_removed(self, chat, contact):
|
||||
print("*** member_removed", contact.addr, "from", chat)
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
deltachat.run_cmdline(argv=argv, account_plugins=[GroupTrackingPlugin()])
|
||||
run_cmdline(argv=argv, account_plugins=[GroupTrackingPlugin()])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user