RedProtocolSharp 0.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package RedProtocolSharp --version 0.0.1
NuGet\Install-Package RedProtocolSharp -Version 0.0.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="RedProtocolSharp" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RedProtocolSharp" Version="0.0.1" />
<PackageReference Include="RedProtocolSharp" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RedProtocolSharp --version 0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RedProtocolSharp, 0.0.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.
#:package RedProtocolSharp@0.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RedProtocolSharp&version=0.0.1
#tool nuget:?package=RedProtocolSharp&version=0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
RedProtocolSharp
--基于RedProtocol的C# SDK,应用于ChronoCat
警告:当前Red与RedProtocolSharp均处于开发阶段,未来结构可能产生较大变化,请做好随时变更代码的准备
介绍
RedProtocolSharp将RedProtocol基础的消息格式进行了封装,并将收到的消息封为Event,可供开发者快速开发Bot框架
功能表
接收源消息
源消息文本解析
源消息图片解析
源消息at解析
源消息回复解析
源消息发送者信息解析
json消息解析(Red尚未提供实现)
发送文本消息
发送图片消息
发送at消息
发送回复消息
发送合并转发消息
发送语音消息
撤回消息
获取Bot自身消息
获取Bot好友列表(Bug)
获取Bot所在某群群员列表(Bug)
踢人
禁言人
全体禁言
已知问题/feature
- 发送者解析不包含用户权限信息
- GetMemberList返回空数组(打开UI可能可以解决问题)
安装
Nuget搜索RedProtocolSharp安装
或
引入Release下的Dll,并自行安装WebSocketSharp,NewtonSoft.JSON相关依赖(不推荐)
示例
启动Bot
var bot = new Bot("localhost:16530","yourToken");
bot.Start();
注册Logger,MessageReceive订阅
bot.Logger.BotLog.OnLogger += BotLogOnHandler;
bot.MessageReceive.OnMessageReceived += MessageReceiveOnHandler;
private static void MessageReceiveOnHandler(MsgType.Payload payload)
{
}
private static void BotLogOnHandler(BotLogger.Levels levels, string content)
{
Console.WriteLine($"{levels} : {content}");
}
提取消息内容
if (payload is MsgType.Payload<MsgType.MessageRecv> data)
{
string text = data.GetMsgText();
}
发送消息
bool statue = await bot.Send
.SetTarget("114514", BotSend.ChatType.Group)
.AddAt("1919810")
.AddText("123")
.AddPic(@"D:\pic.jpg")
.SendMessage();
//向群114514发送内容为123,艾特用户1919810,附带图片pic.jpg的消息
获取Bot自身信息
var selfInfo = bot.Get.SelfInfo();
踢人
await bot.Action.Kick("114514", "1919810", false, "test");
//从群114514踢出用户1919810,不永拒,理由为test
其他操作请自行探索/类比
案例
LlisBot(尚在开发中,暂未提供)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- Newtonsoft.Json (>= 13.0.3)
- WebSocketSharp (>= 1.0.3-rc11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
初代版本