mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2026-08-29 04:16:27 +00:00
update readmes
This commit is contained in:
@@ -1,9 +1,39 @@
|
||||
# SlotMachineDetectorBot
|
||||
|
||||
This bot must reply with information about slot machine answer
|
||||
A long-polling example that distinguishes slot-machine dice from other Telegram
|
||||
dice animations and decodes the slot reels.
|
||||
|
||||
## Launch
|
||||
## Trigger and output
|
||||
|
||||
The bot handles every dice message and defines no commands.
|
||||
|
||||
- For a slot-machine dice, it calls `calculateSlotMachineResult` and replies in the
|
||||
exact format `<left-reel>|<center-reel>|<right-reel>`.
|
||||
- If a slot-machine value cannot be decoded, the handler sends no reply.
|
||||
- For every other dice animation, it replies
|
||||
`There is no slot machine dice in message`.
|
||||
|
||||
The example reports the three decoded reels only. It does not calculate a numeric
|
||||
score or decide whether the combination wins.
|
||||
|
||||
## Setup, permissions, and privacy
|
||||
|
||||
1. Create a bot, obtain its token, and keep the token private.
|
||||
2. Start a private chat with it, or add it to a group where dice should be observed.
|
||||
3. Allow the bot to send replies in that chat.
|
||||
|
||||
Dice are ordinary non-command messages. In groups, configure Telegram's bot privacy
|
||||
setting so the desired dice updates are delivered; disable privacy mode if the bot
|
||||
should inspect all group dice. No administrator-only API methods are used. The bot
|
||||
stores no message or dice data.
|
||||
|
||||
## Run
|
||||
|
||||
From the repository root:
|
||||
|
||||
```bash
|
||||
../gradlew run --args="BOT_TOKEN"
|
||||
./gradlew :SlotMachineDetectorBot:run --args="BOT_TOKEN"
|
||||
```
|
||||
|
||||
The first argument is the required bot token. Omitting it causes startup to fail;
|
||||
additional arguments are ignored. This launcher has no debug or test-server flag.
|
||||
|
||||
@@ -6,6 +6,13 @@ import dev.inmo.tgbotapi.extensions.utils.*
|
||||
import dev.inmo.tgbotapi.types.dice.SlotMachineDiceAnimationType
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
/**
|
||||
* Starts the long-polling slot-machine detector.
|
||||
*
|
||||
* [args] must contain the bot token first; later elements are ignored. Slot-machine
|
||||
* dice receive a pipe-separated three-reel reply, while other dice receive an
|
||||
* explanatory reply. An undecodable slot-machine result is silently ignored.
|
||||
*/
|
||||
suspend fun main(args: Array<String>) {
|
||||
val bot = telegramBot(args.first())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user