using asg_form.Controllers;
using Flandre.Core.Common;
using Flandre.Core.Messaging;
using Flandre.Framework.Common;
using Flandre.Framework.Routing;
using Zack.EventBus;
namespace qqbot
{
public sealed class ExamplePlugin : Plugin
{
private IEventBus eventBus;
public ExamplePlugin(IEventBus eventBus)
{
this.eventBus = eventBus;
}
///
/// 每次收到消息时触发。
///
public override async Task OnMessageReceivedAsync(MessageContext ctx)
{
// 如果消息文本为 "Hello!",
if (ctx.Message.GetText() == "Hello!")
{
// 则发送一条 "World!" 消息作为回复。
await ctx.Bot.SendMessageAsync(ctx.Message, "World!");
}
}
///
/// 定义一条指令。
/// 向机器人发送 "example {num}" 时触发,其中 num 为一个合法的 double 值。
///
///
///
/// 定义一个参数。框架会自动识别参数的类型,并解析用户传入的文本。
///
///
///
/// 指令方法需要返回机器人的回复消息。
///
///
///
/// 发送:example 1.28
/// 回复:1.28 的二次方为 1.6384。
///
[Command]
public string 查询选手(string name)
{
try
{
eventBus.Publish("查询选手", name);
return null;
}
catch
{
return "出现错误";
}
}
}
}