mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2026-08-29 04:16:27 +00:00
1.2 KiB
1.2 KiB
GiveawaysBot
A long-polling example that prints giveaway-related Telegram updates to standard output.
Behavior
At startup, the bot calls getMe and prints its own user information. It then prints
updates matched by these TelegramBotAPI handlers:
onGiveawayCreated— a giveaway was created;onGiveawayCompleted— a giveaway was completed;onGiveawayWinners— the giveaway winners were published;onGiveawayContent— a message contains giveaway content.
The bot sends no replies and defines no bot commands.
Setup and permissions
- Obtain a bot token and keep it private.
- Add the bot to every chat whose giveaway updates it should observe, with enough access for Telegram to deliver those updates.
The example does not call admin-only methods, store data, or configure a webhook.
Run
From the repository root:
./gradlew :GiveawaysBot:run --args="BOT_TOKEN"
The first argument is always the required bot token. Optional, case-sensitive flags may follow it in either order:
debugenables TelegramBotAPI diagnostic logging on standard output;testServerconnects to Telegram's Bot API test environment.
For example:
./gradlew :GiveawaysBot:run --args="BOT_TOKEN debug testServer"