2020from handlers .bus import query_bus
2121from handlers .classroom import query_empty_classroom
2222
23- from config import APPID , SECRET
23+ from config import APPID , SECRET , AI_GROUP_ENABLED , AI_DIRECT_ENABLED
2424
2525_log = botpy .logging .get_logger ()
2626
@@ -73,11 +73,14 @@ async def on_ready(self):
7373
7474 async def on_c2c_message_create (self , message : DirectMessage ):
7575 """私聊消息处理"""
76- try :
77- if await direct_chat_with_clawdbot (api = self .api , message = message ):
78- return
79- except Exception as e :
80- # 出错时回退到简单回复
76+ if AI_DIRECT_ENABLED :
77+ try :
78+ if await direct_chat_with_clawdbot (api = self .api , message = message ):
79+ return
80+ except Exception as e :
81+ content = message .content
82+ await message .reply (content = content )
83+ else :
8184 content = message .content
8285 await message .reply (content = content )
8386
@@ -87,21 +90,30 @@ async def on_group_at_message_create(self, message: GroupMessage):
8790 if await handler (api = self .api , message = message ):
8891 return
8992
90- # 如果没有处理器处理,尝试使用 group_chat_with_clawdbot
91- try :
92- if await group_chat_with_clawdbot (api = self .api , message = message ):
93- return
94- except Exception as e :
95- # 出错时回退到群组查找
93+ if AI_GROUP_ENABLED :
94+ try :
95+ if await group_chat_with_clawdbot (api = self .api , message = message ):
96+ return
97+ except Exception as e :
98+ user_input = message .content .strip ().replace ("群" , "" )
99+ if user_input :
100+ try :
101+ await internal_find_group (api = self .api , message = message , search_key = user_input )
102+ return
103+ except Exception as find_error :
104+ await message .reply (content = f"调用出错: { str (find_error )} " )
105+ else :
106+ await message .reply (content = f"调用出错: { str (e )} " )
107+ else :
96108 user_input = message .content .strip ().replace ("群" , "" )
97109 if user_input :
98110 try :
99111 await internal_find_group (api = self .api , message = message , search_key = user_input )
100112 return
101- except Exception as find_error :
102- await message .reply (content = f"调用出错: { str (find_error )} " )
113+ except Exception as e :
114+ await message .reply (content = f"调用出错: { str (e )} " )
103115 else :
104- await message .reply (content = f"调用出错: { str ( e ) } " )
116+ await message .reply (content = f"不明白你在说什么哦(๑• . •๑) " )
105117
106118 async def on_group_add_robot (self , message : GroupManageEvent ):
107119 """机器人被添加到群组事件"""
0 commit comments