Types for events in deltachat_rpc_client

Hi I’m trying to write a bot with deltachat_rpc_client. However, I’ve run into an issue where I have no idea what I can and can’t call on each event. Is there a list of types for each type of event? Mainly I’m looking for help with adding members

@hooks.on(events.MemberListChanged) def on_memberlist_changed(event): if event.member_added: pass

I would like to know if I can send a message similar to events.NewMessage? I have not been able to find examples of the types with deltachat_rpc_client.With deltabot_cli I am unable to find out how I can listen for when a member was added, if the later is possible I would prefer that

1 Like

Currently the best starting point for JSON-RPC documentation is https://jsonrpc.delta.chat/
You can see all event types at EventType | @deltachat/jsonrpc-client, it is a typescript documentation but the structure of events is the same.
Alternatively, look at the Rust source from which these types are generated:
core/deltachat-jsonrpc/src/api/types/events.rs at main · chatmail/core · GitHub

2 Likes

Is there a list if functions I can call? For example this is a snippet from the echo bot example.

@hooks.on(events.NewMessage)
def echo(event):
    snapshot = event.message_snapshot
    snapshot.chat.send_text(snapshot.text)

Can one call chat.send_text on all events? Sorry if these are silly questions, the documentation is a little lacking

message_snapshot is added here, by the Bot/Client implementation:

This is indeed not well documented what this Bot/Client wrapping does. Raw event itself does not have message_snapshot. Event has chat_id and msg_id properties. When you have a chat_id and you have Account object, you can call Account.get_chat_by_id to get a Chat object (that is just a lightweight wrapper for chat ID and account ID) and from there call Chat.send_text.

I would suggest using

as the starting point, it has less abstraction layers (like hooks) and a simple event loop where you get raw events. Hooks look nice but will need some feedback from users and better documentation to make them work and not do what you don’t want them to do, e.g. you may sometimes not want to load the messages from some chat and hook implementation always loads the message snapshot for you currently.

Thank you, just to confirm there aren’t any types/library stubs for deltachat_rpc_client right?