Skip to content

Commit

Permalink
2022.1.27
Browse files Browse the repository at this point in the history
更新信息请看ReadMe
  • Loading branch information
XYZliang committed Jan 27, 2022
1 parent c0bd42b commit 9c7b06c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 22 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.DS_Store
SignConfig.cfg
SignConfig.cfg
cookie
log
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ Python版本 江西省普通高等学校 校园防疫 健康签到 自动签到
>
> 使用输入的经纬度,单人签到推荐,会在你输入的经纬度定位上随机偏移11.1m以内

8. 如果使用输入的经纬度模式,即上一步中的参数 `signType = 1`,则还需要配置34行和36行的经纬度、38行的地址,建议在[*
百度拾取坐标系统*](http://api.map.baidu.com/lbsapi/getpoint/index.html)找到自己的位置。经度是较大的那个。

9. 如果需要server酱推送,可在第38-46行了解详情并配置
8. 如果使用输入的经纬度模式,即上一步中的参数 `signType = 1`,则还需要配置34行和36行的经纬度、38行的地址,建议在[*百度拾取坐标系统*](http://api.map.baidu.com/lbsapi/getpoint/index.html)找到自己的位置。经度是较大的那个。

9. 如果需要签到通知推送,可在39-51行了解详情并配置

9. 将BigStudyConfigTemplate.cfg重命名为BigStudyConfig.cfg

Expand Down Expand Up @@ -241,7 +240,7 @@ Python版本 江西省普通高等学校 校园防疫 健康签到 自动签到

9. 如果配置的定时函数未运行,请在触发管理里检查你的cron表达式。

10. 如果配置的定时函数出错,可以再日志查询里查看历史允许的情况。如果有配置server酱,运行成功在手机上会有提示。
10. 如果配置的定时函数出错,可以再日志查询里查看历史允许的情况。如果有配置通知推送,运行成功在手机上会有提示。

![image-20220112161123876](README/image-20220112161123876.png)

Expand Down Expand Up @@ -383,6 +382,14 @@ python版本:Python 3.10
- 2022.1.12

增加详细的腾讯云云函数教程,修复几个云函数的错误

- 2022.1.27

修复[一个自己的疏忽导致的配置文件读取错误](https://github.com/XYZliang/AutoZFBXiaoYuanFangYiSign/issues/31),[最终导致定位签到出错](https://github.com/XYZliang/AutoZFBXiaoYuanFangYiSign/issues/36)

加入对[PushDeer(SERVER酱牵头众筹开发的开放源码的无App轻量推送服务)](https://github.com/easychen/pushdeer)推送的支持,现已支持IOS15、macOS设备的原生推送通知,后续还会支持iOS14以及安卓轻应用通知推送

将cookie和log两个涉及隐私的文件加入了gitignore,防止误push了个人信息

# 💣 免责声明

Expand Down
16 changes: 9 additions & 7 deletions SignConfigTemplate.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ zddlwz = 你的地址

# ##############################用户通知数据配置#######################################
[NotificationData]
# ##########SERVER酱配置###############
# #SERVER酱Turbo升级版新官网 sct.ftqq.com
# 是否开启SERVER酱通知 0表示关闭 1表示开启 默认为0
server_chan = 0
# SERVER酱sendkey
# 查看网址 sct.ftqq.com/sendkey
# 免费版可每日发送五条推送
# 是否开启推送通知 0表示关闭 1表示开启SERVER酱配置 2表示开启PushDeer推送(推荐) 默认为0
notification = 0
# ##########SERVER酱、PushDeer配置###############
# #SERVER酱Turbo升级版新官网 sct.ftqq.com,支持推送到钉钉、微信公众号、企业微信、安卓App、苹果Bark App、Webhook、邮件
# #PushDeer为SERVER酱牵头众筹开发的开放源码的无App轻量推送服务(推荐),github.com/easychen/pushdeer ,还在开源测试中,目前iOS15、macOS已经可以正常使用。iOS14、安卓正在开发

# SERVER酱或者PushDeer的sendkey
# SERVER酱免费版可每日发送五条推送
# PushDeer暂无限制
sendkey = 你的key
41 changes: 32 additions & 9 deletions sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def __init__(self, name):
def __str__(self):
return self.name + '项目未配置'


class ShowErr(Exception):
def __str__(self):
return '项目出错,请查看程序输出'
Expand Down Expand Up @@ -83,11 +82,11 @@ def __str__(self):
if signType == 1:
lng = conf["UserData"].getfloat("lng", 0.0)
lat = conf["UserData"].getfloat("lat", 0.0)
zddlwz = conf["UserData"].get("IDs", "null")
zddlwz = conf["UserData"].get("zddlwz", "null")
if lng == 0.0 or lat == 0.0 or zddlwz == "null" or lng == 123.456789 or lat == 22.222222 or zddlwz == "你的地址":
raise NoConf('定位签到数据')
server_chan = conf["NotificationData"].getint("server_chan", 0)
if server_chan == 1:
notification = conf["NotificationData"].getint("notification", 0)
if notification == 1 or notification == 2:
sendkey = conf["NotificationData"].get("sendkey", "null")
if sendkey == "null" or sendkey == '你的key':
raise NoConf('sendkey')
Expand Down Expand Up @@ -354,8 +353,10 @@ def sendings():
else:
title = "部分签到成功:" + str(count[1] + count[2]) + "人签到成功," + str(count[0]) + "人失败!!!!!"
log.write(str(title) + '\n')
if server_chan == 1:
send_serverchan(str(title))
if notification == 1:
sendServerChan(str(title))
elif notification == 2:
sendPushDeer(title)
return


Expand All @@ -365,12 +366,14 @@ def sending():
else:
title = str(name) + str(ID) + "签到成功!"
log.write(str(title) + '\n')
if server_chan == 1:
send_serverchan(str(title))
if notification == 1:
sendServerChan(str(title))
elif notification == 2:
sendPushDeer(title)
return


def send_serverchan(title):
def sendServerChan(title):
global message
url = 'https://sctapi.ftqq.com/' + sendkey + '.send'
log.seek(pointer, 0)
Expand Down Expand Up @@ -404,6 +407,26 @@ def send_serverchan(title):
return


def sendPushDeer(title):
global message
url = 'https://api2.pushdeer.com/message/push?pushkey=' + sendkey + '&text='
log.seek(pointer, 0)
f = log.read()
message = title + message + "\n---本次签到日志如下---\n" + str(f)
message = message.replace("\n", "%0A")
url = url + message
print(url)
res = requests.get(url)
serverdata = json.loads(res.text)
serverdata = json.loads(serverdata['content']['result'][0])
if serverdata['success'] == 'ok':
print("PushDeer发送成功")
log.write("PushDeer发送成功:" + res.text + '\n')
else:
print("SERVER发送失败")
log.write("PushDeer发送失败:" + res.text + '\n')


def initialization():
nowtime = datetime.datetime.now()
log.write(str(nowtime) + '\n')
Expand Down

0 comments on commit 9c7b06c

Please sign in to comment.