Files
NeoBot/plugins/group_welcome.py
K2cr2O1 58a0c717e3 feat(plugins): 添加入群提醒功能
当机器人加入新群时自动发送欢迎消息,包含作者信息和用途说明
2026-02-27 14:42:12 +08:00

45 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
入群提醒插件
在机器人加入群时发送提醒消息,包含作者信息和用途说明。
"""
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}")