修复定时错误,好像本月就结束了

This commit is contained in:
CHERWING 2024-06-02 02:28:14 +08:00 committed by GitHub
parent acaae6eb85
commit 45efde9da1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,7 +3,7 @@
# -------------------------------
# @Author : cherwin
# -------------------------------
# cron "59 9 * 2-6 * *" script-path=xxx.py,tag=匹配cron用
# cron "59 59 9 1 2-7 *" script-path=xxx.py,tag=匹配cron用
# const $ = new Env('统一茄皇监控')
import hashlib
import json
@ -23,15 +23,19 @@ requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
IS_DEV = False
if os.path.isfile('DEV_ENV.py'):
import DEV_ENV
IS_DEV = True
if os.path.isfile('notify.py'):
from notify import send
print("加载通知服务成功!")
else:
print("加载通知服务失败!")
send_msg = ''
one_msg = ''
def Log(cont=''):
global send_msg, one_msg
print(cont)
@ -39,8 +43,10 @@ def Log(cont=''):
one_msg += f'{cont}\n'
send_msg += f'{cont}\n'
USER_INFO = {}
class RUN:
def __init__(self, info, index):
global one_msg
@ -157,7 +163,8 @@ class RUN:
"slidingImage": slidingImage,
"backImage": backImage
}
response = requests.post(f"{dddddocr_api}/capcode", data=json.dumps(data),headers={'Content-Type': 'application/json'})
response = requests.post(f"{dddddocr_api}/capcode", data=json.dumps(data),
headers={'Content-Type': 'application/json'})
print(response.json())
self.capcode = response.json().get('result', '')
if self.capcode:
@ -266,14 +273,12 @@ class RUN:
def userTask(self):
print('\n--------------- 开始日常任务 ---------------')
wait_time = random.randint(1000, 3000) / 1000.0 # 转换为秒
if not self.Login_res:
return False
self.exchange_find()
time.sleep(0.5)
return True
def sendMsg(self, help=False):
if self.send_UID:
push_res = CHERWIN_TOOLS.wxpusher(self.send_UID, one_msg, APP_NAME, help)
@ -306,17 +311,23 @@ def down_file(filename, file_url):
print(f'{filename}】下载失败:{str(e)}')
return False
def import_Tools():
global CHERWIN_TOOLS, ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode
import CHERWIN_TOOLS
ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode = CHERWIN_TOOLS.main(APP_NAME, local_script_name, ENV_NAME,local_version)
ENV, APP_INFO, TIPS, TIPS_HTML, AuthorCode = CHERWIN_TOOLS.main(APP_NAME, local_script_name, ENV_NAME,
local_version)
import threading
def execute_task(infos, index):
run_result = RUN(infos, index).userTask()
if not run_result:
return
if __name__ == '__main__':
APP_NAME = '统一茄皇监控'
ENV_NAME = 'TYQH_JK'
@ -331,12 +342,12 @@ export OCR_API= 'http://localhost:3721'
由于青龙python版本问题无法直接使用dddocr需要自行搭建API搭建方式https://github.com/CHERWING/CHERWIN_OCR
如果你的环境可以安装dddocr库则可以替换代码内的self.get_CapCodeself.get_CapCode_local
export SCRIPT_UPDATE = 'False' 关闭脚本自动更新默认开启
推荐定时*/10 9:59 1-31 2-6 * * 2-6月每月1日9点55到10点1分每10秒执行一次
推荐定时59 59 9 1 2-7 * (2-7月每月1日9点59)
第一个账号助力作者其余互助
@Author CHERWIN
''')
local_script_name = os.path.basename(__file__)
local_version = '2024.05.15'
local_version = '2024.06.02'
if IS_DEV:
import_Tools()
else:
@ -389,11 +400,9 @@ export SCRIPT_UPDATE = 'False' 关闭脚本自动更新,默认开启
thread = threading.Thread(target=execute_task, args=(infos, index))
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
elif current_time.tm_hour == 10 and current_time.tm_min > 5:
break
else:
time.sleep(1)