Skip to content

koctuk999/myTelegramBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My Telegram Bot

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.

Features

  • 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

Tech Stack

  • Kotlin, Spring Boot
  • MongoDB (KMongo)
  • Kotlin Telegram Bot API
  • Retrofit + OkHttp

Configuration

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-key must be a Base64 string or a raw string of 16/24/32 bytes.
  • If you rotate the key, old stored messages will not decrypt.

Commands

  • /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.

Scheduled Jobs

  • 03:00 - clear daily messages collection
  • 06:00 - morning greeting + day status
  • 08:00 - weather for supported cities
  • 19:00 - evening message + daily summary

Running Locally

./gradlew bootRun

Tests

./gradlew test

Docker (Jib)

Build container image with Jib (uses env vars for registry credentials):

./gradlew jib

Encryption Key Generation

Generate a Base64 key:

openssl rand -base64 32

Project Structure

  • src/main/kotlin/.../config - bot wiring and Mongo config
  • src/main/kotlin/.../client - external APIs
  • src/main/kotlin/.../service - schedulers and shared services
  • src/main/kotlin/.../repository - Mongo collections
  • src/main/resources - application properties and resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages