Commit 87e27cd8 authored by nanahira's avatar nanahira

add welcome updater

parent 0d056579
Pipeline #33681 failed with stages
in 1 minute and 2 seconds
...@@ -78,3 +78,15 @@ deploy_to_finale: ...@@ -78,3 +78,15 @@ deploy_to_finale:
SERVER_HOST: diyfree.momobako.com SERVER_HOST: diyfree.momobako.com
SERVER_USER: root SERVER_USER: root
SERVER_PATH: ~/ygopro-custom-free/expansions SERVER_PATH: ~/ygopro-custom-free/expansions
update_welcome:
stage: deploy
tags:
- linux
dependencies:
- check
script:
- python update-welcome.py
only:
- master
- tags
...@@ -13,6 +13,10 @@ ...@@ -13,6 +13,10 @@
- [ZIP 文件](https://cdn02.moecube.com/ygopro-custom-free/ygopro-custom-free.zip) - [ZIP 文件](https://cdn02.moecube.com/ygopro-custom-free/ygopro-custom-free.zip)
- 单独文件下载: `https://cdn02.moecube.com/ygopro-custom-free/contents/` - 单独文件下载: `https://cdn02.moecube.com/ygopro-custom-free/contents/`
ZIP 形式的整合包里面包含下面的额外文件:
- `version.txt`: 记录了整合日期,以便大家检查是不是最新的。
- `redtexts`: 记录了各仓库的红字信息,这些卡没有被整合。
## 上传卡片 ## 上传卡片
1. 制作自己的 DIY 卡仓库,放置在 GitHub 或者 MCGit 下。仓库需要包含: 1. 制作自己的 DIY 卡仓库,放置在 GitHub 或者 MCGit 下。仓库需要包含:
......
...@@ -98,4 +98,4 @@ for file in repos/*.txt; do ...@@ -98,4 +98,4 @@ for file in repos/*.txt; do
done done
echo "Finished processing all repos" echo "Finished processing all repos"
echo "Date: $(date)" > dist/version.txt echo "YGOPro Custom Free Server - Updated at $(date)" > dist/version.txt
import os
import requests
# 读取环境变量
USERNAME = os.environ.get("SRVPRO_USERNAME", "").strip()
PASSWORD = os.environ.get("SRVPRO_PASSWORD", "").strip()
# 读取 version.txt 内容
def get_version_content():
try:
with open("dist/version.txt", "r", encoding="utf-8") as file:
return file.read().strip()
except FileNotFoundError:
print("Error: version.txt not found!")
exit(1)
# 构造请求参数
def send_request():
url = "https://diyfree.momobako.com:11922/api/message"
params = {
"welcome": get_version_content(),
"username": USERNAME,
"pass": PASSWORD
}
try:
response = requests.get(url, params=params, timeout=10) # 10 秒超时
response.raise_for_status() # 如果状态码不是 200-299,则抛出异常
print("Response Status:", response.status_code)
print("Response Body:", response.text)
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
exit(1)
if __name__ == "__main__":
send_request()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment