@@ -47,3 +47,9 @@ ca_cert_path = "ca/ca.pem"
|
|||||||
client_cert_path = "ca/cert.pem"
|
client_cert_path = "ca/cert.pem"
|
||||||
# 客户端密钥路径(可选)
|
# 客户端密钥路径(可选)
|
||||||
client_key_path = "ca/key.pem"
|
client_key_path = "ca/key.pem"
|
||||||
|
|
||||||
|
[image_manager]
|
||||||
|
# 图片高度
|
||||||
|
image_height = 1920
|
||||||
|
# 图片宽度
|
||||||
|
image_width = 1080
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
import tomllib
|
import tomllib
|
||||||
from pydantic import ValidationError
|
from pydantic import ValidationError
|
||||||
from .config_models import ConfigModel, NapCatWSModel, BotModel, RedisModel, DockerModel
|
from .config_models import ConfigModel, NapCatWSModel, BotModel, RedisModel, DockerModel, ImageManagerModel
|
||||||
from .utils.logger import ModuleLogger
|
from .utils.logger import ModuleLogger
|
||||||
from .utils.exceptions import ConfigError, ConfigNotFoundError, ConfigValidationError
|
from .utils.exceptions import ConfigError, ConfigNotFoundError, ConfigValidationError
|
||||||
|
|
||||||
@@ -115,6 +115,13 @@ class Config:
|
|||||||
"""
|
"""
|
||||||
return self._model.docker
|
return self._model.docker
|
||||||
|
|
||||||
|
@property
|
||||||
|
def image_manager(self) -> ImageManagerModel:
|
||||||
|
"""
|
||||||
|
获取图片生成管理器配置
|
||||||
|
"""
|
||||||
|
return self._model.image_manager
|
||||||
|
|
||||||
|
|
||||||
# 实例化全局配置对象
|
# 实例化全局配置对象
|
||||||
global_config = Config()
|
global_config = Config()
|
||||||
|
|||||||
@@ -49,6 +49,13 @@ class DockerModel(BaseModel):
|
|||||||
client_cert_path: Optional[str] = None
|
client_cert_path: Optional[str] = None
|
||||||
client_key_path: Optional[str] = None
|
client_key_path: Optional[str] = None
|
||||||
|
|
||||||
|
class ImageManagerModel(BaseModel):
|
||||||
|
"""
|
||||||
|
对应 `config.toml` 中的 `[image_manager]` 配置块。
|
||||||
|
"""
|
||||||
|
image_height: int = 1920
|
||||||
|
image_width: int = 1080
|
||||||
|
|
||||||
|
|
||||||
class ConfigModel(BaseModel):
|
class ConfigModel(BaseModel):
|
||||||
"""
|
"""
|
||||||
@@ -58,3 +65,6 @@ class ConfigModel(BaseModel):
|
|||||||
bot: BotModel
|
bot: BotModel
|
||||||
redis: RedisModel
|
redis: RedisModel
|
||||||
docker: DockerModel
|
docker: DockerModel
|
||||||
|
image_manager: ImageManagerModel
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -12,6 +12,7 @@ from jinja2 import Template
|
|||||||
from .browser_manager import browser_manager
|
from .browser_manager import browser_manager
|
||||||
from ..utils.logger import logger
|
from ..utils.logger import logger
|
||||||
from ..utils.singleton import Singleton
|
from ..utils.singleton import Singleton
|
||||||
|
from ..config_loader import global_config
|
||||||
|
|
||||||
class ImageManager(Singleton):
|
class ImageManager(Singleton):
|
||||||
"""
|
"""
|
||||||
@@ -73,8 +74,8 @@ class ImageManager(Singleton):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
width = 1920
|
width = global_config.image_manager.image_width
|
||||||
height = 1080
|
height = global_config.image_manager.image_height
|
||||||
await page.set_viewport_size({"width": width, "height": height})
|
await page.set_viewport_size({"width": width, "height": height})
|
||||||
|
|
||||||
# 加载内容
|
# 加载内容
|
||||||
|
|||||||
44
plugins/group_welcome.py
Normal file
44
plugins/group_welcome.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
"""
|
||||||
|
入群提醒插件
|
||||||
|
|
||||||
|
在机器人加入群时发送提醒消息,包含作者信息和用途说明。
|
||||||
|
"""
|
||||||
|
from core.managers.command_manager import matcher
|
||||||
|
from core.bot import Bot
|
||||||
|
from models.events.notice import GroupIncreaseNoticeEvent
|
||||||
|
from models.message import MessageSegment
|
||||||
|
|
||||||
|
__plugin_meta__ = {
|
||||||
|
"name": "入群提醒",
|
||||||
|
"description": "机器人加入群时发送提醒消息",
|
||||||
|
"usage": "自动触发,无需手动操作"
|
||||||
|
}
|
||||||
|
|
||||||
|
@matcher.on_notice(notice_type="group_increase")
|
||||||
|
async def handle_group_increase(bot: Bot, event: GroupIncreaseNoticeEvent):
|
||||||
|
"""
|
||||||
|
处理群成员增加事件,当机器人加入群时发送提醒
|
||||||
|
|
||||||
|
:param bot: Bot实例
|
||||||
|
:param event: 群成员增加事件对象
|
||||||
|
"""
|
||||||
|
if event.user_id != event.self_id:
|
||||||
|
return
|
||||||
|
|
||||||
|
welcome_message = (
|
||||||
|
f"我已加入本群!👋\n"
|
||||||
|
f"\n"
|
||||||
|
f"作者QQ号:2221577113\n"
|
||||||
|
f"作者:镀铬酸钾\n"
|
||||||
|
f"\n"
|
||||||
|
f"用途:/help"
|
||||||
|
f"by TOS team"
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
await bot.send(
|
||||||
|
event,
|
||||||
|
MessageSegment.text(welcome_message)
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[入群提醒] 发送提醒消息失败: {e}")
|
||||||
Reference in New Issue
Block a user