调整虚拟群组功能
This commit is contained in:
@@ -42,7 +42,6 @@ class GroupVirtualPlugin(MessagePluginInterface):
|
||||
self.data = None
|
||||
self.message_cache = set() # 用于防止消息循环转发
|
||||
self.group_virtual_redis = None
|
||||
self.bot: WechatAPIClient = None
|
||||
|
||||
def initialize(self, context: Dict[str, Any]) -> bool:
|
||||
"""初始化插件"""
|
||||
@@ -91,7 +90,7 @@ class GroupVirtualPlugin(MessagePluginInterface):
|
||||
return len(chat_groups) > 0
|
||||
|
||||
@plugin_stats_decorator(plugin_name="跨群聊天")
|
||||
def process_message(self, message: Dict[str, Any]) -> Tuple[bool, Optional[str]]:
|
||||
async def process_message(self, message: Dict[str, Any]) -> Tuple[bool, Optional[str]]:
|
||||
"""处理消息"""
|
||||
roomid = message.get("roomid", "")
|
||||
sender = message.get("sender", "")
|
||||
@@ -120,11 +119,11 @@ class GroupVirtualPlugin(MessagePluginInterface):
|
||||
|
||||
# 处理每个虚拟聊天组的转发
|
||||
for chat_group in chat_groups:
|
||||
self._forward_message_in_chat_group(message, chat_group)
|
||||
await self._forward_message_in_chat_group(message, chat_group)
|
||||
|
||||
return True, "消息已转发"
|
||||
|
||||
def _forward_message_in_chat_group(self, message: Dict[str, Any], chat_group: Dict[str, Any]):
|
||||
async def _forward_message_in_chat_group(self, message: Dict[str, Any], chat_group: Dict[str, Any]):
|
||||
"""在虚拟聊天组内转发消息"""
|
||||
roomid = message.get("roomid", "")
|
||||
sender = message.get("sender", "")
|
||||
@@ -156,7 +155,7 @@ class GroupVirtualPlugin(MessagePluginInterface):
|
||||
# 转发到其他群
|
||||
for group in chat_group["groups"]:
|
||||
if group["id"] != roomid: # 不转发回源群
|
||||
self.bot.send_text_message(group["id"], forward_content)
|
||||
await self.bot.send_text_message(group["id"], forward_content)
|
||||
|
||||
# 图片消息 暂时不支持。
|
||||
# elif msg_type == 3:
|
||||
|
||||
Reference in New Issue
Block a user