mirror of
https://github.com/chatmail/core.git
synced 2026-04-05 23:22:11 +03:00
add a test echo_and_quit examples
This commit is contained in:
@@ -4,52 +4,33 @@ examples
|
||||
========
|
||||
|
||||
|
||||
Sending a Chat message from the command line
|
||||
---------------------------------------------
|
||||
|
||||
Once you have :doc:`installed deltachat bindings <install>`
|
||||
you can start playing from the python interpreter commandline.
|
||||
For example you can type ``python`` and then::
|
||||
|
||||
# instantiate and configure deltachat account
|
||||
import deltachat
|
||||
ac = deltachat.Account("/tmp/db")
|
||||
ac.set_config("addr", "address@example.org")
|
||||
ac.set_config("mail_pwd", "some password")
|
||||
|
||||
# start IO threads and perform configuration
|
||||
ac.start()
|
||||
|
||||
# create a contact and send a message
|
||||
contact = ac.create_contact("someother@email.address")
|
||||
chat = ac.create_chat_by_contact(contact)
|
||||
chat.send_text("hi from the python interpreter command line")
|
||||
|
||||
# shutdown IO threads
|
||||
ac.shutdown()
|
||||
|
||||
|
||||
Checkout our :doc:`api` for the various high-level things you can do
|
||||
to send/receive messages, create contacts and chats.
|
||||
|
||||
|
||||
Receiving a Chat message from the command line
|
||||
----------------------------------------------
|
||||
|
||||
Instantiate an account and register a plugin to process
|
||||
incoming messages:
|
||||
Once you have :doc:`installed deltachat bindings <install>`
|
||||
you can start playing from the python interpreter commandline.
|
||||
|
||||
Here is a simple module that implements a bot that:
|
||||
|
||||
- receives a message and sends back an "echo" message
|
||||
|
||||
- terminates the bot if the message `/quit` is sent
|
||||
|
||||
.. include:: ../examples/echo_and_quit.py
|
||||
:literal:
|
||||
|
||||
Checkout our :doc:`api` for the various high-level things you can do
|
||||
to send/receive messages, create contacts and chats.
|
||||
With this file in your working directory you can run the bot
|
||||
by specifying a database path, an e-mail address and password of
|
||||
a SMTP-IMAP account::
|
||||
|
||||
python echo_and_quit.py --db /tmp/db --email ADDRESS --password PASSWORD
|
||||
|
||||
Looking at a real example
|
||||
While 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 real-life example of Python bindings usage.
|
||||
|
||||
contains a little framework for writing deltachat bots in Python.
|
||||
|
||||
|
||||
@@ -17,8 +17,10 @@ Registering a plugin
|
||||
--------------------
|
||||
|
||||
.. autofunction:: deltachat.register_global_plugin
|
||||
:noindex:
|
||||
|
||||
.. automethod:: deltachat.account.Account.add_account_plugin
|
||||
:noindex:
|
||||
|
||||
|
||||
Per-Account Hook specifications
|
||||
|
||||
Reference in New Issue
Block a user