π A Telegram bot adder application built with Go and Python. Manage and add members to Telegram groups or channels via a web interface.
π Add members to Telegram groups/channels
π Web-based management interface
π Secure authentication and logging
π PostgreSQL database integration
π Deployable on Ubuntu VPS
sudo apt update && sudo apt upgrade -y
sudo apt install -y git curl wget build-essential python3 python3-pip python3-venv postgresql postgresql-contrib nginx certbot python3-certbot-nginxgit clone https://github.com/Ayrop/telegram-bot-adder.git
cd telegram-bot-adderCreate a .env file in the project root:
DB_HOST=localhost
DB_PORT=5432
DB_USER=admin_user
DB_PASSWORD=YOUR-STRONG-PASSWORD
DB_NAME=admin_panel
PORT=8080sudo systemctl start postgresql
sudo systemctl enable postgresql
sudo -i -u postgres
psql
CREATE DATABASE admin_panel;
CREATE USER admin_user WITH PASSWORD 'YOUR-STRONG-PASSWORD';
GRANT ALL PRIVILEGES ON DATABASE admin_panel TO admin_user;
\q
exit\c admin_panel;
CREATE TABLE admins (
id SERIAL PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL
);
INSERT INTO admins (username, password_hash)
VALUES ('admin', 'YOUR-HASHED-PASSWORD');
CREATE TABLE telegram_config (
id SERIAL PRIMARY KEY,
api_token TEXT NOT NULL,
channel_id TEXT NOT NULL,
phone_prefix TEXT DEFAULT '+98',
rate_limit_count INTEGER DEFAULT 50,
rate_limit_seconds INTEGER DEFAULT 120,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE api_accounts (
id SERIAL PRIMARY KEY,
api_token TEXT NOT NULL,
channel_id TEXT NOT NULL,
daily_limit INT NOT NULL,
minute_limit INT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE api_account_usage (
id SERIAL PRIMARY KEY,
account_id INTEGER NOT NULL,
added_count INTEGER NOT NULL DEFAULT 0,
added_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (account_id) REFERENCES api_accounts(id)
);# Install Go
wget https://go.dev/dl/go1.20.3.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.20.3.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go version # Verify installation
go mod tidy
# Set up Python virtual environment
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtgo build -o telegram_bot_adder
./telegram_bot_addersudo nano /etc/nginx/sites-available/telegram_bot_adderAdd the following:
server {
listen 80;
server_name your_domain.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name your_domain.com;
ssl_certificate /etc/letsencrypt/live/your_domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your_domain.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}Enable and restart Nginx:
sudo ln -s /etc/nginx/sites-available/telegram_bot_adder /etc/nginx/sites-enabled/
sudo systemctl restart nginxsudo certbot --nginx -d your_domain.comsudo nano /etc/systemd/system/telegram_bot_adder.serviceAdd the following:
[Unit]
Description=Telegram Bot Adder
After=network.target
[Service]
ExecStart=/path/to/telegram_bot_adder
WorkingDirectory=/path/to/your/project
Restart=always
EnvironmentFile=/path/to/your/project/.env
[Install]
WantedBy=multi-user.targetEnable and start the service:
sudo systemctl enable telegram_bot_adder
sudo systemctl start telegram_bot_adderCheck logs:
sudo journalctl -u telegram_bot_adder -fRestart if needed:
sudo systemctl restart telegram_bot_adderπ₯ Contributions are welcome! Please read our Contributing Guidelines.
π This project is developed and maintained by Ayrop.com - Pooriya Khorasani under the MIT License.
Give a β if you like this project!