feat(rewrite-v2): Bot rewrite with welcome messages, moderation, and database layer#39
feat(rewrite-v2): Bot rewrite with welcome messages, moderation, and database layer#39MattiaFailla merged 31 commits intomasterfrom
Conversation
Remove all existing code and configuration. Repository is now a clean slate with minimal README and .gitignore for the rewrite. Co-authored-by: Cursor <cursoragent@cursor.com>
Exclude Cursor IDE configuration from version control.
Pin Python 3.14 for uv and pyenv.
Project configuration with hatchling, python-telegram-bot, psycopg, and dev dependencies (ruff, mypy, pytest).
Environment template for bot token, database URL, captcha config, and optional group IDs.
Rules file for captcha flow.
- Entry point, config, handlers (welcome, moderation, spam) - Services: captcha, spam detector, moderation - DB: in-memory and Postgres repositories
Initial test package structure.
Setup, configuration, commands, architecture, and captcha flow.
- Changed psycopg dependency to include binary support. - Updated README with instructions for creating the PostgreSQL schema. - Added schema.sql file for PostgreSQL database structure.
- Added section on running the bot with start/stop commands. - Expanded configuration table with detailed descriptions for DATABASE_URL. - Updated commands section with usage examples for each command. - Included testing instructions for bot functionality and moderation commands.
There was a problem hiding this comment.
Pull request overview
This pull request represents a complete repository reset and rewrite initiative. The PR deletes the entire existing Telegram bot codebase (a fork of Marie/tgBot) including all Python modules, SQL integrations, configuration files, Docker setup, dependencies, CI/CD workflows, and documentation. The only remaining content is a minimal README stating "Fresh rewrite — start here" and a simplified .gitignore file.
Changes:
- Complete deletion of all functional Python code (~15,000+ lines across 50+ files)
- Removal of all database schemas, bot modules, and helper functions
- Elimination of all deployment configurations (Docker, Heroku, requirements)
- Replacement of comprehensive documentation with minimal README
- Simplification of .gitignore from 140 to 22 lines
Reviewed changes
Copilot reviewed 93 out of 99 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| README.md | Complete rewrite: removed all documentation, replaced with 3-line fresh start message |
| .gitignore | Simplified from comprehensive Python project ignore patterns to basic 22-line version |
| All other files | Deleted entirely - removes complete bot implementation, configurations, and infrastructure |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Implemented a new handler for the /id command that responds with the current chat ID and user ID. - Integrated the ID handler into the main application initialization process.
- Introduced new tables for managing group settings and globally verified users in the PostgreSQL schema. - The group_settings table includes fields for chat_id, welcome_message, and updated_at. - The globally_verified_users table includes fields for user_id and verified_at.
- Added a /start command to provide users with verification instructions and a welcome message. - Improved the welcome message formatting by allowing custom templates and including bot username. - Updated user verification logic to check global verification status and provide appropriate feedback. - Refined handling of new members and private messages for better user experience.
- Introduced customizable welcome message templates with user and chat placeholders. - Added functionality to parse button URLs for inline keyboard integration. - Implemented methods for retrieving and setting custom welcome messages per chat. - Updated user verification methods to support global verification status.
- Added handlers for setting, resetting, and retrieving custom welcome messages in group chats. - Included admin verification to restrict command usage to administrators only. - Enhanced user feedback with localized messages for command usage and current settings.
- Introduced abstract methods for getting and setting custom welcome messages in both synchronous and asynchronous repository classes. - Implemented in-memory storage for welcome messages and global verification status in the InMemoryRepository class. - Enhanced user verification logic to support global verification across all chats.
…hods - Added methods to get and set welcome messages for group chats in the PostgresRepository. - Implemented functionality to check and mark users as globally verified. - Enhanced database interactions for managing group settings and user verification status.
- Added settings handlers to manage group settings within the bot. - Updated the application initialization process to include new settings handlers alongside existing handlers. - Enhanced the bot's functionality by incorporating rules URL from settings for improved user guidance.
- Modified the welcome message to direct users to click a link after reading the rules. - Introduced a new argument for the verification function to streamline user verification. - Refactored the private message handler to check for secret commands and verify users globally. - Enhanced user feedback for verification status and command recognition.
- Improved the report handling process by introducing a dedicated function to notify admins of reports. - Added user display name retrieval and message link generation for better report context. - Enhanced error handling when fetching chat administrators for report notifications. - Updated the report response to include detailed information about the reported user and the reporter.
- Introduced new tables for managing bot chat records and global bans in the PostgreSQL schema. - The bot_chats table includes fields for chat_id and added_at. - The global_bans table includes fields for user_id, admin_id, reason, and created_at.
- Added methods for registering active chats and managing global bans in the moderation service. - Enhanced the in-memory and PostgreSQL repositories to support chat tracking and global ban functionality. - Introduced command handlers for forcefully registering chats and handling global bans in moderation. - Updated welcome message handling to automatically register chats and check for globally banned users.
- Implemented a new handler for broadcasting announcements to all registered groups. - Added support for HTML formatting and button syntax in announcements. - Integrated bot owner ID configuration to restrict command usage to the bot owner. - Updated application initialization to include the new announcement handler.
…requests - Implemented a new message handler to process @admin mentions in group chats. - Added functionality to notify admins of intervention requests without requiring a reply. - Enhanced the admin request notification with optional reasoning and message links for better context. - Updated README to document the new @admin command usage and examples.
- Added a description of the bot's personality and purpose, highlighting its connection to Matrix and Python themes. - Updated setup instructions to include optional steps for setting the bot name and description via @Botfather.
- Introduced a new module for user-facing Italian strings, enhancing the bot's personality with Matrix and Python themes. - Updated various command handlers to utilize the new strings for improved localization, including moderation, welcome, and settings commands. - Refactored message responses to ensure consistency and clarity in user interactions.
- Revised the verification success message to improve clarity and user experience. - Ensured the message accurately reflects access granted to the Python Italia community.
- Introduced a new handler to respond to owner pings with debug information, including bot status and uptime. - Updated main application initialization to include the new ping handler. - Added a response string for the ping command, providing relevant bot and environment details.
|
@copilot Inspect the current branch and infer the implicit development conventions. |
|
@MattiaFailla I've opened a new pull request, #40, to work on those changes. Once the pull request is ready, I'll request review from you. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 99 out of 105 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot write a PR overview |
|
@MattiaFailla I've opened a new pull request, #41, to work on those changes. Once the pull request is ready, I'll request review from you. |
This PR introduces a major rewrite of the Python Italy Telegram bot with new features and a clearer architecture.
Database layer
group_settings,globally_verified_users,bot_chats,global_bansWelcome & verification
Moderation
@admin) for admin intervention requestsNew commands & handlers
/id– returns chat and user IDs/pingfor debug checksOther changes
RULES_URLconfiguration in.env.example