This README is available in multiple languages:
- English - curent page
- Українська
KBOT is a multifunctional Telegram bot developed in Go. It provides weather information, current time in selected cities, and integrates with OpenTelemetry for metrics collection.
- Find the bot in Telegram: @kbot_seo_bot.
- Start the bot by sending the
/start
command. - Use the following commands to interact:
Hello
— Greet the bot.Help
— Get the list of available commands.Time
— Get the current server time.Weather
— Get weather information (the bot will prompt you to enter a city name).- City names (Kyiv, New York, London, Seattle, Sydney) — Get the current time and weather for these cities.
- Go 1.16+
- Telegram bot token (as environment variable
TELE_TOKEN
) - OpenWeatherMap API key (as environment variable
openweather_api_key
) - (Optional) OpenTelemetry metrics endpoint (as environment variable
METRICS_HOST
)
-
Clone the repository:
git clone https://github.com/YuriiKosiy/kbot.git cd kbot
-
Set up the required environment variables:
export TELE_TOKEN="YOUR_TELEGRAM_TOKEN" export openweather_api_key="YOUR_OPENWEATHER_API_KEY" export METRICS_HOST="YOUR_METRICS_HOST" # Optional
-
Run the bot:
go run main.go start
make build
./kbot start
-
Build the image:
docker build -t kbot .
-
Get the
<image-id>
by running:docker images
The
<image-id>
is listed in theIMAGE ID
column of the output. -
Run the container:
docker run -e TELE_TOKEN="YOUR_TELEGRAM_TOKEN" -e openweather_api_key="YOUR_OPENWEATHER_API_KEY" <image-id>
The bot supports metrics collection via OpenTelemetry. If you wish to enable this, ensure that the METRICS_HOST
environment variable is set, and the bot will automatically connect to the remote telemetry server for metrics collection.
- In Telegram, search for 'BotFather'.
- Create a new bot and obtain the token.
- Use this token as the
TELE_TOKEN
environment variable.
- Register on OpenWeatherMap: https://openweathermap.org.
- Create a new API key in your account.
- Use this key as the
openweather_api_key
environment variable.