NachonekoBot is a multifunctional Telegram Bot with various useful and interesting features. It's designed to be easy to deploy and configure, with support for both standard Python installation and Docker deployment.
- Multi-language support
- Modular plugin system
- PostgreSQL database integration
- Easy configuration with YAML and TOML files
- Docker support for simple deployment
- Python 3.11 or higher
- PostgreSQL database (for standard installation)
- Docker and Docker Compose (for Docker installation)
-
Clone the repository:
git clone https://github.com/KimmyXYC/NachonekoBot-V2.git cd NachonekoBot-V2 -
Install dependencies using PDM:
pip install pdm pdm install
-
Set up PostgreSQL:
- Install PostgreSQL if not already installed
- Create a database for the bot
- Note the database connection details (host, port, database name, username, password)
-
Set up configuration files:
cp .env.exp .env # Configuration file for Telegram bot token cp conf_dir/config.yaml.exp conf_dir/config.yaml -
Edit the configuration files with your own values:
nano .env # Edit this configuration file to set your Telegram bot token nano conf_dir/config.yaml # Configure database connection and other settings
The
.envfile contains the following configuration options:TELEGRAM_BOT_TOKEN=your_bot_token_here # TELEGRAM_BOT_PROXY_ADDRESS=socks5://127.0.0.1:7890TELEGRAM_BOT_TOKEN: Your Telegram bot token obtained from BotFatherTELEGRAM_BOT_PROXY_ADDRESS: (Optional) Proxy address for connecting to Telegram API, uncomment if needed
-
Run the bot:
pdm run python main.py
Before running the application, set up the configuration files in the conf_dir directory:
config.yaml: Main configuration file for the botsettings.toml: Settings for Dynaconf
Example configuration files are provided:
config.yaml.exp: Example main configurationsettings.toml.example: Example Dynaconf settings
You can copy and rename these files:
cp .env.exp .env # Configuration file for Telegram bot token
cp conf_dir/config.yaml.exp conf_dir/config.yaml
cp conf_dir/settings.toml.example conf_dir/settings.tomlThe .env file contains the following configuration options:
TELEGRAM_BOT_TOKEN=your_bot_token_here
# TELEGRAM_BOT_PROXY_ADDRESS=socks5://127.0.0.1:7890
TELEGRAM_BOT_TOKEN: Your Telegram bot token obtained from BotFatherTELEGRAM_BOT_PROXY_ADDRESS: (Optional) Proxy address for connecting to Telegram API, uncomment if needed
At minimum, configure the database connectionn in config.yaml:
database:
host: postgres
port: 5432
dbname: nachonekobot
user: postgres
password: postgres
# Other Telegram settingsYou can customize the deployment by setting environment variables:
POSTGRES_USER: PostgreSQL username (default: postgres)POSTGRES_PASSWORD: PostgreSQL password (default: postgres)POSTGRES_DB: PostgreSQL database name (default: nachonekobot)DEBUG: Set to "true" to enable debug mode (default: false)
-
Start the application:
docker-compose up -d
-
View logs:
docker-compose logs -f app
-
Stop the application:
docker-compose down
-
Stop the application and remove volumes:
docker-compose down -v
The following data is persisted:
- PostgreSQL data: Stored in a Docker volume
- Configuration files: Mounted from the host's
conf_dirdirectory - Application data: Stored in the
datadirectory - Logs: Stored in
run.log
-
If the application fails to connect to the database, check:
- PostgreSQL container is running:
docker-compose ps - Database credentials in
config.yamlmatch the environment variables - Database initialization was successful:
docker-compose logs postgres
- PostgreSQL container is running:
-
If the bot doesn't respond, check:
- Application logs:
docker-compose logs app - Telegram token in configuration
- Network connectivity
- Application logs:
- In production, never use default passwords
- Consider using Docker secrets or a secure environment variable management system
- Restrict access to the PostgreSQL port (5432) if exposed
- Linux system with systemd
- Python 3.12 or higher
- PostgreSQL database
- PDM package manager
-
Clone the repository to
/opt/NachonekoBot-V2(or your preferred location):sudo mkdir -p /opt/NachonekoBot-V2 sudo git clone https://github.com/KimmyXYC/NachonekoBot-V2.git /opt/NachonekoBot-V2
-
Create a dedicated user for the bot (recommended for security):
sudo useradd -r -s /bin/false nachonekobot sudo chown -R nachonekobot:nachonekobot /opt/NachonekoBot-V2
-
Install dependencies using PDM:
cd /opt/NachonekoBot-V2 sudo pip install pdm sudo -u nachonekobot pdm install -
Set up PostgreSQL:
- Install PostgreSQL if not already installed
- Create a database and user for the bot
- Configure database connection in config.yaml
-
Configure the bot:
sudo -u nachonekobot cp .env.exp .env sudo -u nachonekobot cp conf_dir/config.yaml.exp conf_dir/config.yaml sudo -u nachonekobot nano .env # Edit to set your Telegram bot token sudo -u nachonekobot nano conf_dir/config.yaml # Configure database and other settings
-
Copy the systemd service file:
sudo cp /opt/NachonekoBot-V2/nachonekobot.service /etc/systemd/system/
-
Enable and start the service:
sudo systemctl daemon-reload sudo systemctl enable nachonekobot.service sudo systemctl start nachonekobot.service -
Check the service status:
sudo systemctl status nachonekobot.service
-
View logs:
sudo journalctl -u nachonekobot.service -f
- Start the service:
sudo systemctl start nachonekobot.service - Stop the service:
sudo systemctl stop nachonekobot.service - Restart the service:
sudo systemctl restart nachonekobot.service - Check status:
sudo systemctl status nachonekobot.service - View logs:
sudo journalctl -u nachonekobot.service -f - Enable at boot:
sudo systemctl enable nachonekobot.service - Disable at boot:
sudo systemctl disable nachonekobot.service
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License — see the LICENSE.md file for details