telepingbot/README.md

70 lines
2 KiB
Markdown
Raw Normal View History

<div align="center"
2023-11-18 17:46:32 +01:00
# TelePingBot
A simple API to ping telegram bots and returns if it's online or not. using superbot to send message to the bots (mtproto).
[![Forgejo CI Status](https://git.4rs.nl/awiteb/telepingbot/badges/workflows/ci.yml/badge.svg)](https://git.4rs.nl/awiteb/telepingbot)
[![Forgejo CD Status](https://git.4rs.nl/awiteb/telepingbot/badges/workflows/cd.yml/badge.svg)](https://git.4rs.nl/awiteb/telepingbot)
2023-11-18 17:46:32 +01:00
[![agplv3-or-later](https://www.gnu.org/graphics/agplv3-88x31.png)](https://www.gnu.org/licenses/agpl-3.0.html)
2023-11-18 17:46:32 +01:00
</div>
2023-11-18 17:46:32 +01:00
## Why is simple?
Add your API tokens (`Authorization` header) and your bot usernames in the `config.toml` file, and you're ready to go.
2023-11-18 17:46:32 +01:00
> [!NOTE]
> Check out the `config.toml.example` file to see how to fill the `config.toml` file.
> [!WARNING]
> Remember to keep the `config.toml` file safe, because anyone can use it to ping your bots.
2023-11-18 17:46:32 +01:00
## CLI Arguments
- `--config`: The path to the config file. (default: `config.toml`)
2023-11-18 17:46:32 +01:00
## Requirements
- Rust (MSRV 1.75.0)
2023-11-18 17:46:32 +01:00
- Cargo
## Build
```bash
cargo build --release
```
## Run
```bash
cargo run --release
```
Or just run the binary file in `target/release/telepingbot`
2023-11-18 17:46:32 +01:00
## Endpoints
### `/ping/@<bot_username>`
This endpoint is to ping the bot and returns if it's online or not.
#### Url querys
- "cmd": One word base64Url encoded, will use it as a command, default is `start`
- "args": Base64Url encoded, will use it as arguments for the command, default is `""`
2023-11-18 17:46:32 +01:00
#### Headers
- `Authorization`: The API access token. e.g: `Authorization: FirstToken`
#### Response
- `200`: The bot is online.
- `404`: The bot is offline.
- `401`: The API access token is invalid.
- `500`: Internal server error. e.g: The bot username is invalid or the superbot can't send message to the bot.
#### Example
> [!NOTE]
>
> Replace `FirstToken` with your API access token and `@testbot` with your bot username
> and the host and port with your host and port.
```bash
curl -v 0.0.0.0:3939/ping/@testbot -H "Authorization: FirstToken"
```