Contributing
Contributing to Alita Robot
Section titled “Contributing to Alita Robot”Thank you for your interest in contributing to Alita Robot! This guide will help you get started with development.
Development Setup
Section titled “Development Setup”Prerequisites
Section titled “Prerequisites”- Go 1.25+
- PostgreSQL 14+
- Redis 6+
- Make (for running commands)
Clone and Setup
Section titled “Clone and Setup”git clone https://github.com/divkix/Alita_Robot.gitcd Alita_Robotcp sample.env .env# Edit .env with your configurationEssential Commands
Section titled “Essential Commands”make run # Run the bot locallymake build # Build release artifacts using goreleasermake lint # Run golangci-lint for code quality checksmake tidy # Clean up and download go.mod dependenciesDatabase Commands
Section titled “Database Commands”make psql-migrate # Apply all pending PostgreSQL migrationsmake psql-status # Check current migration statusmake psql-reset # Reset database (DANGEROUS: drops all tables)Project Structure
Section titled “Project Structure”Alita_Robot/├── alita/│ ├── config/ # Configuration and environment parsing│ ├── db/ # Database operations and repositories│ ├── i18n/ # Internationalization│ ├── modules/ # Command handlers (one file per module)│ └── utils/ # Utility functions and decorators├── locales/ # Translation files (YAML)├── migrations/ # SQL migration files└── main.go # Entry pointAdding a New Module
Section titled “Adding a New Module”- Create database operations in
alita/db/{module}_db.go - Implement command handlers in
alita/modules/{module}.go - Register commands in the module’s
init()function - Add translations to
locales/en.yml(and other locale files)
Module Template
Section titled “Module Template”package modules
import ( "github.com/divkix/Alita_Robot/alita/utils/helpers" "github.com/PaulSonOfLars/gotgbot/v2" "github.com/PaulSonOfLars/gotgbot/v2/ext" "github.com/PaulSonOfLars/gotgbot/v2/ext/handlers")
var myModule = moduleStruct{moduleName: "mymodule"}
func (m moduleStruct) myCommand(b *gotgbot.Bot, ctx *ext.Context) error { // Implementation return ext.EndGroups}
func init() { helpers.RegisterModule(myModule.moduleName, func(d *ext.Dispatcher) { d.AddHandler(handlers.NewCommand("mycommand", myModule.myCommand)) })}Code Style
Section titled “Code Style”- Run
make lintbefore committing - Follow Go conventions and idioms
- Use the repository pattern for data access
- Add proper error handling with panic recovery
- Use decorators for common middleware (permissions, error handling)
Translation Guidelines
Section titled “Translation Guidelines”Add help messages to locales/en.yml:
mymodule_help_msg: | Help text for my module.
*Commands:* × /mycommand: Description of command.Testing
Section titled “Testing”The project uses golangci-lint for code quality. Manual testing is done with a test bot and group:
- Create a test bot via @BotFather
- Create a test group
- Configure your
.envwith the test bot token - Run
make runand test your changes
Submitting Changes
Section titled “Submitting Changes”- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Make your changes
- Run
make lintto check for issues - Commit with a descriptive message
- Push to your fork
- Open a Pull Request
Getting Help
Section titled “Getting Help”- Support Group: t.me/DivideSupport
- GitHub Issues: Report bugs or request features