- Python 100%
| .gitignore | ||
| bot.py | ||
| CHANGELOG.md | ||
| LICENSE | ||
| README.md | ||
| set_external_email.py | ||
This is a fork of Meshdelta bot (Meshdelta is a WIP Meshtastic<->Delta Chat bridge).
This fork, unlike the original bot, is not intended for group to group communication (the original bot maps a mesh channel to a group chat that it is added to). Instead, it is intended as a tool that allows communication via mesh to DeltaChat with pre-selected contacts without requiring internet connection. Therefore, the configuration differs from the original. For now, architecturally it is not the same as a bot in a classic sense. It assumes the bot user and the bot admin are the same entity - and it can be used with a newly created account or with an already existing one.
How it works:
"Client": phone with Meshtastic app installed + LoRa module connected to it via Bluetooth, no internet required "Server": bot connected to the same account running on a machine connected to the internet
Setup
Client (LoRa module configuration) requirements:
- Pair the LoRa module to the phone via Bluetooth
- Configure the client LoRa module to enable MQTT and use the same MQTT broker as the server, as well as same meshtastic chanel (the channel name and the key must be the same as in mqtt.conf for server, see below).
You can configure it either via the Meshtastic app, or via Meshtastic Python cli (to install meshtastic python cli, run
pip3 install --upgrade "meshtastic[cli]")
Bot server requirements:
-
Install python (version >= 3.13 is required)and create a virtual environment if you don’t have one already and activate it:
python -m venv venv && . venv/bin/activate -
Install meshage - A python module for sending Meshtastic messages via MQTT
pip install meshage -
Install deltachat-rpc-client - RPC client connects to standalone Delta Chat RPC server deltachat-rpc-server and provides Python interface to it.
pip install deltachat-rpc-client
Bot configuration:
- Configure MQTT broker:
- You can use either a pubic MQTT broker or run your own (e.g., mosquitto).
- If you want to set up your own MQTT broker, it needs to run on the same local network to which an entry-point LoRa module is connected.
- Create mqtt.conf and specify your values:
[mqtt]
host=mqtt.meshtastic.org # MQTT broker to serve as the bridge the Meshtastic and the bot - a public one (used here) or a locally hosted one
port=8883 # 8883 for TLS, 1883 for unencrypted
username=meshdev # if using your own MQTT broker, this can be left empty
password=large4cats # if using your own MQTT broker, this can be left empty
root_topic=msh/US # change to msh/EU_868 for EU
userid=<random 32-bit int user id> # it becomes the bot's node ID on the mesh>
admin_email=admin@example.com # ChatMail / Email address that the bot is connected to - because the only user is the bot admin in our use case
# In the keys section, specify the meshtastic channel name and its PSK encryption key, like *channel name*=*channel key*
# Instead of using an existing channel, you might want to create your own. You can create a channel either via Meshtastic's app (Settings > Channels), or through meshtastic Python CLI
[keys]
longfast=1PG7OiApB1nwvP+rz05pAQ== # The default Meshtastic public channel
# In the chats section, specify the DeltaChat chat ID and the channel you want to connect it to, like *chat id*=*channel name*. You need a separate channel for each chat.
# The chat ID needs to be fetched by the account that the bot is connected to by receiving a message with "/bridge" command from the desired chat recipient.
[chats]
13=longfast # this example mathes the chat with ID 13 to the longfast channel
- Configure an account for the bot:
- The bot must be conected to an existing email or chatmail account. For that it needs to have an
accountsdirectory in the same place as bot.py. You can create either a new account or use an existing one, depending on your preference: - If you want to use it with an existing email from an external email provider, you simply can create a fresh email address and connect it with DeltaChat RPC Client. Run
python set_external_email.py *youremail@examp.le* *password*. Don't use an account that you use elsewhere. - If you want to use it with an existing account from a chatmail relay, you need to copy the desired account's accounts/ directory from the Delta Chat client app. For example if you have installed DeltaChat's Linux client it would be: ~/.var/app/chat.delta.desktop/config/DeltaChat/
- Launch bot with
python bot.py.
- For the first time, you can launch it with empty chats section in config to get the first chat ID via /bridge command, then add the fetched ID(s) to the mqtt.conf and restart the bot.
Admin Commands
You can configure an admin_email in mqtt.conf to enable the bot administrator to manage backup mail transports (relays) via Delta Chat:
/transports— Show configured mail relays./addtransport <user@example.com> <password123>— Add a backup mail relay./rmtransport <user@example.com>— Remove a mail relay./setprimary <user@example.com>— Set a specific transport as primary.
The bot automatically retries failed messages using backup transports with an exponential backoff.