feat: basic func from config

main
ZGGSONG 2 years ago
parent fdb00df2c9
commit dc6c0eae04

1
.gitignore vendored

@ -1,2 +1,3 @@
.idea/
.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,33 +1,38 @@
from os import environ
from Check import CheckIn
from check import CheckIn
from push import send_msg_serverJ, send_msg_pushplus, send_bark
from config import config
def main():
conf = config()
# 获取actions secrets配置的cookie SendKey
ck = environ["cookie"]
SendKey = environ.get('SendKey')
token = environ.get('token')
barkUrl = environ.get('barkUrl')
ck = conf[0]['cookies']
# send_key = environ.get('SendKey')
# token = environ.get('token')
bark_url = conf[0]['bark_url']
try:
title, Text = CheckIn(ck)
title, text = CheckIn(ck)
print('签到成功!')
except Exception as e:
print('程序出错!')
title = '程序出错!'
Text = e
text = e
finally:
# print(title)
print(Text)
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)
# if send_key != '':
# rsp = send_msg_serverJ(send_key, title, text) # 推送消息无SendKey不推送
# print(rsp)
#
# if token != '':
# rsp = send_msg_pushplus(token, title, text) # 推送消息无token不推送
# print(rsp)
rsp = send_bark(barkUrl, title, Text)
if bark_url != '':
rsp = send_bark(bark_url, title, text)
print(rsp)

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