AstrBot icon indicating copy to clipboard operation
AstrBot copied to clipboard

[Plugin] 插件名新人入群欢迎

Open mjy1113451 opened this issue 10 months ago • 1 comments

插件信息

{
  from nonebot import on_notice
from nonebot.adapters.onebot.v11 import Bot, GroupIncreaseNoticeEvent
from nonebot.plugin import PluginMetadata

__plugin_meta__ = PluginMetadata(
    name="入群欢迎插件",
    description="新成员入群时自动发送欢迎消息,包含入群时间",
    usage="无需手动触发,新成员入群自动生效"
)

# 监听群成员增加事件
welcome = on_notice(priority=5, block=False)

@welcome.handle()
async def handle_group_increase(bot: Bot, event: GroupIncreaseNoticeEvent):
    # 判断是否为新成员入群事件(排除机器人自身入群)
    if event.user_id == event.self_id:
        return
    
    # 获取入群时间(事件发生时间,格式:年-月-日 时:分:秒)
    join_time = event.time.strftime("%Y-%m-%d %H:%M:%S")
    # 获取群名和新成员昵称
    group_info = await bot.get_group_info(group_id=event.group_id)
    group_name = group_info["group_name"]
    user_info = await bot.get_stranger_info(user_id=event.user_id)
    user_name = user_info["nickname"]
    
    # 构造欢迎消息
    welcome_msg = (
        f"🎉 欢迎新成员 @{user_name} 加入 {group_name} 大家庭!\n"
        f"⏰ 入群时间:{join_time}\n"
        f"✨ 请遵守群规,祝在这里玩得开心~"
    )
    
    # 发送欢迎消息到对应群聊
    await welcome.send(message=welcome_msg, at_sender=True)

}

插件检查清单

  • [x] 我的插件经过完整的测试
  • [x] 我的插件不包含恶意代码
  • [x] 我已阅读并同意遵守该项目的 行为准则。

审核选项

  • [ ] 重新提交审核

mjy1113451 avatar Jan 23 '26 06:01 mjy1113451

⚠️ 插件提交格式错误

您好!您的插件提交格式存在问题,无法进行自动审核。请根据以下指南修正:

  • JSON格式错误: Expected property name or '}' in JSON at position 4 (line 2 column 3)。请检查语法,如逗号、引号是否正确。

请根据上述问题进行修改。修改完成后,请在 Issue 正文 中勾选"重新提交审核"复选框以再次触发审核。

此消息由系统自动生成

astrpluginreviewer avatar Jan 23 '26 06:01 astrpluginreviewer