Telegram Bot, v1.8
Posted on

Telegram channel bot.
Support a photo caption and support the markup specifying for text and photo messages.
Change Log
- publication into a specified channel:
- sending of text messages:
- support the markup specifying:
- allowed markups:
Markdown;MarkdownV2;HTML;
- allowed markups:
- support the markup specifying:
- sending of photo messages:
- support a photo caption:
- support the markup specifying:
- allowed markups:
Markdown;MarkdownV2;HTML;
- allowed markups:
- support the markup specifying:
- support a photo caption:
- sending of text messages:
- perform the refactoring:
- add the
server.RequestHandlerclass;
- add the
- add the documentation:
- add the Postman collection.
Features
- publication into a specified channel:
- sending of text messages:
- support the markup specifying:
- allowed markups:
Markdown;MarkdownV2;HTML;
- allowed markups:
- support the markup specifying:
- sending of photo messages:
- support a photo caption:
- support the markup specifying:
- allowed markups:
Markdown;MarkdownV2;HTML;
- allowed markups:
- support the markup specifying:
- support a photo caption:
- sending of text messages:
- voting for messages (optional):
- restrictions (via a remembering in an SQLite database):
- one vote per one user;
- possibility change an own vote (optionally, i.e. may be disabled);
- decor:
- voting by an inline keyboard;
- reverse of a buttons order (optionally);
- customizable a buttons text via individual templates;
- displaying of a voting result on buttons instead placeholders:
- number of votes;
- percent of votes;
- support emojis (with aliases) in a buttons text;
- restrictions (via a remembering in an SQLite database):
- working mode:
- run as a web service;
- control via the RESTful API;
- utility for a sending of requests to the API:
- making of a path to a photo absolute.
Usage of the Utility for a Sending of Requests to the API
$ ./tools/sender.bash -h
$ ./tools/sender.bash [-H HOST] [-P PORT] [-m MARKUP] -t TEXT
$ ./tools/sender.bash [-H HOST] [-P PORT] [-t TEXT] [-m MARKUP] -f PATH
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;-m MARKUP— set a message text markup (allowed:Markdown,MarkdownV2, andHTML);-f PATH— set a path to a message photo.
API
API description in the Swagger format:
openapi: "3.0.0"
info:
title: telegram-bot
version: 1.8.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:
$ref: "#/components/schemas/nonemptyString"
format:
$ref: "#/components/schemas/formatEnum"
required:
- text
responses:
200:
description: OK
400:
description: Bad Request
500:
description: Internal Server Error
/photo:
post:
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
file:
$ref: "#/components/schemas/nonemptyString"
text:
type: string
format:
$ref: "#/components/schemas/formatEnum"
required:
- file
responses:
200:
description: OK
400:
description: Bad Request
500:
description: Internal Server Error
components:
schemas:
nonemptyString:
type: string
pattern: ^(?!\s*$)[\s\S]+
formatEnum:
type: string
enum:
- Markdown
- MarkdownV2
- HTML
Repository
Link: https://github.com/thewizardplusplus/telegram-bot/tree/v1.8.
Content: code.
License: GPL-3.0-or-later.
Screenshots
Usage of the utility

POST /message

POST /photo

Copyrights
- road photo — Pixabay License, Copyright © 2013 Larisa-K, https://pixabay.com/en/road-asphalt-space-sky-clouds-220058/.