File size: 1,723 Bytes
0220cd3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Examples
========

Once you have :doc:`installed deltachat bindings <install>`
you need email/password credentials for an IMAP/SMTP account.
Delta Chat developers and the CI system use a special URL to create
temporary email accounts on `testrun.org <https://testrun.org/>`_ for testing.

Receiving a Chat message from the command line
----------------------------------------------

Here is a simple bot that:

- receives a message and sends back ("echoes") a message

- terminates the bot if the message `/quit` is sent

.. include:: ../../examples/echo_and_quit.py
    :literal:

With this file in your working directory you can run the bot
by specifying a database path, an email address and password of
a SMTP-IMAP account::

    $ cd examples
    $ python echo_and_quit.py /tmp/db --email ADDRESS --password PASSWORD

While this process is running you can start sending chat messages
to `ADDRESS`.

Track member additions and removals in a group
----------------------------------------------

Here is a simple bot that:

- echoes messages sent to it

- tracks if configuration completed

- tracks member additions and removals for all chat groups

.. include:: ../../examples/group_tracking.py
    :literal:

With this file in your working directory you can run the bot
by specifying a database path, an email address and password of
a SMTP-IMAP account::

    python group_tracking.py --email ADDRESS --password PASSWORD /tmp/db

When this process is running you can start sending chat messages
to `ADDRESS`.

Writing bots for real
-------------------------

The `deltabot repository <https://github.com/deltachat/deltabot#deltachat-example-bot>`_
contains a little framework for writing deltachat bots in Python.