Makabaka 2.0.1.2
See the version list below for details.
dotnet add package Makabaka --version 2.0.1.2
NuGet\Install-Package Makabaka -Version 2.0.1.2
<PackageReference Include="Makabaka" Version="2.0.1.2" />
paket add Makabaka --version 2.0.1.2
#r "nuget: Makabaka, 2.0.1.2"
// Install Makabaka as a Cake Addin #addin nuget:?package=Makabaka&version=2.0.1.2 // Install Makabaka as a Cake Tool #tool nuget:?package=Makabaka&version=2.0.1.2
<div align="center">
<img width="160" src="logo.jpg" alt="logo">
Makabaka
一个基于 OneBot-11标准 的、适配于 Lagrange.Onebot 的、C# .NET Standard 2.1 的异步机器人开发框架。
</div>
说明
[!WARNING] 目前正在重构 Makabaka 2.0,绝大部分代码都使用 DI 进行了重构,因此调用逻辑与 1.x 差异较大。如果你从 1.x 迁移到 2.0 ,可能需要改动较多代码。
本项目将持续跟进 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>
<Details> <Summary>拓展功能</Summary>
功能 | 是否支持 |
---|---|
获取收藏表情 | 🟢 |
获取好友历史消息记录 | 🟢 |
获取群组历史消息记录 | 🟢 |
构造合并转发消息 | 🟢 |
上传群文件 | 🟢 |
私聊发送文件 | 🟢 |
获取群根目录文件列表 | 🟢 |
获取群子目录文件列表 | 🟢 |
获取群文件资源链接 | 🟢 |
好友戳一戳 | 🟢 |
群组戳一戳 | 🟢 |
</Details>
快速上手
配置文件
{
"Logging": {
"LogLevel": {
"Default": "Information",
"@Default": "日志等级,如果需要看到详细的收发数据包内容(例如提出 issue),请改成 Trace ,一般情况下用 Information 就行"
}
},
"Bot": {
"ForwardWebSocket": {
"@ForwardWebSocket": "正向 WebSocket",
"Enabled": true,
"@Enabled": "是否启用。注意:一般情况下 ForwardWebSocket 与 ReverseWebSocket 同一时间只能存在一个",
"Url": "ws://127.0.0.1:8081",
"@Url": "远程 Lagrange.Onebot 的 ws 服务器地址",
"AccessToken": "",
"@AccessToken": "鉴权密钥",
"ReconnectInterval": 1000,
"ConnectionTimeout": 5000,
"ApiTimeout": 10000
},
"ReverseWebSocket": {
"@ReverseWebSocket": "反向 WebSocket",
"Enabled": false,
"@Enabled": "是否启用",
"Url": "http://127.0.0.1:8082/onebot/v11/ws/",
"@Url": "本地开启的 ws 服务器地址,请严格按照 http(s):// 开头、/ 结尾的格式,否则可能报错",
"AccessToken": "",
"@AccessToken": "鉴权密钥",
"RestartInterval": 1000
}
}
}
无注释版本见 appsettings.json 。
代码
using Makabaka;
using Makabaka.Events;
using Makabaka.Messages;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace MyApp
{
internal class Program
{
private static ILogger<Program> _logger = null!;
static void Main(string[] args)
{
var builder = new MakabakaAppBuilder(args);
var app = builder.Build();
_logger = app.Services.GetRequiredService<ILogger<Program>>();
app.BotContext.OnPrivateMessage += OnPrivateMessage;
app.BotContext.OnGroupMessage += OnGroupMessage;
app.Run();
}
private static Task OnPrivateMessage(object sender, PrivateMessageEventArgs e)
{
return OnMessage(e.Message, e);
}
private static Task OnGroupMessage(object sender, GroupMessageEventArgs e)
{
return OnMessage(e.Message, e);
}
private static async Task OnMessage(Message message, IMessageHandler reply)
{
if (message.ToString() == "文本测试")
{
await reply.ReplyAsync([new TextSegment("Hello, world!")]);
}
}
}
}
详细的API见 Makabaka.Test 。
开源协议
特别声明
- 本项目完全免费,仅供学习、娱乐使用,请勿运用于商业、非法用途。
- 因使用者使用不当而造成的法律责任,由使用者本人承担。
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
- Microsoft.Extensions.Hosting (>= 8.0.0)
- Watson (>= 6.2.2)
- 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 |