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

22
ck_wzyd.py

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

7
config.json

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