因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
+1 -1
View File
@@ -147,7 +147,7 @@ jobs:
# 组合协议、匿名化后的域名和路径,输出结果
echo "${protocol}${anonymized_domain}${path}"
}
LOGINURL="/xtgl/login_slogin.html"
LOGINURL="xtgl/login_slogin.html"
FULLURL="${URL}${LOGINURL}"
# 方便通过截图快速定位到用户
+6 -7
View File
@@ -53,12 +53,12 @@
> Name = NameSecret = 例子
| Name | 例子 | 说明 |
| -------- | --------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| URL | https://www.nianbroken.top/ | 教务系统地址 |
| USERNAME | 2971802058 | 教务系统用户名 |
| PASSWORD | Y3xhaCkb5PZ4 | 教务系统密码 |
| TOKEN | J65KWMBfyDh3YPLpcvm8 | [PushPlus 的 token](https://www.pushplus.plus/doc/guide/openApi.html#_1-%E8%8E%B7%E5%8F%96token "PushPlus 的 token") |
| Name | 例子 | 说明 |
| -------- | --------------------------- | ------------------------------------------------------------------------- |
| URL | https://www.nianbroken.top/ | 教务系统地址 |
| USERNAME | 2971802058 | 教务系统用户名 |
| PASSWORD | Y3xhaCkb5PZ4 | 教务系统密码 |
| TOKEN | J65KWMBfyDh3YPLpcvm8 | [Showdoc 的 token](https://push.showdoc.com.cn/#/push "Showdoc 的 token") |
### 4. 开启 Actions
@@ -101,4 +101,3 @@ _若是第一次运行程序,上述步骤会执行两遍_
## 其他
欢迎提交 `Issues``Pull requests`
+82 -33
View File
@@ -15,6 +15,10 @@
</tr>
</table>
<p>1. <a href="https://github.com/NianBroken/ZFCheckScores/fork">点击 Fork</a></p>
<p>2. 点击 Create fork</p>
## 2. 开启工作流读写权限
<table>
@@ -31,16 +35,28 @@
</tr>
</table>
<p>1. 点击 Settings</p>
<p>2. 点击 Actions</p>
<p>3. 点击 General</p>
<p>4. 找到 Workflow permissions</p>
<p>5. 点击 Read and write permissions</p>
<p>6. 点击 Save</p>
## 3. 添加 Secrets
> Name = NameSecret = 例子
| Name | 例子 | 说明 |
| -------- | --------------------------- | ---------------------------------------------------- |
| URL | https://www.nianbroken.top/ | 教务系统地址 |
| USERNAME | 2971802058 | 教务系统用户名 |
| PASSWORD | Y3xhaCkb5PZ4 | 教务系统密码 |
| TOKEN | J65KWMBfyDh3YPLpcvm8 | [PushPlus 的 token](#获取-token "PushPlus 的 token") |
| Name | 例子 | 说明 |
| -------- | --------------------------- | -------------------------------------------------- |
| URL | https://www.nianbroken.top/ | 教务系统地址 |
| USERNAME | 2971802058 | 教务系统用户名 |
| PASSWORD | Y3xhaCkb5PZ4 | 教务系统密码 |
| TOKEN | J65KWMBfyDh3YPLpcvm8 | [Showdoc 的 token](#获取-token "Showdoc 的 token") |
<table>
<tr>
@@ -56,45 +72,49 @@
</tr>
</table>
<p>1. 点击 Settings</p>
<p>2. 点击 Secrets and variables</p>
<p>3. 点击 Actions</p>
<p>4. 点击 Secrets 选项卡</p>
<p>5. 找到 Repository secrets</p>
<p>6. 点击 New repository secret</p>
<p>7. 根据上面的表格填写正确的 Name 以及 Secret</p>
<p>8. 点击 Add secret</p>
### 获取 TOKEN
<p>1. <a href="https://www.pushplus.plus/login.html">登录 PushPlus </a></p>
<p>1. <a href="https://push.showdoc.com.cn/#/push">登录 Showdoc 推送服务</a></p>
<img src="https://raw.githubusercontent.com/NianBroken/ZFCheckScores/main/img/18.png" width="60%" />
<p>2. 使用微信扫码关注公众号</p>
<p>2. <a href="https://www.pushplus.plus/api/open/user/token">获取 Token</a></p>
打开“获取 Token”的页面后,你会得到一个与下列所示几乎一致的 Json 代码块,`data`中的值就是 TOKEN
```json
{
"code": 200,
"msg": "请求成功",
"data": "cd735c356aa14d16b1452aa932ac89cc",
"count": null
}
```
当你的 Secrets 添加完成后,你的页面应该与下图所示的页面完全一致或几乎一致
<img src="https://raw.githubusercontent.com/NianBroken/ZFCheckScores/main/img/19.png" width="60%"/>
<p>3. <a href="https://www.pushplus.plus/doc/guide/openApi.html#_1-%E8%8E%B7%E5%8F%96token">相关文档</a></p>
## 4. 开启 Actions
<p>3. 红框内的字符就是token</p>
<table>
<tr>
<td>
<img src="https://raw.githubusercontent.com/NianBroken/ZFCheckScores/main/img/20.png" />
<img src="https://raw.githubusercontent.com/NianBroken/ZFCheckScores/main/img/18.png" />
</td>
<td>
<img src="https://raw.githubusercontent.com/NianBroken/ZFCheckScores/main/img/21.png" />
<img src="https://raw.githubusercontent.com/NianBroken/ZFCheckScores/main/img/19.png" />
</td>
<td>
<img src="https://raw.githubusercontent.com/NianBroken/ZFCheckScores/main/img/20.png" />
</td>
</tr>
</table>
## 5. 运行程序
当你的 Secrets 添加完成后,你的页面应该与下图所示的页面完全一致或几乎一致
<img src="https://raw.githubusercontent.com/NianBroken/ZFCheckScores/main/img/21.png" width="60%"/>
## 4. 开启 Actions
<table>
<tr>
@@ -107,7 +127,15 @@
</tr>
</table>
## 6. 查看运行结果
<p>1. 点击 Actions</p>
<p>2. 点击 I understand my workflows, go ahead and enable them</p>
<p>3. 点击 CheckScores</p>
<p>4. 点击 Enable workflow</p>
## 5. 运行程序
<table>
<tr>
@@ -120,6 +148,27 @@
</tr>
</table>
<p>1. 点击 Actions</p>
<p>2. 点击 CheckScores</p>
<p>3. 点击 Run workflow</p>
<p>4. 再次点击 Run workflow</p>
## 6. 查看运行结果
<table>
<tr>
<td>
<img src="https://raw.githubusercontent.com/NianBroken/ZFCheckScores/main/img/26.png" />
</td>
<td>
<img src="https://raw.githubusercontent.com/NianBroken/ZFCheckScores/main/img/27.png" />
</td>
</tr>
</table>
当你的页面与上图所示的页面完全一致或几乎一致,则代表程序正常运行且未报错
在此之后,程序将会每隔 30 分钟自动检测一次成绩是否有更新
@@ -128,4 +177,4 @@
当检测到成绩更新时,你的页面应该与下图所示的页面完全一致或几乎一致
<img src="https://raw.githubusercontent.com/NianBroken/ZFCheckScores/main/img/26.png" width="60%" />
<img src="https://raw.githubusercontent.com/NianBroken/ZFCheckScores/main/img/8.png" width="60%" />
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 KiB

After

Width:  |  Height:  |  Size: 208 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 118 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1017 KiB

After

Width:  |  Height:  |  Size: 80 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

After

Width:  |  Height:  |  Size: 334 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 469 KiB

After

Width:  |  Height:  |  Size: 315 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 KiB

After

Width:  |  Height:  |  Size: 92 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 99 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

After

Width:  |  Height:  |  Size: 124 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 130 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 144 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 111 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 106 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 457 KiB

After

Width:  |  Height:  |  Size: 323 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 478 KiB

After

Width:  |  Height:  |  Size: 368 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 872 KiB

After

Width:  |  Height:  |  Size: 1.1 MiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 947 KiB

After

Width:  |  Height:  |  Size: 1.3 MiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 997 KiB

After

Width:  |  Height:  |  Size: 644 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 97 KiB

+1 -1
View File
@@ -7,7 +7,7 @@ from scripts.user_login import login
from scripts.get_user_info import get_user_info
from scripts.get_grade import get_grade
from scripts.get_selected_courses import get_selected_courses
from scripts.pushplus import send_message
from scripts.push import send_message
from datetime import datetime
+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