A high-performance, bilingual Telegram Bot designed to streamline membership verification and management for student organizations. Built for speed, security, and scalability.
- Instant Verification: Checks student membership status via Matric Number & IC.
- Automated Registration:
- Auto-generates USAS Email.
- Auto-generates Membership ID (
STEM(YY/YY)XXXX). - Auto-calculates Session based on Date of Entry.
- Payment Receipts: Auto-sends PDF receipts via Email (Hosted on Drive).
- Admin Dashboard:
- Manage Admins & Members.
- Detailed View: View Status, Proof, Invoice ID, and Receipt Link.
- Approve/Reject new registrations.
- Broadcast messages to all users.
- View Monthly Statistics.
- 🛡️ Robust Admin System:
- Dashboard: Search (Simple/Detail Views), Add/Delete Members, and Broadcast.
- Advanced Search: Toggle between Simple View (List) and Detailed View (Card UI) with full column data.
- Superadmin Control: Manage other admins, toggle Maintenance Mode, and monitor system health.
- 📊 Google Sheets Backend: Uses Google Sheets as a database types.
- Auto-Status: Bot marks new registrations as '✓' (Seen) to prevent duplicates.
- 🚀 High Concurrency: Optimized with
asyncioand threaded logging to handle 100+ concurrent requests.
- Framework: python-telegram-bot (v20+)
- Database: Google Sheets API via gspread
- Automation: Google Apps Script (for server-side sheet logic)
- Concurrency: Python
asyncio&threading - Deployment: Optimized for Render / Docker
- Python 3.9+
- A Telegram Bot Token (from @BotFather)
- Google Cloud Service Account (for Sheets API)
📖 Click here for the DETAILED INSTALLATION GUIDE (Step-by-Step)
For a quick setup:
-
Clone the repository
git clone https://github.com/zis3c/stem-bot.git cd stem-bot -
Install Dependencies
pip install -r requirements.txt
-
Setup Environment Variables Create a
.envfile in the root directory:TELEGRAM_TOKEN=your_bot_token_here SHEET_ID=your_google_sheet_id GOOGLE_CREDENTIALS={"type": "service_account", ...} # JSON string SUPERADMIN_IDS=123456789,987654321 ADMIN_IDS=123456789
-
Setup Google Sheets
-
Share your Google Sheet with the Service Account Email.
-
Ensure tabs named:
Registrations,system_admins,system_config. -
Structure for
RegistrationsSheet (Important!):Col Field Col Field A Timestamp L Birth Place B Email M Address C Name N Date of Entry D Matric O Minute No E Courses P Membership ID F Semester Q Receipt Proof G Phone R Status H Personal Email S Payment Receipt I USAS Email T Invoice No J IC No U Statistic K Birthday
-
python bot.pyThis bot is configured for auto-deployment on Render.
- New Web Service: Connect your GitHub repo.
- Runtime: Python 3.
- Build Command:
pip install -r requirements.txt - Start Command:
python bot.py - Environment Variables: Add your
.envkeys to Render's Environment tab.
- Global User Tracking: Logs every interaction (text, buttons, stickers, media) for all users.
- Keyboard Logic: Detects and labels specific button clicks (e.g., "Check Membership") for easier auditing.
- Detailed Auditing: Explicitly logs results of sensitive actions (Membership checks, Language changes, Registrations).
- Admin Audit: Logs administrative actions (Add/Delete Member, Broadcast).
- Deduplicated User List: Ensures broadcasts are sent only to unique users, preventing spam.
- Auto-Cleanup & Reporting:
- Logs are stored locally in
activity.log. - Every day at 00:00 UTC, the bot sends the log file to Superadmins and clears it to maintain performance.
- Logs are stored locally in
- Role-Based Access: Strict separation between Users, Admins, and Superadmins.
- Secure Logging: Audit logs for all users actions.
- Credential Protection:
.gitignoreconfigured to prevent leaking secrets.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Built with ❤️ by @zis3c