Telegram Bot example
This repository contains an example of telegram bot written in Java (17 and above)
Current version supports the following commands:
Configuration is supplied through Environment Variables:
EXAMPLE_TG_BOT_TOKEN=123455:abcd.. # The token from BotFather
EXAMPLE_TG_BOT_ADMIN_IDS=123456 # User ids separated by comma, allowing them to access /menu (You can obtain that id by typing /whoami)
Click here to talk to BotFather
There are multiple ways to start this example, here are two:
You can run this example with docker.
First create new file called .env with the content mentioned Environment Variables above.
shell script
docker-compose up -d
shell script
docker-compose logs
4. If you want to stop the bot
```shell script
docker-compose down
Alternatively you can run the example from source
shell script
git clone https://github.com/UnAfraid/ExampleTelegramBot.git
Build the source
```shell script
gradlew.bat installDist
./gradlew installDist
```
Run the bot
```shell script
set EXAMPLE_TG_BOT_TOKEN=123455:abcd.. # The token from BotFather
set EXAMPLE_TG_BOT_ADMIN_IDS=123456 # User ids separated by comma, allowing them to access /menu (You can obtain that id by typing /whoami)
export EXAMPLE_TG_BOT_TOKEN=123455:abcd.. # The token from BotFather
export EXAMPLE_TG_BOT_ADMIN_IDS=123456 # User ids separated by comma, allowing them to access /menu (You can obtain that id by typing /whoami)
cd build/install/ExampleTelegramBot
java —add-opens java.base/java.lang=ALL-UNNAMED -jar ExampleTelegramBot.jar
4. If bot is working correctly you should see the following logs
```shell script
[20:30:06] [INFO] Main: Initializing **Your bot name here** ...
[20:30:06] [INFO] Main: Authorized admin ids: [**Your ids here**]
[20:30:07] [INFO] Main: Initialization done