An open API service indexing awesome lists of open source software.

https://github.com/qiwi/watch_bot

a bot that watches the API method and sends messages to the Telegram if the data has changed
https://github.com/qiwi/watch_bot

Last synced: 5 days ago
JSON representation

a bot that watches the API method and sends messages to the Telegram if the data has changed

Awesome Lists containing this project

README

        

# watch_bot
Telegram bot that can eventually fetch data from user endpoint and send info about fetched data.

## Bot commands

![](https://github.com/qiwi/watch_bot/blob/master/bot_message_example.png?raw=true)

### /auth \
Gives access to non-public commands (such as ``/start``).

### /start \
Starts eventually sending GET requests to , processing response and printing info to subscribed user.
Requests will include Authorization header (see config structure for credentials).

Response structure should be like:

```
{
"result": {
"message": "Your message",
"entities": [
{
"meta": {
"key": "value",
"anotherKey": 123
}
},
...
]
}
```

### /check \
Sends 1 GET request to provided , processing response and printing info to subscribed user.
Request will include Authorization header.


### /stop
Stops sending requests.

## Usage

1. Clone this repo.
```
git clone [email protected]:qiwi/watch_bot.git
```
2. Make your own config in ``config/default.json`` or ``config/default.js``

```
{
"general": {
"defaultCronTime": "*/10 * * * * *", // polling cron time
"botTGToken": "*", // bot telegram token - talk to @BotFather at telegram to get it
"numVerboseErrors": 20 // bot will stop printing error message after numVerboseErrors errors in fetching data
"defaultWatchUrl": "https://test" // default watch url for /start and /check commands
},
"auth": {
"method": "JWT", // Authorization header value:
"token": "*" // Authorization header value:
},
"logger": {
"logLevel": "debug"
},
"botAuth": {
"token": "SomeTest" // see /auth command,
"allowedChats": [1111, 2222] // whitelisted chats list (optional)
},
"backupFolder": "./" // folder for backuping active chats data
}
```

3. ``npm install``

4. ``npm run build``

5. ``node app``

## Docker
TODO