A Telegram bot for tracking karma in group chats, built with Python and the python-telegram-bot library. Created for Penguins Network.
- Karma System: Give or take karma from users with
+1or-1replies - Karma Statistics: View karma leaderboards with
/stats - Sudo Management: Add or remove administrators with
/addsudoand/rmsudo - Backup & Restart: Admin commands for bot management
- SQLite Database: Persistent storage of user karma and history
- Python 3.8 or higher
- A Telegram Bot Token (get one from @BotFather)
- Your Telegram User ID
- Your group/network chat ID
First, create your configuration file:
cp sample_config.env .envEdit .env and add your credentials:
BOT_TOKEN=your_bot_token_here
SUDOERS=your_user_id,other_user_id # Comma-separated list
NETWORK=your_group_chat_idpip3 install -r requirements.txt
python3 -m botuv sync
uv run -m botdocker compose up -dTo view logs:
docker compose logs -fTo stop the bot:
docker compose down/start- Start the bot and get a welcome message/help- Show available commands/stats- Display karma leaderboard (groups only)
Reply to a message with:
+1or+- Give karma-1or-- Take karma
/addsudo- Reply to a user to grant them sudo privileges/rmsudo- Reply to a user to revoke sudo privileges/backup- Get a backup of the database (private chat)/restart- Restart the bot (private chat)
PenguinsKarmaBot/
├── bot/
│ ├── __init__.py # Main application setup
│ ├── __main__.py # Entry point
│ ├── database.py # Database configuration
│ ├── models.py # Database models
│ └── plugins/
│ ├── karma.py # Karma functionality
│ ├── misc.py # Helper commands
│ └── sudoers.py # Admin management
├── compose.yml # Docker Compose configuration
├── Dockerfile # Docker build instructions
├── requirements.txt # Python dependencies
└── sample_config.env # Example configuration
Contributions are welcome! Please feel free to submit a Pull Request.
See LICENSE file for details.