Optimization code
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import requests
|
||||
|
||||
|
||||
def advertise():
|
||||
ad_content = ""
|
||||
try:
|
||||
ad_url = "https://raw.githubusercontent.com/NianBroken/ZFCheckScores/main/data/advertise.txt"
|
||||
# 发送HTTP GET请求获取内容
|
||||
response = requests.get(ad_url)
|
||||
# 检查请求是否成功
|
||||
if response.status_code == 200:
|
||||
# 输出内容
|
||||
ad_content = f"{response.text}\n------"
|
||||
return ad_content
|
||||
except Exception:
|
||||
return ad_content
|
||||
@@ -1,10 +1,12 @@
|
||||
import requests
|
||||
import json
|
||||
import re
|
||||
from scripts.ad import advertise
|
||||
|
||||
|
||||
def send_message(token, title, content):
|
||||
url = f"https://push.showdoc.com.cn/server/api/push/{token}"
|
||||
content = advertise() + content
|
||||
pattern = re.compile(r"^.*教学班ID.*$\n?", re.MULTILINE)
|
||||
content = re.sub(pattern, "", content).strip()
|
||||
replacements = {
|
||||
@@ -14,6 +16,7 @@ def send_message(token, title, content):
|
||||
"未公布成绩的课程:": "<h1>未公布成绩的课程</h1>\n",
|
||||
"异常的课程:": "<h1>异常的课程</h1>\n",
|
||||
"工作流信息:": "<h1>工作流信息</h1>\n",
|
||||
"Copyright © 2024 NianBroken. All rights reserved.": "Copyright © 2024 <a href='https://www.nianbroken.top/' target='_blank'>NianBroken</a>. All rights reserved.",
|
||||
}
|
||||
for old, new in replacements.items():
|
||||
content = content.replace(old, new)
|
||||
|
||||
Reference in New Issue
Block a user