Thanks to visit codestin.com
Credit goes to github.com

Skip to content

devadathanmb/ktu-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

KTU Bot ⚑

KTU Bot

A battle-tested, fully open source & libre Telegram bot that served 30,000+ users/month at its peak
Fast lookups β€’ Full-text search β€’ Smart announcement subscriptions β€’ Real-time notifications
Everything the official website should've been, but isn't.

No ads. No tracking. 100% libre and will always remain so.

Better Stack Badge


Important

This bot just got a major rewrite. This branch (grammy-rewrite) contains the new architecture built on GrammY. The legacy implementation lives in the prod branch.

Read the story: Why I rewrote this entire thing

Note

This project is currently in autopilot/maintenance mode. Core functionality depends on public KTU endpoints that can change without notice. If you want to help maintain, extend, or fork it β€” you're more than welcome. ❀️


What Is This? πŸ€”

KTU Bot is a Telegram bot that helps students do everything they could (and should) do on the official KTU website β€” check announcements, timetables, academic calendars, results, and more. The official site is notoriously clunky and frequently crashes when you actually need it, so this bot taps into their public APIs to deliver a reliable experience the website can't.

What started as a quick 50-line script to check my own results eventually became a lifeline for tens of thousands of students. It turned into the default go-to during results season, sparked a wave of similar tools, and carved out its own identity.

What You Can Do

  • πŸ” Full-text search across announcements, academic calendars, and exam timetables β€” find what you need right from the chat
  • πŸ“‚ Browse historical data β€” announcements, exam timetables, academic calendars, all in one place
  • ⚑ Smart subscriptions β€” get only the announcements that matter to you using filters (course, type), delivered the moment they arrive
  • πŸ“Š Results lookup (currently broken, not the bot's fault β€” read why)

Tip

Check out the Commonly Asked Questions for answers to common questions like "Why isn't results working?" and "Will the bot keep working?"

Architecture Overview πŸ—οΈ

The bot follows a microservices architecture where each component handles a specific responsibility. If one service fails, others keep running.

Component Type What It Does
Bot GrammY Telegram bot Handles all user interactions β€” commands, searches, conversations
Announcements Notify Worker Background worker Monitors for new announcements using BullMQ scheduled jobs and sends filtered alerts to users
Broadcasts Worker Background worker Handles queued broadcast message delivery
Data Sync Worker Background worker Periodically syncs KTU data to local DB via BullMQ scheduled jobs to power full-text search
Bull Board Service Monitoring service Web dashboard for real-time queue monitoring and job management
PostgreSQL Database Stores all data with Drizzle ORM for type-safe queries
Redis Queue Powers BullMQ jobs

Tip

Want to understand how it all works? Check out How It Works for the complete architecture breakdown with diagrams.

Quick Start πŸš€

Prerequisites

Trust me. Docker is the easiest way to run anything within seconds πŸ™ƒ

1. Clone the Repo

git clone https://github.com/devadathanmb/ktu-bot.git
cd ktu-bot

2. Configure Environment

Development environment files live in the dev/ directory. Each service/module has its own .env file.

Minimum required:

  • dev/bot.env β€” Set BOT_TOKEN and BOT_FILE_UPLOAD_CHANNEL_ID
  • Most files come prefilled with sensible defaults

Optional (for extra features):

  • dev/api.env β€” For UptimeRobot monitoring, file uploads, etc.
  • dev/llm.env β€” For AI-powered announcement filtering

Note

Most environment variables needed for the development setup come pre-configured in each .env file.

However, some configurations depend on external services and are left as placeholder values. Fill those in with actual credentials if you plan to use those features.

Important

For sensitive local secrets:

cp .env.dev.example .env.dev
# Add your personal API keys, tokens, or credentials here

This file is mounted last in Docker Compose, so values here override anything in dev/*.env files.

Warning

If you don't configure certain .env variables, those features simply won't work or the zod validations may get triggered. Review each file to see what's needed.

3. Run Everything

docker compose -f docker-compose.dev.yaml down -v --remove-orphans && \
docker compose -f docker-compose.dev.yaml up --build

This starts all services with hot-reload enabled. Code changes trigger automatic restarts.

4. Run Only the Bot

If you don't need the workers:

docker compose -f docker-compose.dev.yaml up ktu-bot-app --build

Tip

Database migrations are generated and run automatically via the ktu-bot-db-migrations service.

Once everything is up, talk to your bot in Telegram!

5. Run Individual Workers

Need just the notification worker? No problem:

# Announcements notify worker
docker compose -f docker-compose.dev.yaml up announcements-notify-worker --build

# Data sync worker
docker compose -f docker-compose.dev.yaml up data-sync-worker --build

# Broadcasts worker
docker compose -f docker-compose.dev.yaml up broadcasts-worker --build

Tip

Each service exposes a health check endpoint (e.g., http://localhost:3000/health)

There's also a dedicated bull-board-service running on port 3010 that provides a Bull Board UI for monitoring background workers and queues. Access it at http://localhost:3010

Production Deployment 🏭

Production uses a single .env file approach for simplicity.

1. Configure Environment

cp .env.prod.example .env
# Edit .env and fill in all required values
# Most values come pre-configured β€” just update anything specific to your deployment.

2. Start Services

docker compose down -v --remove-orphans && \
docker compose up -d --build

3. Verify Health

curl -f http://localhost:3000/health

Notes

  • All services communicate over an internal Docker network
  • Database migrations run automatically on startup
  • Make sure all required API keys/tokens are provided
  • If some keys are missing, update the code to handle their absence gracefully

Tech Stack πŸ› οΈ

  • Language: TypeScript β€” Because type-safe code is always better?
  • Bot Framework: GrammY β€” Modern, type-safe Telegram bot framework
  • Database: PostgreSQL β€” Powerful relational DB with god knows how many features
  • ORM: Drizzle β€” Type-safe SQL queries and migrations
  • Job Queue: BullMQ β€” Reliable background job processing
  • HTTP Client: got β€” Modern fetch wrapper

Contributing 🀝

Contributions are welcome! Whether it's bug fixes, new features, documentation improvements, or ideas β€” all are appreciated.

Tip

Need help getting started? Check out How It Works to understand the architecture.

Tip

New to Telegram Bot ecosystem? Check out this awesome getting started guide from GrammY.

Bugs & Feedback πŸ›

Found a bug? Have an idea? Want to discuss something?

Open an issue: https://github.com/devadathanmb/ktu-bot/issues

When reporting bugs, please try to include:

  • What you were trying to do?
  • What happened instead?
  • Steps to reproduce (if reproducible)

Documentation πŸ“š

  • How It Works β€” Complete architecture breakdown with diagrams
  • The Rewrite Story β€” Why I rewrote this and some commonly asked questions

License πŸ›‘οΈ

GPL-3.0 β€” See LICENSE for details.

This means you can use, modify, and distribute this code freely, but you must:

  • Keep it open source
  • Share your changes under the same license
  • Give credit where it's due

About

A telegram bot to view KTU exam results and notifications easily.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages