1.添加自动加群,开启机器人功能。
This commit is contained in:
14
robot.py
14
robot.py
@@ -225,6 +225,20 @@ class Robot(Job):
|
||||
receivers = msg.roomid
|
||||
self.sendTextMsg(content, receivers, msg.sender)
|
||||
"""
|
||||
try:
|
||||
# 检测群聊是否已加入机器人管理,如果没有则自动添加并开启机器人功能
|
||||
if msg.from_group() and msg.roomid not in GroupBotManager.local_cache["group_list"]:
|
||||
self.LOG.info(f"检测到新群聊: {msg.roomid},自动添加到机器人管理列表并启用机器人功能")
|
||||
# 添加群组到列表
|
||||
GroupBotManager.local_cache["group_list"].add(msg.roomid)
|
||||
# 保存到Redis
|
||||
redis_conn = self.db_manager.get_redis_connection()
|
||||
redis_conn.sadd("group:list", msg.roomid)
|
||||
# 设置ROBOT功能为启用状态
|
||||
GroupBotManager.set_group_permission(msg.roomid, Feature.ROBOT, PermissionStatus.ENABLED)
|
||||
except Exception as e:
|
||||
self.LOG.error(f"加入新群,自动添加并开启机器人功能 error: {e}")
|
||||
|
||||
# 发布消息接收事件
|
||||
self.event_system.publish(EventType.MESSAGE_RECEIVED, {"message": msg})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user