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

@@ -0,0 +1,48 @@
# JoinRequestQueriesBot
A long-polling example for processing chat join-request queries as a chat's guard bot.
## Behavior
At startup, the bot calls `getMe` and prints its bot information and
`supportsJoinRequestQueries` value. For every chat join request it prints the
requesting user, chat, bio, query ID, and the chat's configured guard bot.
Only requests containing a query ID are processed. Without a Web App URL, the bot:
- answers with `Queue` when the user's bio is missing or blank, leaving the
decision to other administrators;
- answers with `Approve` when the user has a nonblank bio.
When an HTTPS Web App URL is supplied, the bot sends that Web App for verification
instead of answering the query. Requests without a query ID are only logged. Every
received update is printed to standard output, and the bot defines no commands.
## Setup and permissions
1. Create a bot, obtain its token, and keep the token private.
2. Configure the bot as the guard bot of the chat whose requests it should handle.
3. Grant it the administrator permission to invite users (`can_invite_users`).
4. If using the Web App flow, provide an HTTPS verification URL.
The example uses long polling and does not configure a webhook. Be aware that its
default flow automatically approves query-backed requests with a nonblank bio.
## Run
From the repository root:
```bash
./gradlew :JoinRequestQueriesBot:run --args="BOT_TOKEN"
```
The first argument is the required bot token. An optional Web App URL is recognized
only as the second argument and must begin with `https://`. The case-sensitive flags
`debug` and `testServer` enable formatted logging and Telegram's test environment;
they may follow the token and Web App URL.
For example:
```bash
./gradlew :JoinRequestQueriesBot:run --args="BOT_TOKEN https://example.com/verify debug"
```

View File

@@ -14,24 +14,13 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
/**
* This bot demonstrates Join Request Queries support introduced in Telegram Bot API 10.1.
* Starts the long-polling join-request-query example.
*
* A "guard bot" of a chat receives chat join requests as queries and must process them with
* [answerChatJoinRequestQuery] or hand the user a Web App via [sendChatJoinRequestWebApp]
* (for example, to run a captcha / verification flow before deciding).
*
* Your bot must be set as the guard bot of the chat and must have `can_invite_users` rights to
* receive these requests.
*
* Key concepts demonstrated:
* - [dev.inmo.tgbotapi.types.chat.ExtendedBot.supportsJoinRequestQueries] — whether the bot itself
* supports join request queries (from getMe(), maps `User.supports_join_request_queries`)
* - [dev.inmo.tgbotapi.types.chat.ExtendedChat.guardBot] — the bot that processes join request
* queries in a chat (from getChat(), maps `ChatFullInfo.guard_bot`)
* - [dev.inmo.tgbotapi.types.chat.ChatJoinRequest.queryId] — the [dev.inmo.tgbotapi.types.ChatJoinRequestQueryId]
* present when the request arrives as a query to the guard bot
* - [answerChatJoinRequestQuery] with [ChatJoinRequestQueryResult] (Approve / Decline / Queue / Unknown)
* - [sendChatJoinRequestWebApp] — open a Web App to process the request
* The first element of [args] must be the bot token. When the second element is an
* `https://` URL, query-backed requests are handed to that Web App. Otherwise, the
* bot queues requests with a blank bio and approves those with a nonblank bio.
* The optional exact values `debug` and `testServer` enable diagnostic logging and
* Telegram's test environment, respectively.
*/
suspend fun main(vararg args: String) {
val botToken = args.first()