update readmes

This commit is contained in:
2026-08-21 15:51:06 +06:00
parent 016400a821
commit ce48393895
104 changed files with 2615 additions and 333 deletions

View File

@@ -1,9 +1,45 @@
# GetMeBot
# MyBot
This is one of the most easiest bot - it will just print information about itself
A long-polling example that prints information about the bot and lets Telegram users replace or remove its global profile photo.
## Behavior
At startup, the application prints the results of `getMe` and `getChat` for the bot itself to standard output. It then handles two commands:
- `/setMyProfilePhoto` replies with `ok, send me new photo` and waits for the first photo sent in the same chat. It streams draft progress messages while downloading the photo to a temporary file, uploads it as a static bot profile photo, and replies when the change is complete. The photo may come from any user in that chat; it is not restricted to the user who sent the command.
- `/removeMyProfilePhoto` removes the bot's current profile photo and confirms success. On failure, it prints the exception and sends a generic error reply.
There is no `/start` handler, and ordinary messages are ignored unless the bot is waiting for a photo after `/setMyProfilePhoto`.
## Setup and permissions
- Create a bot with [@BotFather](https://t.me/BotFather) and obtain its token.
- No chat-administrator permission is required to change the bot's own profile photo. In a group, the bot still needs permission to send replies.
- Prefer using this example in a private chat. Telegram's draft-message API is intended for private chats, and BotFather privacy mode can prevent an unrelated group photo from reaching the bot unless it is sent as a reply or privacy mode is disabled.
- This example performs no authorization checks: anyone who can reach the commands can change or remove the bot's profile photo globally. Do not expose a production bot without adding access control.
- Long polling automatically removes an existing webhook at startup. Run only one update consumer for the token at a time.
## Arguments
The first argument is always the required bot token. Optional arguments can follow it in any order:
- `debug` enables formatted default KSLog output.
- `testServer` makes the behavior and long-polling client use Telegram's Bot API test environment. The initial `getMe` and `getChat` diagnostics currently use a separate default-server client.
Other arguments are ignored. Argument matching is case-sensitive.
## Launch
The intended command from the repository root is:
```bash
../gradlew run --args="BOT_TOKEN"
./gradlew :MyBot:run --args="<BOT_TOKEN>"
```
For example, to enable both optional modes:
```bash
./gradlew :MyBot:run --args="<BOT_TOKEN> debug testServer"
```
> **Known issue:** `MyBot/build.gradle` still declares the old `GetMeBotKt` main class, while the current source produces `MyBotKt`. Consequently, the `run` task cannot start until that build setting is corrected. It is left unchanged here because this example update is documentation-only.

View File

@@ -26,7 +26,13 @@ import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.first
/**
* This is one of the easiest bots - it will just print information about itself
* Runs the MyBot profile-photo example using long polling.
*
* Startup bot information is printed to standard output. The bot then handles commands that replace its profile
* photo from the next photo received in the same chat or remove its current profile photo.
*
* @param args the bot token first, followed optionally by `debug` for formatted KSLog output and/or `testServer` for
* the Telegram Bot API test environment
*/
suspend fun main(vararg args: String) {
val botToken = args.first()