From cac4856f2fb0416136709aa0b8dc74418ec81e13 Mon Sep 17 00:00:00 2001 From: Wbucket <2595141012@stu.hqu.edu.cn> Date: Wed, 30 Sep 2026 13:28:33 +0800 Subject: [PATCH] =?UTF-8?q?fix=20:=20=E6=9A=82=E6=97=B6=E6=B7=BB=E5=8A=A0d?= =?UTF-8?q?ev=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/bot.py b/bot.py index 21921f6..e352c4b 100644 --- a/bot.py +++ b/bot.py @@ -11,8 +11,8 @@ from botpy.types.session import Session from dotenv import load_dotenv import os import types -# from bobby import bobbySession -# from mcwatcher import watcher +from bobby import bobbySession +from mcwatcher import watcher from threading import Thread import asyncio #环境配置 @@ -98,7 +98,7 @@ class djtuWebsocket (Client) : # 触发概率不大所以可以直接提取关键字 async def parseCommand(self,msg :Message): commands:dict[str,types.MethodType|types.FunctionType] = { - # r'/邀请码' : bobby.getInviteCode, + r'/邀请码' : bobby.getInviteCode, r'吃什么' : lambda :"是啊吃什么" } required = msg.content @@ -142,17 +142,19 @@ bbyPasswd = os.getenv("BOBBY_PASSWORD") appid = os.getenv("APP_ID") secret_bot = os.getenv("SECRET") group_open_id = os.getenv("GROUP_OPEN_ID") +dev = os.getenv("DEV") if appid is None or secret_bot is None : raise SystemExit("未找到bot配置!") logger.info("登录账号:"+appid) # bobby Session -if bbyAccount is None or bbyPasswd is None : - raise SystemError("未找到账密配置") -if appid is None or secret_bot is None : - raise SystemError("未找到bot配置") -# bobby = bobbySession(bbyAccount,bbyPasswd) +if not dev is None: + if bbyAccount is None or bbyPasswd is None : + raise SystemError("未找到账密配置") + if appid is None or secret_bot is None : + raise SystemError("未找到bot配置") + bobby = bobbySession(bbyAccount,bbyPasswd) async def main(ws:djtuWebsocket, *args: Any, **kwargs: Any) -> None: async with ws as ws: @@ -175,10 +177,11 @@ ws = djtuWebsocket(Intents_ex(public_messages=True,member_event=True)) # 启动mcwatcher线程 def pushQuene(cont:str): ws.q.put(cont) -# Thread(target=watcher.MCWatcher,name="watcher",kwargs={ -# "hookfunction":pushQuene, -# "logging":logger -# }).start() +if not dev is None : + Thread(target=watcher.MCWatcher,name="watcher",kwargs={ + "hookfunction":pushQuene, + "logging":logger + }).start() # bot线程运行 asyncio.run(main(ws,appid=appid,secret=secret_bot))