Telegram bot built with Kotlin and Spring Boot. It supports chat commands, scheduled messages, weather updates, and AI-assisted responses. Daily chat messages are stored in MongoDB, encrypted at rest, and cleared at 03:00.
- Telegram commands: help, cat, explain, weather, daily summary, and more
- Scheduled posts: morning/evening messages and daily weather
- AI integrations (DeepSeek) for styled replies and summaries
- MongoDB persistence for chats and daily messages
- AES-GCM encryption for stored daily messages
- Kotlin, Spring Boot
- MongoDB (KMongo)
- Kotlin Telegram Bot API
- Retrofit + OkHttp
Create application.properties (or use env vars). All keys are required.
spring.application.name=myTelegramBot
spring.data.mongodb.uri=mongodb://mongo:27017/bot
bot.token=BOT_TOKEN
group.name=GROUP_NAME
cat.api-key=CAT_API_KEY
deepseek.api-key=DEEPSEEK_API_KEY
weather.api-key=WEATHER_API_KEY
messages.encryption-key=CHANGE_ME_32_BYTES_KEY_123456789
Notes:
messages.encryption-keymust be a Base64 string or a raw string of 16/24/32 bytes.- If you rotate the key, old stored messages will not decrypt.
/help- show available commands/cat- random cat image/pus- translate a replied message into "pus style"/explain <question>- explain something in a child-friendly way/today- day status (workday/holiday)/tomorrow- day status for tomorrow/weather <city>- weather in supported cities/day- AI summary of messages for the day
Supported cities are listed in CityCoordinates.
- 03:00 - clear daily messages collection
- 06:00 - morning greeting + day status
- 08:00 - weather for supported cities
- 19:00 - evening message + daily summary
./gradlew bootRun
./gradlew test
Build container image with Jib (uses env vars for registry credentials):
./gradlew jib
Generate a Base64 key:
openssl rand -base64 32
src/main/kotlin/.../config- bot wiring and Mongo configsrc/main/kotlin/.../client- external APIssrc/main/kotlin/.../service- schedulers and shared servicessrc/main/kotlin/.../repository- Mongo collectionssrc/main/resources- application properties and resources