diff --git a/magic.json b/magic.json index a253aa8..7114404 100644 --- a/magic.json +++ b/magic.json @@ -12,6 +12,7 @@ "log_path": "/jd/log", "log_send": true, "monitor_cache_size": 30, + "monitor_cars是你要监控的对象,需要填上自己bot的id和线报频道或群组id": 1, "monitor_cars": [ -1001718319262, -1001533334185, @@ -20,8 +21,33 @@ "monitor_auto_stops": [ "jd_AutoOpenCard" ], + "monitor_scripts_path 填写与面板上一样的路径": 1, "monitor_scripts_path": "/jd/scripts", "monitor_scripts": { + "M_WX_BUILD_DRAW_URL": { + "name": "M盖楼领奖", + "file": "m_jd_wx_buildDraw.js", + "wait": 0, + "queue": false, + "queue_name": "M_WX_BUILD_DRAW_URL", + "enable": true + }, + "M_WX_SHOP_GIFT_URL": { + "name": "M关注有礼无线", + "file": "m_jd_wx_shopGift.js", + "wait": 0, + "queue": false, + "queue_name": "M_WX_SHOP_GIFT_URL", + "enable": true + }, + "M_WX_FOLLOW_DRAW_URL": { + "name": "M关注抽奖", + "file": "m_jd_wx_followDraw.js", + "wait": 0, + "queue": false, + "queue_name": "M_WX_FOLLOW_DRAW_URL", + "enable": true + }, "M_WX_ADD_CART_URL": { "name": "M加购有礼", "file": "m_jd_wx_addCart.js", diff --git a/magic.py b/magic.py index 3e860bf..12164fb 100644 --- a/magic.py +++ b/magic.py @@ -12,7 +12,7 @@ from telethon import TelegramClient, events # 0. 进入容器 # 1. pip3 install -U cacheout # 2. 复制magic.py,magic.json到/ql/config/目录 并配置 -# 3. python3 /ql/config/magic.py 登录 +# 3. python3 /ql/config/magic.py 用手机号登录 # 4. 给bot发送在吗 有反应即可 # 5. pm2 start /ql/config/magic.py -x --interpreter python3 # 6. 挂起bot到后台 查看状态 pm2 l @@ -223,7 +223,7 @@ async def handler(event): logger.info(f'设置环境变量export {action}') await export(text) await client.send_message(bot_id, f'开始执行 #{name}') - await cmd(f'cd {monitor_scripts_path} && {command} {file}') + await cmd(f'{command} {monitor_scripts_path}/{file}') except Exception as e: logger.error(e) await client.send_message(bot_id, f'{str(e)}') @@ -250,7 +250,7 @@ async def task(task_name, task_key): logger.info(f'JTASK命令 {file},{parse.quote_plus(value)}') logger.info(f'出队执行-->设置环境变量export {action}') await export(text) - await cmd(f'cd {monitor_scripts_path} && {command} {file}') + await cmd(f'{command} {monitor_scripts_path}/{file}') if curr_queue.qsize() > 1: await client.send_message(bot_id, f'{action["name"]},队列长度{curr_queue.qsize()},将等待{action["wait"]}秒...') await asyncio.sleep(action['wait']) @@ -261,10 +261,7 @@ async def task(task_name, task_key): async def cmd(text): try: logger.info(f"执行命令{text}") - if 'node' in text: - name = re.findall(r'node (.*).js', text)[0] - else: - name = re.findall(r'task (.*).js', text)[0] + name = re.findall(r'[^/:*?"<>|]+$', text)[0] tmp_log = f'{log_path}/{name}.{datetime.datetime.now().strftime("%H%M%S%f")}.log' proc = await asyncio.create_subprocess_shell( f"{text} >> {tmp_log} 2>&1",