feat: basic func from config

main
ZGGSONG 2 years ago
parent fdb00df2c9
commit dc6c0eae04

1
.gitignore vendored

@ -1,2 +1,3 @@
.idea/ .idea/
.DS_Store .DS_Store
*.yml

@ -0,0 +1,13 @@
# coding:utf-8
import yaml
def config():
# 获取yaml文件路径
yaml_path = 'config.yml'
with open(yaml_path, 'rb') as f:
# yaml文件通过---分节,多个节组合成一个列表
date = yaml.safe_load_all(f)
# print(list(date))
return list(date)

@ -0,0 +1,2 @@
cookies: #&&分割
bark_url:

@ -1,35 +1,40 @@
from os import environ 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
def main(): def main():
conf = config()
# 获取actions secrets配置的cookie SendKey # 获取actions secrets配置的cookie SendKey
ck = environ["cookie"] ck = conf[0]['cookies']
SendKey = environ.get('SendKey') # send_key = environ.get('SendKey')
token = environ.get('token') # token = environ.get('token')
barkUrl = environ.get('barkUrl') bark_url = conf[0]['bark_url']
try: try:
title, Text = CheckIn(ck) title, text = CheckIn(ck)
print('签到成功!') print('签到成功!')
except Exception as e: except Exception as e:
print('程序出错!') print('程序出错!')
title = '程序出错!' title = '程序出错!'
Text = e text = e
finally: finally:
# print(title) # print(title)
print(Text) print(text)
# Text = Text.replace('\n', '%0D%0A%0D%0A') # 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) # 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不推送
# print(rsp)
if bark_url != '':
rsp = send_bark(bark_url, title, text)
print(rsp)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

@ -1,2 +1,3 @@
requests==2.28.1 requests==2.28.1
pytz==2022.1 pytz==2022.1
PyYAML==6.0
Loading…
Cancel
Save