Makabaka 2.0.0-preview.2.241029.1

This is a prerelease version of Makabaka.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Makabaka --version 2.0.0-preview.2.241029.1                
NuGet\Install-Package Makabaka -Version 2.0.0-preview.2.241029.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Makabaka" Version="2.0.0-preview.2.241029.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Makabaka --version 2.0.0-preview.2.241029.1                
#r "nuget: Makabaka, 2.0.0-preview.2.241029.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Makabaka as a Cake Addin
#addin nuget:?package=Makabaka&version=2.0.0-preview.2.241029.1&prerelease

// Install Makabaka as a Cake Tool
#tool nuget:?package=Makabaka&version=2.0.0-preview.2.241029.1&prerelease                

<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>

API 是否支持
/send_private_msg 🟢
/send_group_msg 🟢
/send_msg 🟢
/delete_msg 🟢
/get_msg 🟢
/get_forward_msg 🟢
/send_like 🟢
/set_group_kick 🟢
/set_group_ban 🟢
/set_group_anonymous_ban 🟢
/set_group_whole_ban 🟢
/set_group_admin 🟢
/set_group_anonymous 🟢
/set_group_card 🟢
/set_group_name 🟢
/set_group_leave 🟢
/set_group_special_title 🟢
/set_friend_add_request 🟢
/set_group_add_request 🟢
/get_login_info 🟢
/get_stranger_info 🟢
/get_friend_list 🟢
/get_group_info 🟢
/get_group_list 🟢
/get_group_member_info 🟢
/get_group_member_list 🟢
/get_group_honor_info 🟢
/get_cookies 🟢
/get_csrf_token 🟢
/get_credentials 🟢
/get_record 🟢
/get_image 🟢
/can_send_image 🟢
/can_send_record 🟢
/get_status 🟢
/get_version_info 🟢
/set_restart 🟢
/clean_cache 🔴

</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" // 日志等级,如果需要看到详细的收发数据包内容(例如提出 issue),请改成 Trace ,一般情况下用 Information 就行
		}
	},
	"Bot": {
		"ForwardWebSocket": { // 正向 WebSocket
			"Enabled": true, // 是否启用。注意:一般情况下 ForwardWebSocket 与 ReverseWebSocket 同一时间只能存在一个
			"Url": "ws://127.0.0.1:8081", // 远程 Lagrange.Onebot 的 ws 服务器地址
			"AccessToken": "", // 鉴权密钥
			"ReconnectInterval": 1000,
			"ConnectionTimeout": 5000,
			"ApiTimeout": 10000
		},
		"ReverseWebSocket": { // 反向 WebSocket
			"Enabled": false, // 是否启用
			"Url": "http://127.0.0.1:8082/onebot/v11/ws/", // 本地开启的 ws 服务器地址
			"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!")]);
			}
		}
	}
}

开源协议

GPL-3.0 license

特别声明

  • 本项目完全免费,仅供学习、娱乐使用,请勿运用于商业、非法用途。
  • 因使用者使用不当而造成的法律责任,由使用者本人承担。
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0 74 11/10/2024
2.0.0-preview.2.241029.1 39 10/29/2024
2.0.0-preview.1.241026.1 45 10/26/2024
1.2.1.2 186 3/29/2024
1.2.1.1 116 3/22/2024
1.2.1 117 3/13/2024
1.2.0.1 100 3/6/2024
1.2.0 110 2/28/2024
1.1.3 112 2/23/2024
1.1.2.1 185 12/24/2023
1.1.2 104 12/24/2023
1.1.1.3 89 12/23/2023
1.1.1.2 109 12/20/2023
1.1.1.1 151 11/9/2023
1.1.1 104 11/8/2023
1.1.0 101 11/4/2023
1.0.1 107 10/29/2023
1.0.0.2 123 10/29/2023
1.0.0.1 115 10/28/2023
1.0.0 99 10/28/2023