feat: multiple accounts

main
ZGGSONG 2 years ago
parent dc6c0eae04
commit 90f266b5dc

@ -38,8 +38,9 @@ def CheckIn(cookie):
mess = checkin.json()['message'] mess = checkin.json()['message']
time = state.json()['data']['leftDays'] time = state.json()['data']['leftDays']
email = state.json()['data']['email']
days = time.split('.')[0] days = time.split('.')[0]
msg = f'现在时间是:{time_now}\ncheckin: {checkin.status_code} | state: {state.status_code}\n{mess}\n剩余天数:{days}' msg = f'现在时间是:{time_now}\nemail: {email}\ncheckin: {checkin.status_code} | state: {state.status_code}\n{mess}\n剩余天数:{days}'
checkin.close() checkin.close()
state.close() state.close()

@ -2,12 +2,17 @@
import yaml import yaml
# https://blog.csdn.net/weixin_41010198/article/details/111591030
def config(): def config():
# 获取yaml文件路径 # 获取yaml文件路径
yaml_path = 'config.yml' yaml_path = 'config.yml'
# 使用open()函数读取config.yaml文件
yaml_file = open(yaml_path, "r", encoding="utf-8")
# 读取文件中的内容
file_data = yaml_file.read()
# print(f"file_date type: {type(file_data)}\nfile_date value:\n{file_data}")
yaml_file.close()
with open(yaml_path, 'rb') as f: # 加载数据流,返回字典类型数据
# yaml文件通过---分节,多个节组合成一个列表 y = yaml.load(file_data, Loader=yaml.FullLoader)
date = yaml.safe_load_all(f) return y
# print(list(date))
return list(date)

@ -1,2 +1,5 @@
cookies: #&&分割 cookies:
bark_url: - #多cookie
bark_url: # bark app中的URL
send_key: # 将Server酱中的SendKey复制到此
token: # 将push plus微信公众号中的token复制到此

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

Loading…
Cancel
Save