44 lines
1.4 KiB
Markdown
44 lines
1.4 KiB
Markdown
# telewarder
|
|
|
|
## Installation
|
|
|
|
First build the image with `docker-compose build`.
|
|
|
|
Set up environment variables in `.env` file, get them from https://my.telegram.org/apps. Copy `.env.example` and modify it.
|
|
|
|
Once built, run once: `docker run -it --env-file .env -v $PWD/data:/data telewarder python3 /app/app.py`, it will ask for your phone number (use country code, like `+34666123456`), enter it and follow instructions. When finished, quit with `CTRL+c`. You should now see `telewarder.session` and `telewarder.session-journal` files under `data` folder.
|
|
|
|
You're now all set up.
|
|
|
|
## Run
|
|
|
|
Execute `docker-compose up -d`
|
|
|
|
The app will be listening to messages sent to the user only (it won't listen to messages sent to groups where the user is), and make a HTTP POST query to the `URL` server in the `/sendmessage` endpoint, it will send the data as follows:
|
|
|
|
```
|
|
{
|
|
"chat_id": 123456789,
|
|
"message_id": 987654321,
|
|
"message": "Hello, world!"
|
|
}
|
|
```
|
|
|
|
The app will also query the `URL` in the `/readmessages` endpoint every few seconds, this should have a response with the following format:
|
|
|
|
```
|
|
[
|
|
{
|
|
"chat_id": 123456789,
|
|
"message_id": 987654321,
|
|
"message": "Hello, world!"
|
|
},
|
|
{
|
|
"chat_id": 987654321,
|
|
"message_id": 123456789,
|
|
"message": "This is a test message."
|
|
}
|
|
]
|
|
```
|
|
|
|
It will go through every message and send the text as a reply to each one, the data should be the same that the app sent before. |