Telegram Bot, v1.10
Posted on

Telegram channel bot.
Support sending of photo albums.
Change Log
- publication into a specified channel:
- sending of photo albums:
- ignore duplicate photos:
- detect duplicates by their canonical paths;
- support a photo caption:
- support the markup specifying:
- allowed markups:
Markdown;MarkdownV2;HTML;
- allowed markups:
- support emojis (with aliases).
- support the markup specifying:
- ignore duplicate photos:
- sending of photo albums:
Features
- publication into a specified channel:
- sending of text messages:
- support the markup specifying:
- allowed markups:
Markdown;MarkdownV2;HTML;
- allowed markups:
- support emojis (with aliases);
- support the markup specifying:
- sending of photo messages:
- support a photo caption:
- support the markup specifying:
- allowed markups:
Markdown;MarkdownV2;HTML;
- allowed markups:
- support emojis (with aliases);
- support the markup specifying:
- support a photo caption:
- sending of photo albums:
- ignore duplicate photos:
- detect duplicates by their canonical paths;
- support a photo caption:
- support the markup specifying:
- allowed markups:
Markdown;MarkdownV2;HTML;
- allowed markups:
- support emojis (with aliases);
- support the markup specifying:
- ignore duplicate photos:
- 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;
- total 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 [-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.10.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:
deprecated: true
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
/photos:
post:
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
files:
type: array
items:
$ref: "#/components/schemas/nonemptyString"
minItems: 1
maxItems: 10
text:
type: string
format:
$ref: "#/components/schemas/formatEnum"
required:
- file
encoding:
files:
style: form
explode: true
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.10.
Content: code.
License: GPL-3.0-or-later.
Screenshots
Usage of the utility

POST /photos

Copyrights
- road photo 1 — Pixabay License, Copyright © 2013 Larisa-K, https://pixabay.com/en/road-asphalt-space-sky-clouds-220058/;
- road photo 2 — Pixabay License, Copyright © 2014 dawnfu, https://pixabay.com/en/road-distance-landscape-horizon-348544/;
- road photo 3 — Pixabay License, Copyright © 2014 Unsplash, https://pixabay.com/en/street-road-straight-horizon-381227/.