mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-07-07 00:06:32 +08:00
2.9 KiB
2.9 KiB
Contributing
Setup
To run the bot
cp .env.example .env
python -V # 3.10
pip install -r requirements.txt
python -m bot
Before you push, make sure the pre-commit hooks are installed and run successfully.
pip install pre-commit
pre-commit install
pre-commit run --all-files
To test the bot on your own discord server you need to register a discord application at the Discord Developer Portal and get at bot token.
- Follow a tutorial on how to get a bot token, for example this one: Creating a discord bot & getting a token
- The bot script expects the bot token to be in the
.envfile under theTOKENvariable.
Resources
Structure
.env # Environment variables
.env.example # Example environment variables
CONTRIBUTING.md # This file
dev-requirements.txt # Development requirements
flake8-requirements.txt # Flake8 extensions (for linting)
noxfile.py # Nox session definitions (for formatting, typechecking, linting)
pyproject.toml # Project configuration
README.md # Project readme
requirements.txt # Requirements
templates/ # Message templates
bot/
├─ __init__.py
├─ __main__.py # Entrypoint
├─ bot.py # Main bot class
├─ config.py # Configuration and secrets
├─ utils.py # Utility Functions
│
├─ db/ # Database related code
│ ├─ database.db # SQLite database
│ └─ schema.sql # Database schema
│
└── extensions/ # Application logic, see https://hikari-lightbulb.readthedocs.io/en/latest/guides/extensions.html
└─ hot_reload.py # Utility for hot reload extension
Adding a new command/listener
- Create a new file in the
extensionsfolder - Copy the template below
# -*- coding: utf-8 -*-
"""My plugin."""
import lightbulb
plugin = lightbulb.Plugin("MyPlugin")
# Add your commands here
def load(bot: lightbulb.BotApp):
"""Add the plugin to the bot."""
bot.add_plugin(plugin)
def unload(bot: lightbulb.BotApp):
"""Remove the plugin to the bot."""
bot.remove_plugin(plugin)
For example commands and listeners, see EXAMPLES.md
Docs
Discord
Main framework
Command handler
Component handler (buttons, modals, etc... )