Files
NeoBot/plugins/echo.py
K2cr2O1 56b1014419 refactor(core): 重构核心模块结构并添加开发文档
将核心模块按功能重新组织为更清晰的结构,包括 managers、handlers 和 utils 目录
添加完整的开发文档,涵盖快速开始、项目结构、核心概念和插件开发指南
更新所有相关模块的导入路径以匹配新的结构
将单例模式实现提取到单独的 singleton.py 文件
2026-01-07 22:51:27 +08:00

54 lines
1.5 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.
"""
Echo 与交互插件
提供 /echo 和 /赞我 指令。
"""
from core.managers.command_manager import matcher
from core.bot import Bot
from models import MessageEvent
__plugin_meta__ = {
"name": "echo",
"description": "提供 echo 和 赞我 功能",
"usage": "/echo [内容] - 复读内容\n/赞我 - 让机器人给你点赞",
}
@matcher.command("echo",permission=MessageEvent.ADMIN)
async def handle_echo(bot: Bot, event: MessageEvent, args: list[str]):
"""
处理 echo 指令,原样回复用户输入的内容
:param bot: Bot 实例
:param event: 消息事件对象
:param args: 指令参数列表
"""
if not args:
reply_msg = "请在指令后输入要回复的内容,例如:/echo 你好"
else:
reply_msg = " ".join(args)
await event.reply(reply_msg)
@matcher.command(
"赞我",
override_permission_check=True
)
async def handle_poke(bot: Bot, event: MessageEvent, permission_granted: bool):
"""
处理 赞我 指令,发送点赞
:param bot: Bot 实例
:param event: 消息事件对象
:param permission_granted: 权限检查结果
"""
if not permission_granted:
await event.reply("只有我的操作员才能让我点赞哦!(。•ˇ‸ˇ•。)")
return
try:
# 尝试发送赞
await bot.send_like(event.user_id, times=10)
await event.reply("好感度+10(〃''〃)")
except Exception as e:
await event.reply(f"点赞失败了 >_<: {str(e)}")