asg_backend/qqbot/Program.cs
2024-10-19 00:43:22 +08:00

37 lines
1.1 KiB
C#

using Flandre.Adapters.OneBot.Extensions;
using Flandre.Framework;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using qqbot;
using System.Reflection;
using Zack.EventBus;
var builder = FlandreApp.CreateBuilder(new HostApplicationBuilderSettings
{
Args = args,
ContentRootPath = AppDomain.CurrentDomain.BaseDirectory
});
// 安装一个适配器,并添加在这里。
// builder.Adapters.Add(new YourAdapter());
builder.Adapters.AddOneBot(builder.Configuration.GetSection("Adapters:OneBot"));
builder.Plugins.Add<ExamplePlugin>();
var eventBusSec = builder.Configuration.GetSection("EventBus");
builder.Services.Configure<IntegrationEventRabbitMQOptions>(eventBusSec);
builder.Services.AddEventBus("qqbot_client", Assembly.GetExecutingAssembly());
var app = builder.Build();
// 添加内置中间件。
// 这些中间件保证 Flandre 的正常运转。你也可以加入自己的中间件,并灵活调整其顺序。
app.UseCommandSession();
// app.UseMiddleware(async (ctx, next) => { /* ... */ });
app.UseCommandParser();
app.UseCommandInvoker();
app.Run();