Makabaka 1.1.1
See the version list below for details.
dotnet add package Makabaka --version 1.1.1
NuGet\Install-Package Makabaka -Version 1.1.1
<PackageReference Include="Makabaka" Version="1.1.1" />
paket add Makabaka --version 1.1.1
#r "nuget: Makabaka, 1.1.1"
// Install Makabaka as a Cake Addin #addin nuget:?package=Makabaka&version=1.1.1 // Install Makabaka as a Cake Tool #tool nuget:?package=Makabaka&version=1.1.1
Makabaka
简介
基于 OneBot-11标准 的、适配于 Lagrange.Onebot 的、C# .NET Standard 2.1 的异步机器人开发框架。
本项目将持续跟进 Lagrange.Core 项目进度。由于 Lagrange.Core 项目仍在开发当中,可能有部分功能暂未支持。
如果对该项目有任何问题,欢迎在 Issues 中提出。
安装
Makabaka 已发布到 NuGet ,可以通过NuGet包管理器搜索并安装到工程。
或者,可以直接去 Releases 中下载 .nupkg 文件。
已适配内容
<Details> <Summary>消息类型</Summary>
消息类型 | 是否支持 |
---|---|
Text | 🟢 |
Face | 🟢 |
Image | 🟢 |
Record | 🔴 |
Video | 🔴 |
At | 🟢 |
Rps | 🔴 |
Dice | 🔴 |
Shake | 🔴 |
Poke | 🔴 |
Anonymous | 🔴 |
Share | 🔴 |
Contact | 🔴 |
Location | 🔴 |
Music | 🔴 |
Reply | 🔴 |
Forward | 🟢 |
Node | 🔴 |
Xml | 🔴 |
Json | 🔴 |
</Details>
<Details> <Summary>API</Summary>
</Details>
<Details> <Summary>事件</Summary>
推送类型 | 事件名称 | 是否支持 |
---|---|---|
Message | Private Message | 🔴 |
Message | Group Message | 🟢 |
Notice | Group File Upload | 🔴 |
Notice | Group Admin Change | 🔴 |
Notice | Group Member Decrease | 🟢 |
Notice | Group Member Increase | 🟢 |
Notice | Group Mute | 🔴 |
Notice | Friend Add | 🔴 |
Notice | Group Recall Message | 🔴 |
Notice | Friend Recall Message | 🔴 |
Notice | Group Poke | 🔴 |
Notice | Group red envelope luck king | 🔴 |
Notice | Group Member Honor Changed | 🔴 |
Request | Add Friend Request | 🔴 |
Request | Group Request/Invitations | 🔴 |
Meta | LifeCycle | 🟢 |
Meta | Heartbeat | 🟢 |
</Details>
<Details> <Summary>适配器</Summary>
适配器类型 | 是否支持 |
---|---|
Http | 🔴 |
Http-Post | 🟢 |
ForwardWebSocket | 🟢 |
ReverseWebSocket | 🟢 |
</Details>
画饼充饥
- 没饼画了
- 添加Http-Post支持
- 添加反向WebSocket支持
- 添加正向WebSocket支持
代码示例
<Details> <Summary>正向/反向WebSocket</Summary>
using Makabaka.Models.API.Responses;
using Makabaka.Models.EventArgs.Messages;
using Makabaka.Models.EventArgs.Meta;
using Makabaka.Models.Messages;
using Makabaka.Services;
using Serilog;
namespace Test
{
internal class Program
{
private static IService _service;
static async Task Main(string[] args)
{
Log.Logger = new LoggerConfiguration() // Serilog包
.MinimumLevel.Debug() // 日志等级
.WriteTo.Console() // 日志输出
.CreateLogger(); // 配置日志
_service = ServiceFactory.CreateForwardWebSocketService(new() // 创建正向WebSocket服务
{
AccessToken = "114514", // 适配器的access_token,用于认证
Host = "127.0.0.1", // 服务器地址
Port = "8080", // 服务器端口
});
// 注册事件
_service.OnLifeCycle += OnLifeCycle; // 生命周期事件
_service.OnGroupMessage += OnGroupMessage; // 群消息事件
await _service.StartAsync(); // 启动服务
await _service.WaitAsync(); // 等待服务关闭
//await _service.StopAsync(); // 关闭服务,可以放在任何地方(放这里其实没用,前面在等待服务关闭)
}
private static async void OnGroupMessage(object? sender, GroupMessageEventArgs e)
{
if (e.Message == "测试") // 接收到“测试”
{
APIResponse<MessageIdInfo> response = await e.Session.SendGroupMessageAsync(e.GroupId, new TextSegment("耶")); // 发送“耶”
response.EnsureSuccess(); // 确保发送成功了
MessageIdInfo info = response; // 这里可以隐式转换
// 因此,如果你用不到APIResponse<T>,可以把两行省略成一行:
// MessageIdInfo info = await e.Session.SendGroupMessageAsync(e.GroupId, new TextSegment("耶"));
// 效果是一样的
Log.Information($"消息ID:{info.MessageId}"); // 输出消息ID
}
}
private static async void OnLifeCycle(object? sender, LifeCycleEventArgs e)
{
LoginInfo info = await e.Session.GetLoginInfoAsync(); // 获取登录信息
Log.Information($"当前登录账号:[{info.UserId}]{info.Nickname}");
}
}
}
</Details>
<Details> <Summary>HttpPost(目前Lagrange.Core暂未支持,不推荐使用)</Summary>
using Makabaka.Models.EventArgs.Messages;
using Makabaka.Models.FastActions;
using Makabaka.Models.Messages;
using Makabaka.Services;
using Serilog;
using XeronBot.Configurations;
namespace XeronBot
{
internal class Program
{
private static IPassiveService _service;
static async Task Main(string[] args)
{
Log.Logger = new LoggerConfiguration() // Serilog包
.MinimumLevel.Verbose() // 日志等级
.WriteTo.Console() // 日志输出
.CreateLogger(); // 配置日志
_service = ServiceFactory.CreateHttpPostService(new() // 创建正向WebSocket服务
{
AccessToken = "114514", // 适配器的secret,用于认证
Host = "127.0.0.1", // 服务器地址
Port = "8080", // 服务器端口
});
// 注册事件
_service.OnLifeCycle += OnLifeCycle; // 生命周期事件
_service.OnGroupMessage += OnGroupMessage; // 群消息事件
await _service.StartAsync(); // 启动服务
await _service.WaitAsync(); // 等待服务关闭
//await _service.StopAsync(); // 关闭服务,可以放在任何地方(放这里其实没用,前面在等待服务关闭)
}
private static async Task<IFastAction> OnGroupMessage(object? sender, GroupMessageEventArgs e)
{
if (e.Message == "测试") // 接收到“测试”
{
return new GroupMessageFastAction(message: new TextSegment("耶")); // 快速操作,回复“耶”
}
// 注意:由于 HttpPost 的特殊性, e.Session 永远为 null
// 也就是说,您将无法使用 e.Session 进行主动操作
// 故不推荐使用 HttpPost
await Task.CompletedTask; // 强制异步
return null; // 如果不需要快速操作,返回null
}
private static async Task<IFastAction> OnLifeCycle(object? sender, LifeCycleEventArgs e)
{
// TODO: ...
await Task.CompletedTask; // 强制异步
return null; // 如果不需要快速操作,返回null
}
}
}
</Details>
开源协议
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Newtonsoft.Json (>= 13.0.3)
- Serilog (>= 3.0.1)
- Watson (>= 5.1.3)
- WatsonWebsocket (>= 4.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.0.1.3 | 86 | 12/7/2024 |
2.0.1.2 | 81 | 11/28/2024 |
2.0.0 | 102 | 11/10/2024 |
2.0.0-preview.2.241029.1 | 46 | 10/29/2024 |
2.0.0-preview.1.241026.1 | 50 | 10/26/2024 |
1.2.1.2 | 194 | 3/29/2024 |
1.2.1.1 | 122 | 3/22/2024 |
1.2.1 | 125 | 3/13/2024 |
1.2.0.1 | 108 | 3/6/2024 |
1.2.0 | 118 | 2/28/2024 |
1.1.3 | 118 | 2/23/2024 |
1.1.2.1 | 193 | 12/24/2023 |
1.1.2 | 110 | 12/24/2023 |
1.1.1.3 | 97 | 12/23/2023 |
1.1.1.2 | 115 | 12/20/2023 |
1.1.1.1 | 157 | 11/9/2023 |
1.1.1 | 110 | 11/8/2023 |
1.1.0 | 107 | 11/4/2023 |
1.0.1 | 114 | 10/29/2023 |
1.0.0.2 | 129 | 10/29/2023 |
1.0.0.1 | 121 | 10/28/2023 |
1.0.0 | 105 | 10/28/2023 |