Download app.py from Dragdev/Chatgpt: direct link, hf CLI and curl.
- Browser
- Download file 964 Bytes
-
https://huggingface.co/spaces/Dragdev/Chatgpt/resolve/main/app.py
- Command line
-
hf download hf://spaces/Dragdev/Chatgpt/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Dragdev/Chatgpt/resolve/main/app.py
964 Bytes
| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| import re | |
| app = FastAPI() | |
| class CommandInput(BaseModel): | |
| message: str | |
| user_id: int # the person who sent the command | |
| chat_id: int # the chat where the command was used | |
| def handle_command(data: CommandInput): | |
| message = data.message.strip().lower() | |
| response = "Unknown command." | |
| if message.startswith("/ban"): | |
| match = re.search(r"@?(\w+)", message) | |
| if match: | |
| target = match.group(1) | |
| response = f"User @{target} has been banned in chat {data.chat_id}." | |
| elif message.startswith("/mute"): | |
| match = re.search(r"@?(\w+)", message) | |
| if match: | |
| target = match.group(1) | |
| response = f"User @{target} has been muted in chat {data.chat_id}." | |
| elif message.startswith("/help"): | |
| response = "Available commands: /ban @user, /mute @user, /help" | |
| return {"response": response} |