mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2026-08-28 11:56:25 +00:00
update readmes
This commit is contained in:
@@ -1,9 +1,47 @@
|
||||
# ReactionsInfoBot
|
||||
# LinkPreviewsBot
|
||||
|
||||
This bot will resend messages with links with all variants of `LinkPreviewOptions`
|
||||
A long-polling example that resends text-bearing content with every demonstrated
|
||||
`LinkPreviewOptions` variant.
|
||||
|
||||
## Launch
|
||||
## Behavior
|
||||
|
||||
The bot handles every content message. It searches the message's text entities for
|
||||
the first plain URL or text-link entity. When one is found, it sends the same text
|
||||
and entities to the same chat seven times:
|
||||
|
||||
- with link previews disabled;
|
||||
- with a large preview above the text;
|
||||
- with a large preview below the text;
|
||||
- with a small preview above the text;
|
||||
- with a small preview below the text;
|
||||
- with Telegram's default preview size above the text;
|
||||
- with Telegram's default preview size below the text.
|
||||
|
||||
The detected URL is selected explicitly for each enabled preview. If the content is
|
||||
not text-bearing or contains no URL entity, the bot replies that only content with
|
||||
a URL is supported. It defines and registers no commands.
|
||||
|
||||
## Setup and permissions
|
||||
|
||||
1. Create a bot, obtain its token, and keep the token private.
|
||||
2. Start a private chat with it, or add it to a chat where previews should be tested.
|
||||
3. Ensure Telegram delivers the relevant content messages and the bot may send
|
||||
messages in that chat.
|
||||
|
||||
The example uses no administrator-only methods and does not configure a webhook.
|
||||
|
||||
## Run
|
||||
|
||||
From the repository root:
|
||||
|
||||
```bash
|
||||
../gradlew run --args="BOT_TOKEN"
|
||||
./gradlew :LinkPreviewsBot:run --args="BOT_TOKEN"
|
||||
```
|
||||
|
||||
The first argument is the required bot token. The optional, case-sensitive second
|
||||
argument `debug` enables formatted library logging on standard output. Arguments
|
||||
after the second are ignored.
|
||||
|
||||
```bash
|
||||
./gradlew :LinkPreviewsBot:run --args="BOT_TOKEN debug"
|
||||
```
|
||||
|
||||
@@ -15,7 +15,12 @@ import dev.inmo.tgbotapi.types.message.content.TextedContent
|
||||
import dev.inmo.tgbotapi.utils.regular
|
||||
|
||||
/**
|
||||
* This bot will reply with the same
|
||||
* Starts a long-polling bot that demonstrates link-preview layouts.
|
||||
*
|
||||
* The first element of [args] must be the bot token. An optional exact `debug`
|
||||
* value in the second position enables diagnostic logging. For each text-bearing
|
||||
* content message, the bot uses its first URL entity to send one disabled-preview
|
||||
* copy and large, small, and default previews both above and below the text.
|
||||
*/
|
||||
suspend fun main(vararg args: String) {
|
||||
val botToken = args.first()
|
||||
|
||||
Reference in New Issue
Block a user