base on Cloudflare Woker Bot ! No servers needed, just pure Xray link creation, all running smoothly on PythonAnywhere. a Shortcut to internet freedom! ✨" [فارسی](https://github.com/2ri4eUI/CFW-BOT/blob/main/README-FA.md) [ENGLISH](https://github.com/2ri4eUI/CFW-BOT/blob/main/README.md) # CFW-BOT V0.04 Cloudflare Woker Bot ! No servers needed, just pure Xray link creation, all running smoothly on PythonAnywhere. a Shortcut to internet freedom! ✨" ![image](https://github.com/2ri4eUI/CFW-BOT/assets/139592104/8db90fe5-dd6e-4015-840e-5df58ff5f12e) ![image](https://github.com/2ri4eUI/CFW-BOT/assets/139592104/2512c617-b93a-48ac-a6a9-58bdd5fb67c6) # version 0.02 | What is new ? - it can create unique subscription worker link for each user that can use IP-API value - subscription can be updated just by changing the IP_API value - cloudflare webiste error solved # version 0.03 | What is NEW? - added proxies.txt , now you can create your favorite proxy list in bot - access to your favorite proxy while adding new user or changing users proxies - access to recently used proxies - redeploy your worker script with new proxy that you set - you can change all users proxies at once ! - no tls configurate added - bug fixed : now delete subscripton worker when you delete a user # version 0.04 |what is NEW? - added SingBox Subscription Link - added Cloudflare page redirect - added Wiki - every thing you need to know about the bot ! - added button that show current subdomain of worker and button to change that in cloudflare - added CF Proxy button, which show content of Proxies.txt as button when creating a user or changing user proxy - added redeploy option for users, which can upload your worker with new proxy. - minor bug fix ## Table of Contents - [What is this ?](#what-is-this-) - [Features](#features) - [Prerequisites](#prerequisites) - [LAZY INSTALL](#lazy-install) - [ADVANCE INSTALL](#advanced-install) - [How To Use the Bot](#how-to-use-the-bot) - [Note](#note) - [Disclaimer](#disclaimer) # What is this ? This Python Telegram bot, powered by Cloudflare's Workers, makes generating Xray links a breeze! No need for complex server setups, just follow these simple steps to get started: ## Features - **Easy Setup**: No server configurations required. With Cloudflare's Workers, deploying the bot is a breeze. - **Persistent Storage**: Utilizes SQLite for database management, ensuring that your user data and generated links are securely stored. - **User Management**: Create and manage multiple users with ease. Each user has access to their generated links at all times. - **Efficient Deployment**: Leveraging Wrangler, the bot's worker script can be easily deployed on Cloudflare, ensuring reliability and scalability. ## Prerequisites - One domain registered on Cloudflare - Access to Cloudflare account - Telegram Bot token (available from Telegram's BotFather) - Cloudflare API key (generate one from Cloudflare dashboard) - Account ID of your Cloudflare account - User ID of the Telegram account you want to use the bot on (for authentication) - ## Single Command install | v0.04 i will release the final version soon! just copy and run and send tokens when it ask for them : ```bash bash -c "$(curl -fsSL https://raw.githubusercontent.com/2ri4eUI/CFW-BOT/main/install.sh)" ``` ![image](https://github.com/2ri4eUI/CFW-BOT/assets/139592104/36852bd8-1d49-4fed-8c4f-5e028f5ae9c0) ## Ubuntu if you want to run bot in background on Ubuntu you can use a systemd setup: 1. you can install bot manually or you can use single command line instalation. 2. terminate bot if its running using ctrl+c (hold it) 3. create a systemd file by this command: ```bash sudo nano /etc/systemd/system/cfwbot.service ``` 4. copy paste this systemd configuartion. CHANGE WorkingDirectory if your bot path is diffrent, if your user is differnt change that as well.CTRL+X and ENTER to save. ```bash [Unit] Description=CFW-BOT After=network.target [Service] User=root WorkingDirectory=/root/CFW-BOT/ ExecStart=/usr/bin/python3 cfw.py Restart=always [Install] WantedBy=multi-user.target ``` 5. Enable and Start Service ```bash sudo systemctl enable cfwbot sudo systemctl start cfwbot sudo systemctl status cfwbot ``` ## LAZY INSTALL 1. Register for a free account on [PythonAnywhere](https://www.pythonanywhere.com). 2. Obtain the required API keys: - Telegram Bot token from BotFather - Cloudflare API key from Cloudflare dashboard (make sure to select "Edit Cloudflare Workers template" and grant necessary permissions, all of them should have EDIT permission) - Telegram UserID you can obtain it from here https://t.me/useridinfobot or any similar bot you know - Cloudflare Account id, you can find it from right side of overview page or worker page in cloudflare 4. in your Dashboard section Select Files and and Click on "Open Bash Console Here" 5. Clone this repository: ```bash git clone https://github.com/2ri4eUI/CFW-BOT.git ``` 6. Navigate to the project directory: ```bash cd CFW-BOT ``` 7. Make `requirement.sh` executable: ```bash chmod +x requirement.sh ``` 8. Run `requirement.sh`: ```bash ./requirement.sh ``` "If you encounter errors running requirement.sh on PythonAnywhere , simply close the console (using `exit` command) , go to file manager and open it and save it (use `ctrl+s` ) without changing any thing. thats it! now you can run it" another solution is converting it using dos2unix since PythonAnyWhere does not support that you can use this simple python code 'dos2unix.py' you can run this to solve the issue: ```bash python3 dos2unix.py ``` 10. Run `install.py` and provide the required API tokens when prompted: ```bash python3 install.py ``` 11. Start the bot: ```bash python3 cfw.py ``` ## ADVANCED INSTALL 1. install requirements: ```bash pip install telebot pip install pytelegrambotapi --upgrade pip install qrcode[pil] pip install requests pip install python-dotenv ``` 2. install NVM ```bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash ``` 3. set nvm settings ``` bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads NVM [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads NVM bash completion ``` 4. start nvm and install wrangler ```bash nvm install 16.17.0 nvm use 16.17.0 npm install wrangler@latest npx wrangler --version ``` 5. set .env file variables | Variable | Description | |----------------------|--------------------------------------------------------| | CLOUDFLARE_API_TOKEN | Cloudflare API token with Worker edit permission | | BOT_TOKEN | Telegram bot token obtained from BotFather | | ACCOUNT_ID | Cloudflare account ID | | ADMIN_USER_ID | Numeric Telegram user ID for admin authentication | | IP_API | use this as refrence https://raw.githubusercontent.com/2ri4eUI/CFW_Worker_Sub/main/ips.txt| 6.remember to set cloudflare account id in workertemp.txt ## How To Use the Bot Once the bot is running, simply send the necessary commands to generate Xray links right from your Telegram app! Creating a new user is a straightforward process. Follow these steps to get started: **Obtain Cloudflare IP or Domain:** - Use platforms like [fofa.info](https://fofa.info) to find Cloudflare IP addresses or domains. - Example search query for fofa.info: ```bash server=="cloudflare" && port=="443" && country=="NL" && city=="Amsterdam" ``` - Choose based on your preferences and network speed. ## Note This bot is designed to be lightweight and inexpensive to run, making it accessible for everyone. Enjoy creating Xray links hassle-free! ## Disclaimer I want to acknowledge the work of others and clarify that the `index.js` and `subworker.js` file is not my original work. It has been edited solely to ensure compatibility with the bot. ## HUGE THANKS TO https://github.com/cmliu for creating these workers This project is just the beginning, and there is potential for it to evolve further. The extent to which it progresses depends on how much it is liked and used. Your feedback and contributions are appreciated! ", Assign "at most 3 tags" to the expected json: {"id":"8922","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"