因PushPlus推送服务在近期增加了:敏感词屏蔽、不实名就无法使用、实名需要收费等等严重影响用户体验的功能,所以本项目后续将使用Showdoc推送服务。

This commit is contained in:
NianBroken
2024-07-25 00:02:28 +08:00 Unverified
parent a03747b00d
commit 0a8b883b2e
28 changed files with 132 additions and 64 deletions
+2 -1
View File
@@ -61,7 +61,8 @@ class GitHubActionsManager:
break
def log(self, message):
current_time_str = datetime.now().strftime("%Y-%m-%d %H:%M:%S:%f")[:-3] # 获取当前时间,精确到三位毫秒
beijing_time = datetime.now(timezone.utc).astimezone(timezone(timedelta(hours=8))) # 获取北京时间
current_time_str = beijing_time.strftime("%Y-%m-%d %H:%M:%S:%f")[:-3] # 获取当前时间,精确到三位毫秒
print(f"{current_time_str} {message}") # 打印日志消息
+13 -2
View File
@@ -28,7 +28,9 @@ def get_grade(student_client, output_type="none"):
total_xfjd = sum(float(course["xfjd"]) for course in grade)
# (百分制成绩*学分)的总和
sum_of_percentage_grades_multiplied_by_credits = sum(float(course["percentage_grades"]) * float(course["credit"]) for course in grade)
sum_of_percentage_grades_multiplied_by_credits = sum(
float(course["percentage_grades"]) * float(course["credit"]) for course in grade
)
# GPA计算 (学分*绩点)的总和/学分总和
gpa = "{:.2f}".format(total_xfjd / total_credit)
@@ -49,7 +51,16 @@ def get_grade(student_client, output_type="none"):
score_grades = f"{course['grade']} ({course['percentage_grades']})"
# 整合成绩信息
integrated_grade_info += f"\n" f"教学班ID{course['class_id']}\n" f"课程名称:{course['title']}\n" f"任课教师:{course['teacher']}\n" f"成绩:{score_grades}\n" f"提交时间:{course['submission_time']}\n" f"提交人姓名:{course['name_of_submitter']}\n" f"------"
integrated_grade_info += (
f"\n"
f"教学班ID{course['class_id']}\n"
f"课程名称:{course['title']}\n"
f"任课教师:{course['teacher']}\n"
f"成绩:{score_grades}\n"
f"提交时间:{course['submission_time']}\n"
f"提交人姓名:{course['name_of_submitter']}\n"
f"------"
)
if output_type == "grade":
return grade
+27
View File
@@ -0,0 +1,27 @@
import requests
import json
import re
def send_message(token, title, content):
url = f"https://push.showdoc.com.cn/server/api/push/{token}"
pattern = re.compile(r"^.*教学班ID.*$\n?", re.MULTILINE)
content = re.sub(pattern, "", content).strip()
replacements = {
"------": "\n------\n",
"个人信息:": "<h1>个人信息</h1>\n",
"成绩信息:": "<h1>成绩信息</h1>\n",
"未公布成绩的课程:": "<h1>未公布成绩的课程</h1>\n",
"异常的课程:": "<h1>异常的课程</h1>\n",
"工作流信息:": "<h1>工作流信息</h1>\n",
}
for old, new in replacements.items():
content = content.replace(old, new)
data = {"title": title, "content": content}
body = json.dumps(data).encode(encoding="utf-8")
headers = {"Content-Type": "application/json"}
response = requests.post(url, data=body, headers=headers)
# 解析 JSON 数据
response_dict = json.loads(response.text)
return response_dict
-17
View File
@@ -1,17 +0,0 @@
import requests
import json
def send_message(token, title, content):
url = "http://www.pushplus.plus/send"
data = {"token": token, "title": title, "content": content}
body = json.dumps(data).encode(encoding="utf-8")
headers = {"Content-Type": "application/json"}
response = requests.post(url, data=body, headers=headers)
# 解析 JSON 数据
response_dict = json.loads(response.text)
# 删除 "data" 字段
if "data" in response_dict:
response_dict.pop("data")
return response_dict
-2
View File
@@ -1,5 +1,3 @@
import base64
import os
import sys
from pprint import pprint
from .zfn_api import Client