A Telegram bot designed to help hostel guests find friends for gaming and manage shared resources across multiple locations.
LFG (Looking For Groups) creates a digital lobby system for hostel common areas, making it easy for travelers to:
- Find gaming partners for Mahjong, Nintendo Switch, PlayStation, board games, and more
- Check resource availability for TVs, game consoles, pool tables, and other shared equipment
- Reserve resources automatically when creating groups
- Get notified when groups fill up, games start, or resources become available
- Easy Group Creation: Use
/lfgto create a gaming session in seconds - Browse Active Groups: Find and join existing groups with
/browse - Resource Management: Check availability and reserve shared equipment
- Smart Notifications: Get alerted 15 minutes before your game starts
- Multi-Hostel Support: Works across multiple hostel locations
- Approval System: Admin approval ensures only current guests can access
- User Management: Approve or reject access requests
- Resource Control: Add, edit, or remove shared resources
- Custom Categories: Create hostel-specific game categories beyond the defaults
- Group Oversight: View all active groups and cancel if needed
- Usage Statistics: Track popular games, peak hours, and resource utilization
- Public Channels: Auto-post new groups to your hostel's announcement channel
- Join: Send
/startto the bot and select your hostel - Wait for Approval: Admins will approve your access request
- Create or Join Groups: Use
/lfgto create a gaming session or/browseto find existing ones - Get Notified: Receive reminders when it's time to play
- Check Resources: View which gaming areas and equipment are available
- Approve Users: Review and approve guests requesting access
- Manage Resources: Add TVs, consoles, tables, and other shared equipment
- Customize Categories: Create categories specific to your hostel (e.g., "Poker Night")
- Monitor Activity: Track groups, resource usage, and statistics
- Maintain Order: Cancel problematic groups or manage user access
- Runtime: Node.js (Local development)
- Database: Supabase (PostgreSQL - Cloud)
- Bot Framework: Grammy (modern Telegram Bot API library)
- Language: TypeScript
- Deployment: Local-first (Cloudflare Workers migration planned for production)
- Node.js 18+ and npm
- Supabase account and project (free tier is fine)
- Telegram bot token (from @BotFather)
- Telegram channels for each hostel (for group announcements)
# Clone the repository
git clone https://github.com/EnderSky/LFG
cd LFG
# Install dependencies
npm install
# Copy environment template
cp .env.example .env
# Edit .env with your credentials (see Configuration below)Create a .env file in the project root:
# Telegram Bot Configuration
TELEGRAM_BOT_TOKEN=your_bot_token_here
# Supabase Configuration (get these from your Supabase project settings)
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your_anon_key_here
SUPABASE_SERVICE_KEY=your_service_key_here
# Environment
NODE_ENV=development
LOG_LEVEL=DEBUG
# Scheduler intervals (milliseconds) - optional, defaults provided
NOTIFICATION_CHECK_INTERVAL=300000 # 5 minutes
CLEANUP_INTERVAL=900000 # 15 minutes
ARCHIVE_INTERVAL=3600000 # 1 hour-
Create a Supabase Project:
- Go to supabase.com and create a new project
- Wait for the project to be ready
- Get your project URL and keys from Settings > API
-
Run Database Migrations:
- Open Supabase SQL Editor
- Copy contents of
supabase/migrations/001_initial_schema.sql - Paste and execute in SQL Editor
-
Seed Initial Data:
- Copy contents of
supabase/seed.sql - Paste and execute in SQL Editor
- This creates predefined game categories and a test hostel
- Copy contents of
# Start the bot in development mode (with auto-reload)
npm run dev
# The bot will:
# - Connect to Telegram using long polling
# - Start background scheduler for notifications and cleanup
# - Log all activity to console
# - Auto-reload on file changes
# You can now interact with your bot on Telegram!Once the bot is running:
- Open Telegram and find your bot (search for the username you set with @BotFather)
- Send
/startto begin registration - You'll need to manually approve yourself in the database first (or create an admin)
- Test creating groups, managing resources, etc.
Quick Admin Setup (for first-time testing):
-- Run this in Supabase SQL Editor to make yourself an admin
-- Replace with your actual telegram_id (visible after /start)
INSERT INTO admins (user_id, hostel_id, is_super_admin)
SELECT u.id, u.hostel_id, true
FROM users u
WHERE u.telegram_id = YOUR_TELEGRAM_ID;/start- Register and request access to a hostel/help- Display help message and available commands/lfg- Create a new gaming group/browse- Browse and join available groups/mygroups- View all your active groups/resources- Check availability of shared resources/checkout- Check out of resources you're using
/admin- Open the admin control panel/approve <username>- Quick approve a pending user/reject <username>- Quick reject a pending user/stats- View quick statistics
The bot comes with these predefined categories:
- ๐ Mahjong
- ๐ฎ Nintendo Switch
- ๐ฎ PlayStation
- ๐ฎ Xbox
- ๐ฒ Board Games
- ๐ Card Games
- ๐ฑ Pool/Billiards
- ๐ Table Tennis
- โ Other
Admins can add custom categories specific to their hostel (e.g., "Poker Night", "Football", "Karaoke").
The bot automatically manages group and resource lifecycles:
- Groups expire 6 hours after their scheduled start time
- Resources auto-checkout after their max duration (default 6 hours)
- Notifications sent 15 minutes before games start
- Warnings sent 30 minutes before auto-checkout
- Old data archived after 7-30 days
- Admin Approval: Only approved users can create and participate in groups
- Hostel Isolation: Users only see data for their hostel
- Row Level Security: Database enforces access control
- Secure Tokens: Bot token and keys stored in .env (never committed)
- No Personal Data: Only stores Telegram username and first name
LFG/
โโโ src/
โ โโโ handlers/ # Command handlers (/start, /lfg, etc.)
โ โโโ services/ # Business logic (database, notifications)
โ โโโ types/ # TypeScript type definitions
โ โโโ utils/ # Helper functions
โ โโโ middleware/ # Auth, rate limiting, errors
โ โโโ bot.ts # Grammy bot setup
โ โโโ index.ts # Main entry point (long polling)
โ โโโ scheduler.ts # Background jobs (setInterval)
โโโ supabase/
โ โโโ migrations/ # Database migrations
โ โโโ seed.sql # Seed data
โโโ tests/ # Unit and integration tests
โโโ .env.example # Environment template
โโโ tsconfig.json # TypeScript config
โโโ package.json
Edit src/utils/constants.ts to change:
- Max active groups per user (default: 3)
- Max group memberships (default: 5)
- Default group expiry (default: 6 hours)
- Resource max duration (default: 6 hours)
- Notification timing (default: 15 min before)
You can also override scheduler intervals in .env:
NOTIFICATION_CHECK_INTERVAL=600000 # Change to 10 minutes
CLEANUP_INTERVAL=1800000 # Change to 30 minutesThe modular structure makes it easy to extend:
- Add new commands in
src/handlers/ - Add business logic in
src/services/ - Update database schema in
supabase/migrations/ - Register command in
src/bot.ts
- Check the console for error messages
- Verify
TELEGRAM_BOT_TOKENis correct in.env - Ensure the bot is running (
npm run dev) - Ensure the bot is running (
npm run dev) - Test by sending
/startto your bot on Telegram
- Verify Supabase URL and keys in
.env - Check RLS policies are properly configured (see migrations)
- Ensure migrations and seed data have been run
- Check Supabase logs for query errors
- Check console for scheduler logs
- Verify scheduler is running (should see "Scheduler started" message)
- Test by creating a group with a near-future time
- Check that users have correct Telegram IDs in database
- Manually approve users in database, or
- Make yourself an admin first, then use
/adminto approve users
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Submit a pull request
See DESIGN.md for detailed workflows and future enhancements:
- Favorite resources for availability alerts
- Auto-create Telegram group chats for gaming sessions
- Reputation/reliability system
- Calendar view for scheduled groups
- User gaming profiles and preferences
- Private/invite-only groups
- Recurring groups (weekly Mahjong nights)
- Equipment checkout system (controllers, cards)
- Multi-language support
- Web dashboard for admins
- Production deployment to Cloudflare Workers
- DESIGN.md - Comprehensive design document with workflows, database schema, and architecture
- API Reference - Database queries and Telegram API usage (coming soon)
- Admin Guide - Guide for hostel administrators (coming soon)
Current Version: Local Development (v1.0)
This bot is currently designed for local development and testing. The architecture uses:
- Long polling for Telegram updates (no webhook needed)
- Simple
setInterval()for background jobs - Node.js runtime
Future: Migration to Cloudflare Workers for production deployment is planned, which will provide:
- Global edge deployment
- Auto-scaling
- Webhook-based updates
- Generous free tier
The codebase is designed to make this migration straightforward with minimal changes.
For issues or questions:
- Check the DESIGN.md for detailed information
- Review console logs for errors
- Check Supabase dashboard for database issues
- Ensure all environment variables are set correctly
MIT License - feel free to use this for your hostel or organization!
- Built with Grammy - Modern Telegram Bot Framework
- Database by Supabase - Open source Firebase alternative
- Ready for Cloudflare Workers deployment
Made for travelers who love gaming together ๐ฎ
Start finding your gaming crew today!