优化代码,删除无效代码
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
from typing import Dict, Any, List, Optional, Tuple
|
||||
|
||||
from message_util import MessageUtil
|
||||
from plugin_common.message_plugin_interface import MessagePluginInterface
|
||||
from plugin_common.plugin_interface import PluginStatus
|
||||
from utils.decorator.plugin_decorators import plugin_stats_decorator
|
||||
from utils.wechat.contact_manager import ContactManager
|
||||
from db.connection import DBConnectionManager
|
||||
from db.group_virtual_redis import GroupVirtualRedisDB
|
||||
from wechat_ipad import WechatAPIClient
|
||||
from wechat_ipad.models.message import WxMessage
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ 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:
|
||||
"""初始化插件"""
|
||||
@@ -49,7 +50,6 @@ class GroupVirtualPlugin(MessagePluginInterface):
|
||||
|
||||
# 保存上下文对象
|
||||
self.event_system = context.get("event_system")
|
||||
self.message_util: MessageUtil = context.get("message_util")
|
||||
|
||||
# 初始化配置
|
||||
self.enable = self._config.get("GroupVirtual", {}).get("enable", True)
|
||||
@@ -96,6 +96,8 @@ class GroupVirtualPlugin(MessagePluginInterface):
|
||||
roomid = message.get("roomid", "")
|
||||
sender = message.get("sender", "")
|
||||
full_wx_msg: WxMessage = message.get("full_wx_msg")
|
||||
|
||||
self.bot: WechatAPIClient = message.get("bot")
|
||||
# 检查是否是机器人自己发送的消息
|
||||
if full_wx_msg.from_self():
|
||||
return False, "不转发自己的消息"
|
||||
@@ -154,7 +156,7 @@ class GroupVirtualPlugin(MessagePluginInterface):
|
||||
# 转发到其他群
|
||||
for group in chat_group["groups"]:
|
||||
if group["id"] != roomid: # 不转发回源群
|
||||
self.message_util.send_text(forward_content, group["id"])
|
||||
self.bot.send_text_message(group["id"], forward_content)
|
||||
|
||||
# 图片消息 暂时不支持。
|
||||
# elif msg_type == 3:
|
||||
|
||||
Reference in New Issue
Block a user