Telegram Bot, v1.0
Posted on

Telegram channel bot.
Major release.
Features
- publication into a specified channel:
- sending of text messages;
- working mode:
- run as a web service;
- control via the RESTful API;
- utility for a sending of requests to the API.
Installation
Clone this repository:
$ git clone https://github.com/thewizardplusplus/telegram-bot.git
$ cd telegram-bot
Then install the utility with pip tool:
$ sudo -H python3 -m pip install .
sudo command is required to install telegram-bot console script. If it's not required, sudo command can be omitted:
$ python3 -m pip install .
But then the utility should be started as python3 -m telegram_bot.
Usage
$ telegram-bot -v | --version
$ telegram-bot -h | --help
$ telegram-bot
Options:
-v,--version— show the version message and exit;-h,--help— show this help message and exit.
Environment variables:
TELEGRAM_BOT_TOKEN— Telegram API access token;TELEGRAM_BOT_CHANNEL— Telegram channel name;TELEGRAM_BOT_PORT— bot API port (default:4000).
Environment variables can be specified in a .env config in the format:
NAME_1=value_1
NAME_2=value_2
...
See details about the format: https://github.com/motdotla/dotenv#rules.
A .env config will never modify any environment variables that have already been set.
Usage of the Utility for a Sending of Requests to the API
$ ./tools/sender.bash -h
$ ./tools/sender.bash [-H HOST] [-P PORT] -t TEXT
Options:
-h— show this help message;-H HOST— set a host name (default:localhost);-P PORT— set a port number (default:4000);-t TEXT— set a message text.
API
API description in the Swagger format:
openapi: '3.0.0'
info:
title: telegram-bot
version: 1.0.0
servers:
- url: http://localhost:{port}/api/v1
variables:
port:
default: '4000'
paths:
/message:
post:
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
text:
type: string
pattern: \S+
required:
- text
responses:
200:
description: OK
400:
description: Bad Request
500:
description: Internal Server Error
Repository
Link: https://github.com/thewizardplusplus/telegram-bot/tree/v1.0.
Content: code.
License: GPL-3.0-or-later.
Screenshots
Run of the web service

Usage of the utility

POST /message
