Update README.md
Browse files
README.md
CHANGED
|
@@ -1,51 +1,5 @@
|
|
| 1 |
-
# Hugging Face Space Pinger Bot ๐
|
| 2 |
-
|
| 3 |
-
A Telegram bot built with **Pyrogram** and **FastAPI** to keep Hugging Face spaces alive by pinging them sequentially every 5 minutes. The database containing authorized users, admins, and space URLs is automatically created and synced to a Hugging Face dataset for persistent storage.
|
| 4 |
-
|
| 5 |
-
## ๐ ๏ธ Required Secret Environment Variables
|
| 6 |
-
|
| 7 |
-
When deploying this bot on Hugging Face Spaces (or any Docker platform), you **MUST** configure the following variables in the Space settings (under **Variables and Secrets**):
|
| 8 |
-
|
| 9 |
-
1. **`API_ID`**: The API ID for your Telegram application (get it from [my.telegram.org](https://my.telegram.org)).
|
| 10 |
-
2. **`API_HASH`**: The API Hash for your Telegram application (get it from [my.telegram.org](https://my.telegram.org)).
|
| 11 |
-
3. **`BOT_TOKEN`**: The Telegram Bot Token generated by [@BotFather](https://t.me/BotFather).
|
| 12 |
-
4. **`ADMIN_ID`**: The numeric Telegram ID of the **Super Admin** (e.g., `123456789`). The Super Admin has highest authority (e.g., can remove admins).
|
| 13 |
-
5. **`HF_TOKEN`**: A Hugging Face User Access Token with **WRITE** permissions (generate it under your Hugging Face account settings at [huggingface.co/settings/tokens](https://huggingface.co/settings/tokens)).
|
| 14 |
-
6. **`HF_DATASET_URL`**: The full URL of your Hugging Face dataset repository (e.g. `https://huggingface.co/datasets/your_username/your_dataset_name` or simply the repository ID like `your_username/your_dataset_name`). The bot will automatically create this dataset if it doesn't already exist and maintain `database.json` within it.
|
| 15 |
-
|
| 16 |
---
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
- `/id` - View your Telegram User ID (used to request authorization).
|
| 22 |
-
- `/start` - Displays a simple welcome message.
|
| 23 |
-
- `/help` - Explains what the bot does.
|
| 24 |
-
- `/commands` - List commands matching the caller's authorization level.
|
| 25 |
-
|
| 26 |
-
### ๐ค Authorized User Commands
|
| 27 |
-
- `/add <hf_url>` - Register a Hugging Face Space URL. (You can also just send a raw Hugging Face URL directly, and the bot will normalize and register it automatically).
|
| 28 |
-
- `/remove <hf_url>` - Remove a Space URL you registered.
|
| 29 |
-
- `/list_url` - List the Space URLs that *you* registered.
|
| 30 |
-
|
| 31 |
-
### ๐ฎ Admin Commands
|
| 32 |
-
- `/add_user <user_id>` - Authorize a user to register and manage their own URLs.
|
| 33 |
-
- `/remove_user <user_id>` - Deauthorize a user.
|
| 34 |
-
- `/add_admin <user_id>` - Promote a user to Admin.
|
| 35 |
-
- `/list_url` - List **ALL** registered Space URLs in the system along with who registered them.
|
| 36 |
-
- `/list` - List all Admins and Users (excluding the Super Admin).
|
| 37 |
-
|
| 38 |
-
### ๐ Super Admin Commands
|
| 39 |
-
- `/remove_admin <user_id>` - Demote an Admin back to a regular user.
|
| 40 |
-
- `/list` - List the Super Admin, all Admins, and all Users.
|
| 41 |
-
|
| 42 |
-
---
|
| 43 |
-
|
| 44 |
-
## ๐ณ Deployment to Hugging Face Spaces
|
| 45 |
-
|
| 46 |
-
1. Create a new Space on Hugging Face: [huggingface.co/new-space](https://huggingface.co/new-space).
|
| 47 |
-
2. Choose **Docker** as the SDK.
|
| 48 |
-
3. Select **Blank** (or any Docker template).
|
| 49 |
-
4. Go to the Space **Settings** page and add the **Secrets** listed above.
|
| 50 |
-
5. Push the repository files (`Dockerfile`, `requirements.txt`, `config.py`, `database.py`, `main.py`) to the Space.
|
| 51 |
-
6. The space will automatically build the Docker image, run the FastAPI web server on port `7860`, launch the Telegram bot, and begin the sequential 5-minute pinger loop.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
sdk: docker
|
| 4 |
+
emoji: ๐
|
| 5 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|