feature:1.加群功能插件化;2.成员变更不监听消息,使用定时检查策略;
This commit is contained in:
@@ -5,6 +5,7 @@ from typing import Dict, Any, List, Optional, Tuple
|
||||
|
||||
from wcferry import Wcf
|
||||
|
||||
from message_util import MessageUtil
|
||||
from plugin_common.message_plugin_interface import MessagePluginInterface
|
||||
from plugin_common.plugin_interface import PluginStatus
|
||||
from plugins.stats_collector.decorators import plugin_stats_decorator
|
||||
@@ -40,7 +41,8 @@ class BeautyLegPlugin(MessagePluginInterface):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.image_folder = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), "beautyleg", "download_dir")
|
||||
self.image_folder = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
|
||||
"beautyleg", "download_dir")
|
||||
|
||||
def initialize(self, context: Dict[str, Any]) -> bool:
|
||||
"""初始化插件"""
|
||||
@@ -50,7 +52,7 @@ class BeautyLegPlugin(MessagePluginInterface):
|
||||
# 保存上下文对象
|
||||
self.wcf = context.get("wcf")
|
||||
self.event_system = context.get("event_system")
|
||||
self.message_util = context.get("message_util")
|
||||
self.message_util: MessageUtil = context.get("message_util")
|
||||
self.gbm = context.get("gbm")
|
||||
|
||||
self._commands = self._config.get("Beautyleg", {}).get("command", ["美腿", "腿来"])
|
||||
@@ -105,8 +107,8 @@ class BeautyLegPlugin(MessagePluginInterface):
|
||||
# 获取随机图片
|
||||
random_file_path = self._get_random_file_from_dir(self.image_folder)
|
||||
if not random_file_path:
|
||||
wcf.send_text(f"\n❌未找到美腿图片资源",
|
||||
(roomid if roomid else sender), sender)
|
||||
self.message_util.send_text_msg(f"\n❌未找到美腿图片资源",
|
||||
(roomid if roomid else sender), sender)
|
||||
return True, "未找到图片资源"
|
||||
|
||||
# 发送图片
|
||||
@@ -147,4 +149,4 @@ class BeautyLegPlugin(MessagePluginInterface):
|
||||
self.LOG.error("No image files found in the directory (including subdirectories).")
|
||||
return None
|
||||
|
||||
return random.choice(image_files)
|
||||
return random.choice(image_files)
|
||||
|
||||
Reference in New Issue
Block a user