Download config_manager.py from Brozy123/bot-config: direct link, hf CLI and curl.
- Browser
- Download file 901 Bytes
-
https://huggingface.co/datasets/Brozy123/bot-config/resolve/main/config_manager.py
- Command line
-
hf download hf://datasets/Brozy123/bot-config/config_manager.py
-
curl -L -o config_manager.py https://huggingface.co/datasets/Brozy123/bot-config/resolve/main/config_manager.py
901 Bytes
| import json | |
| import os | |
| from huggingface_hub import hf_hub_download, upload_file | |
| # CHANGE THIS TO YOUR USERNAME | |
| HF_USERNAME = "your_username_here" | |
| REPO_NAME = "bot-config" | |
| CONFIG_FILE = "lineup_access.json" | |
| def load_config(): | |
| """Load roles from cloud""" | |
| try: | |
| file_path = hf_hub_download( | |
| repo_id=f"{HF_USERNAME}/{REPO_NAME}", | |
| filename=CONFIG_FILE, | |
| repo_type="dataset" | |
| ) | |
| with open(file_path) as f: | |
| return json.load(f) | |
| except: | |
| return {} # Return empty if first time | |
| def save_config(data): | |
| """Save roles to cloud""" | |
| # Save locally | |
| with open(CONFIG_FILE, "w") as f: | |
| json.dump(data, f, indent=2) | |
| # Upload to cloud | |
| upload_file( | |
| path_or_fileobj=CONFIG_FILE, | |
| path_in_repo=CONFIG_FILE, | |
| repo_id=f"{HF_USERNAME}/{REPO_NAME}", | |
| repo_type="dataset" | |
| ) |