Skip to content

Commit d742a58

Browse files
committed
english readme
1 parent ef340af commit d742a58

File tree

1 file changed

+98
-72
lines changed

1 file changed

+98
-72
lines changed

README_EN.md

Lines changed: 98 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ Use the [CharDisplay] library(https://github.com/GyverLibs/CharDisplay) to displ
2323
ESP8266 (SDK v2.6+), ESP32
2424

2525
## Documentation and projects
26-
Detailed tutorials on working with the Telegram bot using this library can be found on the [GyverKIT Arduino website] (https://kit.alexgyver.ru/tutorials-category/telegram/)
26+
Detailed tutorials on working with the Telegram bot using this library can be found on the [GyverKIT Arduino site] (https://kit.alexgyver.ru/tutorials-category/telegram/)
2727

2828
## Comparison with Universal-Arduino-Telegram-Bot
2929
[Universal-Arduino-Telegram-Bot](https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot)
3030

31-
For comparison, we used a minimal example with sending a message to the chat and outputting incoming messages to the series:
31+
For comparison, a minimal example was used with sending a message to the chat and outputting incoming messages to the series:
3232
- **send** - send a message to the chat
3333
- **update** - check incoming messages
3434
- **free heap** - amount of free RAM while the program is running
@@ -39,8 +39,12 @@ For comparison, we used a minimal example with sending a message to the chat and
3939
| fastbot | 393220 | 28036 | 70 | 70 | 37552 |
4040
| diff | 6784 | 1812 | 1930 | 1830 | 1040 |
4141

42-
- FastBot is lighter by almost 7 kB of Flash and 2 kB of SRAM, but takes up 1 kB of SRAM more while the program is running. Total lighter by 2-1 = 1 kB of SRAM.
42+
- FastBot is almost 7kB lighter than Flash and 2kB SRAM, but takes up 1kB more SRAM while the program is running. Total lighter by 2-1 = 1 kB of SRAM.
4343
- FastBot processes chat and sends messages much faster (by 2 seconds) due to manual parsing of the server response and statically allocated HTTP clients
44+
- The test was carried out in the normal mode of operation of FastBot. When `FB_DYNAMIC` is activated, the library will take 10kb less memory, but it will work slower:
45+
- Free heap: 48000 kB
46+
- Sending a message: 1 second
47+
- Update request: 1 second
4448

4549
## Content
4650
- [Install](#install)
@@ -68,17 +72,22 @@ For comparison, we used a minimal example with sending a message to the chat and
6872
- [Bugs and feedback](#feedback)
6973

7074
<a id="install"></a>
71-
## Installation
75+
## Installedcranberry vka
7276
- The library can be found by the name **FastBot** and installed through the library manager in:
7377
- Arduino IDE
7478
- Arduino IDE v2
7579
- PlatformIO
7680
- [Download library](https://github.com/GyverLibs/FastBot/archive/refs/heads/main.zip) .zip archive for manual installation:
7781
- Unzip and put in *C:\Program Files (x86)\Arduino\libraries* (Windows x64)
78-
- Unpack and putin *C:\Program Files\Arduino\libraries* (Windows x32)
82+
- Unzip and put in *C:\Program Files\Arduino\libraries* (Windows x32)
7983
- Unpack and put in *Documents/Arduino/libraries/*
8084
- (Arduino IDE) automatic installation from .zip: *Sketch/Include library/Add .ZIP library…* and specify the downloaded archive
8185
- Read more detailed instructions for installing libraries [here] (https://alexgyver.ru/arduino-first/#%D0%A3%D1%81%D1%82%D0%B0%D0%BD%D0%BE% D0%B2%D0%BA%D0%B0_%D0%B1%D0%B8%D0%B1%D0%BB%D0%B8%D0%BE%D1%82%D0%B5%D0%BA)
86+
### Update
87+
- I recommend always updating the library: new versions fix errors and bugs, as well as optimize and add new features
88+
- Through the IDE library manager: find the library as during installation and click "Update"
89+
- Manually: **delete the folder with the old version**, and then put the new one in its place. "Replacement" cannot be done: sometimes new versions delete files that remain after replacement and can lead to errors!
90+
8291

8392
<a id="init"></a>
8493
## Initialization
@@ -157,7 +166,7 @@ uint8_t closeMenu();
157166
uint8_t closeMenu(String id);
158167
159168
160-
// ======== REGULAR MENU WITH TEXTOM =========
169+
// ======== REGULAR MENU WITH TEXT =========
161170
// message (msg) + show menu (menu) in the chat/chats specified in setChatID OR pass the id of the chat/chats
162171
uint8_t showMenuText(String msg, String menu);
163172
uint8_t showMenuText(String msg, String menu, String id);
@@ -227,7 +236,7 @@ int32_t lastBotMsg(); // ID of the last message sent by the bot
227236
int32_t lastUsrMsg(); // ID of the last message sent by the user
228237
String chatIDs; // the string specified in setChatID, for debugging and editing the list
229238
230-
uint8_t sendRequest(String&req); // send request (https://api.telegram.org/bot...)
239+
uint8_t sendRequest(String&req); // send request(https://api.telegram.org/bot...)
231240
void autoIncrement(boolean incr); // auto increment messages (enabled by default)
232241
void incrementID(uint8_tval); // manually increment ID by val
233242
@@ -245,7 +254,8 @@ bool& edited; // message edited
245254
bool isBot; // message from bot
246255
bool OTA; // request for OTA update
247256
uint32_t unix; // message time
248-
String toString(); // all information in one line
257+
String&fileName; // File name
258+
String&replyText; // response text, if any
249259
250260
251261
// ================ TIME =================
@@ -290,6 +300,7 @@ String FB_64str(int64_t id); // transfer from int64_t to String
290300
#define FB_NO_UNICODE // disable Unicode conversion for incoming messages (slightly speed up the program)
291301
#define FB_NO_URLENCODE // disable urlencode conversion for outgoing messages (slightly speeds up the program)
292302
#define FB_NO_OTA // disable support for OTA updates from chat
303+
#define FB_DYNAMIC // enable dynamic mode: the library takes longer to execute the request, but takes up 10 kb less memory in SRAM
293304
```
294305

295306
<a id="usage"></a>
@@ -318,64 +329,67 @@ bot.sendMessage("Hello!", "112233"); // will go to "112233"
318329
Telegram sets the following limits on **sending** messages by the bot ([documentation](https://core.telegram.org/bots/faq#my-bot-is-hitting-limits-how-do-i-avoid-this ))
319330
- To chat: no more than once per second. *You can send more often, but the message may not reach*
320331
- To a group: no more than 20 messages per minute
321-
- Total limit: no more than 30 messages per second
332+
- Total limit: no more than 30 messages per secondКлюква ду
322333

323-
The bot can also read messages that are less than 24 hours old.
334+
Также бот может читать сообщения, с момента отправки которых прошло меньше 24 часов.
324335

325336
<a id="inbox"></a>
326-
## Message parsing
327-
Messages are automatically requested and read in `tick()`, when a new message arrives, the specified handler function is called:
328-
- Create our own function in the sketch like `void function(FB_msg& message)`
329-
- Call `attach(function)`
330-
- This function will be automatically called on an incoming message if the chat ID matches or is not configured
331-
- If the handler is not connected - messages will not be checked
332-
- Inside this function, you can use the passed variable `message`, which has the type `FB_msg` (structure) and contains:
333-
- `String userID` - user ID
334-
- `String username` - user or channel name
335-
- `String chatID` - chat ID
336-
- `int32_t messageID` - message ID in the chat
337-
- `String text` - message text or file caption
338-
- `String data` - callback data from the menu (if any)- `bool query` - query
339-
- `bool edited` - message has been edited
340-
- `bool isBot` - message from bot
341-
- `bool OTA` - request for OTA update (received .bin file)
342-
- `uint32_t unix` - message time
343-
- `String fileName` - file name
344-
- `String toString()` - all information from the message, convenient for debugging (since 2.11)
345-
346-
**Notes:**
347-
- Telegram splits the text into several messages if the text length exceeds ~4000 characters! These messages will have a different messageID in the chat.
348-
- When replying to a message, the library parses the text of the original message, not the answer
349-
350-
### White list
351-
The library implements a white list mechanism: you can specify in `setChatID()` the ID of a chat (or several, separated by commas), messages from which will be accepted.
352-
Messages from other chats will be ignored.
337+
## Парсинг сообщений
338+
Сообщения автоматически запрашиваются и читаются в `tick()`, при поступлении нового сообщения вызывается указанная функция-обработчик:
339+
- Создаём в скетче свою функцию вида `void функция(FB_msg& сообщение)`
340+
- Вызываем `attach(функция)`
341+
- Эта функция будет автоматически вызвана при входящем сообщении, если ID чата совпадает или не настроен
342+
- Если обработчик не подключен - сообщения не будут проверяться
343+
- Внутри этой функции можно пользоваться переданной переменной `сообщение`, которая имеет тип `FB_msg` (структура) и содержит в себе:
344+
- `String userID` - ID пользователя
345+
- `String username` - имя пользователя или канала
346+
- `String chatID` - ID чата
347+
- `int32_t messageID` - ID сообщения в чате
348+
- `String text` - текст сообщения или попдпись к файлу
349+
- `String replyText` - текст ответа, если он есть
350+
- `String data` - callback данные из меню (если есть)
351+
- `bool query` - запрос
352+
- `bool edited` - сообщение отредактировано
353+
- `bool isBot` - сообщение от бота
354+
- `bool OTA` - запрос на OTA обновление (получен .bin файл)
355+
- `uint32_t unix` - время сообщения
356+
- `String fileName` - имя файла
357+
358+
А также `String toString()` - вся информация из сообщения, удобно для отладки (с версии 2.11)
359+
360+
**Примечания:**
361+
- Телеграм разделяет текст на несколько сообщений, если длина текста превышает ~4000 символов! Эти сообщения будут иметь разный messageID в чате.
362+
- При ответе на сообщение библиотека парсит текст исходного сообщения, а не ответа
363+
364+
### Белый список
365+
В библиотеке реализован механизм белого списка: можно указать в `setChatID()` ID чата (или нескольких через запятую), сообщения из которого будут приниматься.
366+
Сообщения из остальных чатов будут игнорироваться.
353367

354368
<a id="tick"></a>
355-
## Ticker
356-
To poll incoming messages, you need to connect a message handler and call `tick()` in the main loop of the program `loop()`, polling occurs according to the built-in timer.
357-
By default, the polling period is set to 3600 milliseconds.
369+
## Тикер
370+
Для опроса входящих сообщений нужно подключить обработчик сообщений и вызывать `tick()` в главном цикле программы `loop()`, опрос происходит по встроенному таймеру.
371+
По умолчанию период опроса установлен 3600 миллисекунд.
358372

359-
You can poll more often (change the period via `setPeriod()`), but personally, since ~ 2021, the Telegram server has not responded
360-
sooner than ~3 seconds later. If you request updates more often than this period, the program hangs inside a `tick()` (inside a GET request)
361-
waiting for the server response for the remainder of 3 seconds. With a period of ~3600 ms this does not happen, so I made it the default.
362-
Maybe it depends on the provider or the country.
373+
Можно опрашивать чаще (сменить период через `setPeriod()`), но лично у меня с ~2021 года сервер Телеграм стал отвечать не
374+
раньше, чем через ~3 секунды. Если запрашивать обновления чаще этого периода, программа зависает внутри `tick()` (внутри GET запроса)
375+
в ожидании ответа сервера на остаток от 3 секунд. При периоде ~3600 мс этого не происходит, поэтому я сделал его по умолчанию.
376+
Возможно это зависит от провайдера или страны.
363377

364378
<a id="example"></a>
365-
## Minimal example
379+
## Минимальный пример
366380
```cpp
367381
void setup() {
368-
// connect to WiFi
369-
bot.attach(newMsg); // connect the message handler
382+
// подключаемся к WiFi
383+
bot.attach(newMsg); // подключаем обработчик сообщений
370384
}
371385

372386
void newMsg(FB_msg& msg) {
373-
// display the username and message text
387+
// выводим имя юзера и текст сообщения
374388
//Serial.print(msg.username);
375389
//Serial.print(", ");
376390
//Serial.println(msg.text);
377391

378-
// output all information about the message
392+
// выводим всю информацию о сообщении
379393
Serial.println(msg.toString());
380394
}
381395

@@ -385,29 +399,29 @@ void loop() {
385399
```
386400
387401
<a id="msgid"></a>
388-
## Accessing messages
389-
To edit and delete messages and menus, as well as pin messages, you need to know the message ID (its number in the chat):
390-
- ID of the incoming message is sent to the incoming message handler
391-
- Last received message ID can be obtained from `lastUsrMsg()`
392-
- The ID of the last message sent by the bot can be obtained from `lastBotMsg()`
402+
## Обращение к сообщениям
403+
Для редактирования и удаления сообщений и меню, а также закрепления сообщений, нужно знать ID сообщения (его номер в чате):
404+
- ID входящего сообщения приходит в обработчик входящих сообщений
405+
- ID последнего принятого сообщения можно получить из `lastUsrMsg()`
406+
- ID последнего отправленного ботом сообщения можно получить из `lastBotMsg()`
393407
394-
Be careful with the chat ID, all chats have their own message numbering!
408+
Будьте внимательны с ID чата, у всех чатов своя нумерация сообщений!
395409
396410
<a id="sticker"></a>
397-
## Send stickers
398-
To send a sticker, you need to know the sticker ID. Send the desired sticker to the *@idstickerbot* bot, it will send the sticker ID.
399-
This ID must be passed to the `sendSticker()` function.
411+
## Отправка стикеров
412+
Для отправки стикера нужно знать ID стикера. Отправь нужный стикер боту *@idstickerbot*, он пришлёт ID стикера.
413+
Этот ID нужно передать в функцию `sendSticker()`.
400414
401415
<a id="menu"></a>
402-
## Menu
403-
> Note: for all menu options *not produced* url encode. Avoid the `#` and `&` characters, or use an already encoded url!
416+
## Меню
417+
> Примечание: для всех вариантов меню *не производится* url encode. Избегайте символов `#` и `&` или используйте уже закодированный url!
404418
405-
To send the menu, a string with button names and special formatting is used:
406-
- `\t` - horizontal separation of buttons
407-
- `\n` - vertical separation of buttons
408-
- Extra spaces are cut automatically
419+
Для отправки меню используется строка с именами кнопок и специальным форматированием:
420+
- `\t` - горизонтальное разделение кнопок
421+
- `\n` - вертикальное разделение кнопок
422+
- Лишние пробелы вырезаются автоматически
409423
410-
3x1 menu example: `"Menu1 \t Menu2 \t Menu3 \n Menu4"`
424+
Пример меню 3x1: `"Menu1 \t Menu2 \t Menu3 \n Menu4"`
411425
412426
Result:
413427
```cpp
@@ -442,7 +456,7 @@ Menu in the message. Allows you to set a unique text for each button, which will
442456
The list of callbacks is listed separated by commas in the order of the menu buttons:
443457
```cpp
444458
String menu1 = F("Menu 1 \t Menu 2 \t Menu 3 \n Back");
445-
String cback1 = F("action1,acaction2,action3,back");
459+
String cback1 = F("action1,action2,action3,back");
446460
bot.inlineMenuCallback("Menu 1", menu1, cback1);
447461
```
448462
Clicking the button sends the menu name (the `text` message field) and the specified data (the `data` message field).
@@ -522,8 +536,8 @@ library and **count continues on** using standard time functions. Thus, it is en
522536
message after the board is turned on, so that the library synchronizes the clock. The time will also be synchronized on further sendings.
523537
and to be specified, because the time calculated by means of esp will go away (~ 2 seconds per day). Tools:
524538
525-
- `uint32_t getUnix()` - returns the current time in unix format, or `0` if the time is out of sync.
526-
- `bool timeSynced()` - will return `true` if the clock is synchronized.
539+
- `uint32_t getUnix()` - returns the current time in unix format or `0` if the time is out of sync.
540+
- `booltimeSynced()` - will return `true` if clocks are synchronized.
527541
- `FB_Time getTime(gmt)` - you need to pass your time zone, it will return `FB_Time`.
528542
529543
Thus, there are two ways to get the time (see the timeTest example):
@@ -546,7 +560,7 @@ Since version 2.13 of the library, a firmware update has appeared "over the air"
546560
- After a successful update, the esp will reboot
547561

548562
```cpp
549-
// update if justsent bin file
563+
// update if just sent a bin file
550564
if (msg.OTA) bot.update();
551565

552566
// update if the file has the desired signature
@@ -630,7 +644,7 @@ void loop() {
630644
- v2.1:
631645
- More optimization
632646
- Added text formatting (markdown, html)
633-
- Added a reply to the message
647+
-Added a reply to a post
634648

635649
- v2.2:
636650
- Big memory and performance optimizations
@@ -650,7 +664,7 @@ void loop() {
650664
- Callback data is now parsed separately in data
651665
- Redesigned work with callback
652666
- Added toString() for FB_msg for debugging
653-
- Processing added to callbackcranberry url addresses
667+
- Added processing of url addresses in callback
654668
- Removed first_name and last_name (preserving legacy)
655669
- usrID and ID renamed to userID and messageID (preserving legacy)
656670
- Completely removed the old incoming message handler
@@ -660,8 +674,20 @@ void loop() {
660674
- v2.14: Improved ID string parsing, added OTA disable, added group/channel name parsing to username
661675
- v2.15: ESP32 library curve patch
662676
- v2.16: added fileName output, fixed unsent messages in Markdown mode
677+
- v2.17: displaying the text of the message to which the user replied + correct work with menu in groups
678+
- v2.17.1: minor fix https://github.com/GyverLibs/FastBot/issues/12
679+
- v2.18: added FB_DYNAMIC mode: the library takes longer to execute a request, but takes up 10 kb less memory in SRAM
663680

664681
<a id="feedback"></a>
665682
## Bugs and feedback
666683
When you find bugs, create an **Issue**, or better, immediately write to the mail [alex@alexgyver.ru](mailto:alex@alexgyver.ru)
667-
The library is open for revision and your **Pull Request**'s!
684+
The library is open for revision and your **Pull Request**'s!
685+
686+
When reporting bugs or incorrect work of the library, it is necessary to indicate:
687+
- Library version
688+
- What MK is used
689+
- SDK version (for ESP)
690+
- Arduino IDE version
691+
- Whether built-in examples work correctly, which use functions and constructs that lead to a bug in your code
692+
- What code was loaded, what work was expected from it and how it works in reality
693+
- Ideally, attach the minimum code in which the bug is observed. Not a canvas of a thousand lines, but a minimal code

0 commit comments

Comments
 (0)