{"id":13589451,"url":"https://github.com/PheeZz/wireguard-bot","last_synced_at":"2025-04-08T09:32:52.812Z","repository":{"id":74522047,"uuid":"586487023","full_name":"PheeZz/wireguard-bot","owner":"PheeZz","description":"telegram bot for manage Wireguard server","archived":true,"fork":false,"pushed_at":"2024-09-13T21:18:24.000Z","size":304,"stargazers_count":83,"open_issues_count":1,"forks_count":20,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-06T09:39:43.050Z","etag":null,"topics":["adguard","aiogram2","postgresql","telegram-bot","wireguard"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PheeZz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-08T10:21:21.000Z","updated_at":"2024-10-15T05:55:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"9368ca46-ec2f-4499-b60e-ae0391f75697","html_url":"https://github.com/PheeZz/wireguard-bot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PheeZz%2Fwireguard-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PheeZz%2Fwireguard-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PheeZz%2Fwireguard-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PheeZz%2Fwireguard-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PheeZz","download_url":"https://codeload.github.com/PheeZz/wireguard-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247814215,"owners_count":21000522,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adguard","aiogram2","postgresql","telegram-bot","wireguard"],"created_at":"2024-08-01T16:00:30.323Z","updated_at":"2025-04-08T09:32:52.349Z","avatar_url":"https://github.com/PheeZz.png","language":"Python","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"\u003ch1 align=\"center\"\u003ePheeZz's Wireguard Bot\u003c/h1\u003e\r\n\u003cp align=\"center\"\u003e\r\n\u003cimg src = \"https://github.com/PheeZz/wireguard-bot/blob/master/image/logo_wide.png?raw=true\" width = 50%\u003e\r\n\u003c/p\u003e\r\n\r\n\u003cdiv align=\"center\"\u003e\r\n\r\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\r\n[![Packaged with Poetry](https://img.shields.io/badge/packaging-poetry-cyan.svg)](https://python-poetry.org/)\u003cbr\u003e\r\n[![!Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?style=for-the-badge\u0026logo=ubuntu\u0026logoColor=white)](https://ubuntu.com/)\r\n[![!Debian](https://img.shields.io/badge/Debian-A81D33?style=for-the-badge\u0026logo=debian\u0026logoColor=white)](https://www.debian.org/)\r\n[![!Python](https://img.shields.io/badge/Python-3776AB?style=for-the-badge\u0026logo=python\u0026logoColor=white)](https://www.python.org/)\r\n[![!PostgreSQL](https://img.shields.io/badge/PostgreSQL-4169E1?style=for-the-badge\u0026logo=postgresql\u0026logoColor=white)](https://www.postgresql.org/)\r\n[![!Wireguard](https://img.shields.io/badge/Wireguard-88171A?style=for-the-badge\u0026logo=wireguard\u0026logoColor=white)](https://www.wireguard.com/)\r\n[![!AdGuard](https://img.shields.io/badge/AdGuard-00A6D6?style=for-the-badge\u0026logo=adguard\u0026logoColor=white)](https://adguard.com/)\r\n[![!Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge\u0026logo=telegram\u0026logoColor=white)](https://telegram.org/)\r\n\r\n\u003c/div\u003e\r\n\r\n## Contents tree:\r\n\r\n1. [Description](#description)\r\n2. [Stack](#stack)\r\n3. [Before you start...](#before-you-start)\r\n4. [Setup guide](#setup)\r\n\r\n## ❗️Attention: project unmaintained. Please do not use it to bypass your country blocks.\r\n\r\n## Description\r\n\r\nThis bot is designed to manage Wireguard VPN server. It can automatically connect and disconnect users, generate QR codes for mobile clients, and also can be used as a payment system for VPN services.\r\n\r\n## Stack\r\n\r\nCore: python 3.10, aiogram 2.x\u003cbr/\u003e\r\nDatabase: postgresql\u003cbr/\u003e\r\n\r\n## Before you start... (if don't want to use semi-automatic installation script)\r\n\r\n1. You need to manually install Wireguard on your server. You can find installation guide [here](https://www.wireguard.com/install/).\r\n2. You need to configure Wireguard server. You can find configuration guide [here (RUS)](https://t.me/t0digital/32).\r\n3. You need to create a bot using [BotFather](https://t.me/BotFather).\r\n4. You need to install [PostgreSQL](https://www.postgresql.org/download/).\r\n5. You need to have poetry installed on your system. You can find installation guide [here](https://python-poetry.org/docs/#installation).\r\n\r\n## Setup\r\n\r\n1. You can use semi-automatic installation script or manual installation guide. If you want to use script, just run it and follow the instructions. If you want to install bot manually, follow the instructions below.\r\n   ### Semi-automatic installation script\r\n   ```bash\r\n   wget https://raw.githubusercontent.com/PheeZz/wireguard-bot/master/SemiAutoInstall.sh \u0026\u0026 chmod +x SemiAutoInstall.sh \u0026\u0026 ./SemiAutoInstall.sh\r\n   ```\r\n### Manual installation guide\r\n2. #### Clone this repo and go to project folder\u003cbr/\u003e\r\n\r\n   ```bash\r\n   git clone https://github.com/PheeZz/wireguard-bot.git \u0026\u0026 cd wireguard-bot\r\n   ```\r\n\r\n3. #### Create your virtualenv inside project dir\u003cbr/\u003e\r\n\r\n   ```bash\r\n   poetry shell\r\n   ```\r\n\r\n4. #### Download required libs\u003cbr/\u003e\r\n\r\n   ```bash\r\n   poetry install\r\n   ```\r\n\r\n5. #### Create your database\u003cbr/\u003e\r\n\r\n   ```bash\r\n   sudo -u postgres psql\r\n   ```\r\n\r\n   ```sql\r\n   CREATE DATABASE \u003cdatabase_name\u003e;\r\n   CREATE USER \u003cuser_name\u003e WITH PASSWORD '\u003cpassword\u003e';\r\n   GRANT ALL PRIVILEGES ON DATABASE \u003cdatabase_name\u003e TO \u003cuser_name\u003e;\r\n   GRANT ALL ON ALL TABLES IN SCHEMA \"public\" TO \u003cuser_name\u003e;\r\n   \\q\r\n   ```\r\n\r\n6. #### Create .env file in data folder and fill it with your data. You can use following example as a template or use .env.sample file (it's the same)\u003cbr/\u003e\r\n\r\n   ```bash\r\n   cp data/.env.sample data/.env\r\n   nano data/.env\r\n   ```\r\n\r\n   #### .env file example\r\n\r\n   ```ini\r\n   #telegram bot token\r\n   WG_BOT_TOKEN = \u003cstr\u003e\r\n   #ip of your wireguard server\r\n   WG_SERVER_IP = \u003cstr\u003e\r\n   #port of your wireguard server\r\n   WG_SERVER_PORT = '51830'\r\n   #server's public key\r\n   WG_SERVER_PUBLIC_KEY = \u003cstr\u003e\r\n   #server's preshared key\r\n   WG_SERVER_PRESHARED_KEY= \u003cstr\u003e\r\n   #path to wireguard config file, default /etc/wireguard/wg0.conf\r\n   WG_CFG_PATH = '/etc/wireguard/wg0.conf'\r\n   #token for telegram invoice payments, if you don't use payments, just leave it empty (NOW IT'S NOT WORKING)\r\n   PAYMENTS_TOKEN = \u003cstr\u003e\r\n   #your telegram id, you can get it from @userinfobot or @myidbot or @RawDataBot\r\n   ADMINS_IDS = \u003cstr\u003e\r\n   #your bank card number, if you will use payments with \"handmade\" method\r\n   PAYMENT_CARD = \u003cstr\u003e\r\n   #any text you want to show in the start of every peer config file (for example in case MYVPN_pheezz_PC.conf - \"MYVPN\" is prefix)\r\n   CONFIGS_PREFIX = \u003cstr\u003e\r\n   #how much subscription costs in rubles\r\n   BASE_SUBSCRIPTION_MONTHLY_PRICE_RUBLES = \u003cint\u003e\r\n   #dns server for your peers, default 1.1.1.1 if you don't use AdGuard Home, else 10.0.0.1\r\n   PEER_DNS = '1.1.1.1'\r\n\r\n   #name of your database\r\n   DATABASE = \u003cstr\u003e\r\n   #database user\r\n   DB_USER = \u003cstr\u003e\r\n   #database user's password\r\n   DB_USER_PASSWORD = \u003cstr\u003e\r\n   #database host, default localhost\r\n   DB_HOST = 'localhost'\r\n   #database port, default 5432\r\n   DB_PORT = '5432'\r\n   ```\r\n\r\n7. #### Configure your database tables\u003cbr/\u003e\r\n   Move create script from database/create.py to project root folder and run it\r\n\r\n   ```bash\r\n   mv database/create.py . \u0026\u0026 python3.10 create.py\r\n   ```\r\n\r\n   Now you can delete create.py file\u003c/br\u003e\r\n\r\n   ```bash\r\n   rm create.py\r\n   ```\r\n8. #### Install AdGuard Home (optional)\u003c/br\u003e\r\n   Firtly make installation script executable\u003c/br\u003e\r\n\r\n   ```bash\r\n   chmod +x AdGuardInstall.sh\r\n   ```\r\n\r\n   Then run it\u003c/br\u003e\r\n\r\n   ```bash\r\n   ./AdGuardInstall.sh\r\n   ```\r\n9.  #### Configure AddGuard Home\u003c/br\u003e\r\n      Open AddGuard Home web interface on url ```\u003cyour_server_ip\u003e:3000```\u003c/br\u003e\r\n      Do the initial setup, it's very simple, just follow the instructions and create admin account\u003c/br\u003e\r\n      Go to Settings -\u003e Filters -\u003e DNS blocklists and add some blocklists (I recommend to use add all available blocklists EXCEPT `No Google` list)\u003c/br\u003e\r\n\r\n10. #### Create .service file for your bot\u003c/br\u003e\r\n      Path: `/etc/systemd/system/wireguard-bot.service` \u003c/br\u003e\r\n      Code: (if you using python 3.10)\u003c/br\u003e\r\n   \r\n      ```ini\r\n       [Unit]\r\n       Description='Service for wireguard bot'\r\n       After=network.target\r\n   \r\n       [Service]\r\n       Type=idle\r\n       Restart=on-failure\r\n       User=root\r\n       ExecStart=/bin/bash -c 'cd ~/wireguard-bot/ \u0026\u0026 $(poetry env info --path)/bin/python3.10 app.py'\r\n   \r\n       [Install]\r\n       WantedBy=multi-user.target\r\n      ```\r\n11. Enable service and start it\u003c/br\u003e\r\n      ```bash\r\n      systemctl enable wireguard-bot.service\r\n      systemctl start wireguard-bot.service\r\n      ```\r\n\r\n12. Finally, you can use your bot and enjoy it ❤️\r\n\r\n## Extra\r\n\r\n### Admin commands (available in chat with bot)\r\n\r\n1. `/give \u003cuser_id\u003e \u003cdays\u003e` - give user access to VPN for \\\u003cdays\u003e days.\u003cbr/\u003e\r\n   Also you can use this command with \\\u003c@username\u003e instead of \\\u003cuser_id\u003e.\u003cbr/\u003e\r\n   If you want to disable user's access, just use `/give \u003cuser_id\u003e -9999` or any negative number that will be higher than user's access expiration date.\u003cbr/\u003e\r\n   \u003cb\u003eWARNING:\u003c/b\u003e disconnecting user will not remove his access from database, so you can give him access again later.\u003cbr/\u003e\r\n   Example: `/give 123456789 30` - give user with id 123456789 access to VPN for 30 days.\r\n2. `/stats` - show stats about users and their access expiration dates.\u003cbr/\u003e\r\n   Aviable options: `/stats active` - show active users.\u003cbr/\u003e\r\n   `/stats inactive` - show inactive users.\u003cbr/\u003e\r\n   `/stats` without options will show all users.\u003cbr/\u003e\r\n   `/wgrestart` - restart wireguard service\r\n\r\n\r\n\r\n## Star History\r\n\r\n[![Star History Chart](https://api.star-history.com/svg?repos=PheeZz/wireguard-bot\u0026type=Date)](https://star-history.com/#PheeZz/wireguard-bot\u0026Date)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPheeZz%2Fwireguard-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPheeZz%2Fwireguard-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPheeZz%2Fwireguard-bot/lists"}