Chess-Web / lichess-bot /start_bot.py
dpv007's picture
Upload folder using huggingface_hub
c2e3a29 verified
Raw
History Blame Contribute Delete
1.09 kB
import os
import yaml
def main():
print("Reading config.yml...")
with open("config.yml", "r") as f:
config = yaml.safe_load(f)
# Inject Lichess Token from Hugging Face Secrets
token = os.environ.get("LICHESS_TOKEN")
if not token:
print("===============================================================")
print("WARNING: LICHESS_TOKEN Secret is NOT SET in Hugging Face Space!")
print("Please go to Space Settings -> Variables and secrets to add it.")
print("===============================================================")
# We don't crash, let lichess-bot crash gracefully so the space stays alive (web UI still works)
else:
print("Successfully found LICHESS_TOKEN secret!")
config["token"] = token
with open("config.yml", "w") as f:
yaml.dump(config, f)
print("Upgrading account to bot status just in case...")
os.system("python3 lichess-bot.py -u")
print("Executing lichess-bot...")
os.system("python3 lichess-bot.py")
if __name__ == "__main__":
main()