main
ZGGSONG 2 years ago
commit fdb00df2c9

2
.gitignore vendored

@ -0,0 +1,2 @@
.idea/
.DS_Store

@ -0,0 +1,47 @@
from pytz import timezone
from json import dumps
from requests import post, get
from datetime import datetime
def CheckIn(cookie):
url = "https://glados.rocks/api/user/checkin"
url2 = "https://glados.rocks/api/user/status"
referer = 'https://glados.rocks/console/checkin'
origin = "https://glados.rocks"
useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
payload = {
'token': 'glados.network'
}
checkin = post(
url,
headers={
'cookie': cookie,
'referer': referer,
'origin': origin,
'user-agent': useragent,
'content-type': 'application/json;charset=UTF-8'
},
data=dumps(payload)
)
state = get(
url2,
headers={
'cookie': cookie,
'referer': referer,
'origin': origin,
'user-agent': useragent
}
)
tz = timezone('Asia/Shanghai')
time_now = str(datetime.now(tz=tz))[:19]
mess = checkin.json()['message']
time = state.json()['data']['leftDays']
days = time.split('.')[0]
msg = f'现在时间是:{time_now}\ncheckin: {checkin.status_code} | state: {state.status_code}\n{mess}\n剩余天数:{days}'
checkin.close()
state.close()
return f'{mess},剩余{days}', msg

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

@ -0,0 +1,35 @@
from os import environ
from Check import CheckIn
from push import send_msg_serverJ , send_msg_pushplus, send_bark
def main():
# 获取actions secrets配置的cookie SendKey
ck = environ["cookie"]
SendKey = environ.get('SendKey')
token = environ.get('token')
barkUrl = environ.get('barkUrl')
try:
title, Text = CheckIn(ck)
print('签到成功!')
except Exception as e:
print('程序出错!')
title = '程序出错!'
Text = e
finally:
# print(title)
print(Text)
# Text = Text.replace('\n', '%0D%0A%0D%0A')
rsp = send_msg_serverJ(SendKey, title, Text) # 推送消息无SendKey不推送
print(rsp)
rsp = send_msg_pushplus(token, title, Text) # 推送消息无token不推送
print(rsp)
rsp = send_bark(barkUrl, title, Text)
print(rsp)
if __name__ == '__main__':
main()

@ -0,0 +1,62 @@
from json import dumps
from time import sleep
from requests import post, get
from datetime import datetime, timedelta
def send_msg_serverJ(SendKey, title, Text):
if not SendKey:
# 无SendKey则拦截推送
return 'Sever酱: 未配置SendKey无法进行消息推送。'
print('=================================================================\nSever酱: 开始推送消息!')
Text = Text.replace('\n', '\n\n')
url = f'https://sctapi.ftqq.com/{SendKey}.send'
data = {'title': title, 'desp': Text, 'channel': 9}
rsp = post(url=url, data=data)
pushid = rsp.json()['data']['pushid']
readkey = rsp.json()['data']['readkey']
state_url = f'https://sctapi.ftqq.com/push?id={pushid}&readkey={readkey}'
stop_time = datetime.now() + timedelta(minutes=0, seconds=30)
count = 1
while True:
status_rsp = get(url=state_url)
result = status_rsp.json()['data']['wxstatus']
now_time = datetime.now()
print(now_time, ' ---> ', stop_time, ' : ', count)
if result:
# print(result)
return '消息推送成功!'
elif now_time >= stop_time:
return '程序运行结束!推送结果未知!'
elif count >= 60: # 防止程序一直运行
return '程序运行结束!推送结果未知!'
count += 1
sleep(1)
def send_msg_pushplus(token, title, Text):
if not token:
# 无token则拦截推送
return 'pushPlus: 未配置token无法进行消息推送。'
print('=================================================================\npushPlus: 开始推送消息!')
url = 'http://www.pushplus.plus/send/'
headers = {'Content-Type': 'application/json'}
data = {
"token": token,
"title": title,
"content": Text,
"template": "txt",
"channel": "wechat"
}
data = dumps(data).encode(encoding='utf-8')
rsp = post(url=url, data=data, headers=headers)
return rsp.json()['msg']
def send_bark(url, title, text):
if not url:
return 'bark: 未配置,无法进行消息推送.'
print('=================================================================\nBark: 开始推送消息!')
uri = url + '/' + title + '/' + text
rsp = get(uri)
return rsp.json()['message']

@ -0,0 +1,2 @@
requests==2.28.1
pytz==2022.1
Loading…
Cancel
Save