Browse Source

修改从环境变量获取的方式

pull/15/head
张洛 3 years ago
parent
commit
6dda761673
  1. 20
      ck_hlx.py
  2. 22
      ck_wzyd.py
  3. 7
      config.json

20
ck_hlx.py

@ -2,7 +2,9 @@
import requests import requests
import os import os
from checksendNotify import send from checksendNotify import send
from getENV import getENv
from checksendNotify import send
import json
r = requests.Session() r = requests.Session()
@ -96,15 +98,13 @@ def hlx(user, passwd):
def start(): def start():
scriptName = '葫芦侠签到' getENv()
print(scriptName) with open("/ql/config/check.json", "r", encoding="utf-8") as f:
if "hlx_username" in os.environ and "hlx_password" in os.environ: datas = json.loads(f.read())
print('已经在环境中找到用户名和密码,开始执行程序') _check_item = datas.get("HLX", [])[0]
res = hlx(os.environ['hlx_username'], os.environ['hlx_password']) res = hlx(user=_check_item.get('user'),passwd=_check_item.get('password'))
result = f' {scriptName} \n {res}' print(res)
send("葫芦侠", result) send('葫芦侠', res)
else:
print('未找到用户名和密码停止执行')
if __name__ == '__main__': if __name__ == '__main__':

22
ck_wzyd.py

@ -1,11 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# 20 10 * * *
import json import json
import os import os
import time
from urllib import parse from urllib import parse
from checksendNotify import send
import requests import requests
from getENV import getENv
from checksendNotify import send
class WZYDCheckIn: class WZYDCheckIn:
@ -25,7 +25,7 @@ class WZYDCheckIn:
return msg return msg
def main(self): def main(self):
wzyd_data = self.check_item wzyd_data = self.check_item.get("wzyd_data")
data = {k: v[0] for k, v in parse.parse_qs(wzyd_data).items()} data = {k: v[0] for k, v in parse.parse_qs(wzyd_data).items()}
try: try:
user_id = data.get("userId", "") user_id = data.get("userId", "")
@ -38,10 +38,10 @@ class WZYDCheckIn:
if __name__ == "__main__": if __name__ == "__main__":
if 'wzyd' in os.environ: getENv()
print('王者营地签到开始') with open("/ql/config/check.json", "r", encoding="utf-8") as f:
text = WZYDCheckIn(check_item=os.environ.get('wzyd')).main() datas = json.loads(f.read())
localtime = time.asctime(time.localtime(time.time())) _check_item = datas.get("WZYD_DATA_LIST", [])[0]
result=f'当前时间{localtime}\n结果:{text}' res = WZYDCheckIn(check_item=_check_item).main()
send('王者营地签到',result) print(res)
else:print('未找到变量请填入') send('王者营地', res)

7
config.json

@ -274,5 +274,10 @@
{ {
"womail_url": "多账号 url 填写,请参考上面,url 以实际获取为准(遇到特殊字符如双引号\" 请加反斜杠转义)" "womail_url": "多账号 url 填写,请参考上面,url 以实际获取为准(遇到特殊字符如双引号\" 请加反斜杠转义)"
} }
] ],
"HLX":
{
"user": "",
"password": ""
}
} }
Loading…
Cancel
Save