Masuda.Net
5.0.2
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 Masuda.Net --version 5.0.2
NuGet\Install-Package Masuda.Net -Version 5.0.2
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="Masuda.Net" Version="5.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Masuda.Net" Version="5.0.2" />
<PackageReference Include="Masuda.Net" />
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 Masuda.Net --version 5.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Masuda.Net, 5.0.2"
#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 Masuda.Net@5.0.2
#: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=Masuda.Net&version=5.0.2
#tool nuget:?package=Masuda.Net&version=5.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
QQ频道机器人官方接口(C#)
实现了一个简易的C#的接口封装,由于目前消息权限卡的很死,需要配置语料才能发送,请注意。
个人开发者需要用ReplyMessageAsync以回复的方式发送消息,回复的消息目前必须与语料配置完全一致才能发出去(tx你在干什么啊tx)。- 上条作废,在沙箱环境中目前可以任意回复。(niiiice)
- 如果不行请在官方管理平台 [https://bot.q.qq.com/] 完成语料配置再测试
- 日程官方似乎还未实装功能
- appid是int类型,appkey,token是string类型,目前appkey不是必须要的值可以随意填入。其他两个按自己的bot信息填入。
- 如果遇到权限问题请尝试踢出机器人再重新加入
- 未来接口可能还会有比较大的改动,请注意。
- 有疑问欢迎提出issue或联系QQ1078995020
说明
目前本项目依赖于.NET6/.NET5,未来可能考虑加入之前版本的包。
本项目力图提供极简风格的api,以实现尽可能少的代码完成bot配置,可参考以下例子。
由于目前很多接口由于过于严格的审核机制导致测试起来很麻烦,目前关于消息方面仅提供简单的文字回复接口,未来测试完毕后会更新。
小功能
- api中所用的时间戳,可以通过以下方法获取
DateTime.Now.ToMillisecond();
- uint类型的Color可以用类似0x1AC456这样赋值,本SDK中也提供了HexColor的属性值来通过字符串设定
- 收到了AT消息后可以通过以下函数获取去除at消息后的内容
GetPureMessage(msg.Content);
如何安装
- VS2022/19通过Nuget包管理器搜索Masuda.Net即可安装。vs19推荐使用5.x.x版本, vs22推荐使用6.x.x版本
- 在项目命令行中输入(需要.net环境)
# .net5
dotnet add package Masuda.Net --version 5.0.1
# .net6
dotnet add package Masuda.Net --version 6.0.1
例子
以下为回复一条消息的简单实现
using Masuda.Net;
using Masuda.Net.HelpMessage;
MasudaBot MasudaBot
= new(appid, appkey, token);
// 沙箱环境
MasudaBot MasudaBot1
= new(appid, appkey, token, sandBox: true);
// 配置回复事件模板
MasudaBot.AtMessageAction += async (bot, msg, type) =>
{
// 回复文本
await bot.ReplyMessageAsync(msg, "muda");
// 组合消息
await bot.ReplyMessageAsync(msg, new PlainMessage("muda"), new AtMessage(msg.Author.Id));
//
};
// 阻塞程序,可以用其他任何方法
while (true)
{
await Task.Delay(10000);
}
另有其他几种启动模式
// 带命令行log输出
MasudaBot MasudaBot
= new(appid, appkey, token, log: true);
// 指定权限
// 默认会请求Intent.AT_MESSAGES, Intent.GUILDS, Intent.GUILD_MEMBERS三个权限, 如已开启了私域,可再请求Intent.NORMAL_MESSAGES权限
MasudaBot MasudaBot
= new(appid, appkey, token, intents: new[] { Intent.GUILDS, Intent.AT_MESSAGES});
// 缺省参数也可以混用
MasudaBot MasudaBot
= new(appid, appkey, token, log: true, intents: new[] { Intent.GUILDS, Intent.AT_MESSAGES});
// 普通消息事件注册
MasudaBot.MessageAction += async (bot, msg, type) =>
{
// 回复文本
await bot.ReplyMessageAsync(msg, "muda");
// 组合消息
await bot.ReplyMessageAsync(msg, new PlainMessage("muda"), new AtMessage(msg.Author.Id));
//
};
Intent表
public enum Intent
{
GUILDS = 1 << 0,
GUILD_MEMBERS = 1 << 1,
NORMAL_MESSAGES = 1 << 9,
GUILD_MESSAGE_REACTIONS = 1 << 10,
DIRECT_MESSAGE = 1 << 12,
FORUM_EVENT = 1 << 28,
AUDIO_ACTION = 1 << 29,
AT_MESSAGES = 1 << 30,
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. 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. 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.
-
net5.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Masuda.Net:
| Repository | Stars |
|---|---|
|
CnGal/CnGalWebSite
CnGal是一个非营利性的,立志于收集整理国内制作组创作的中文Galgame/AVG的介绍、攻略、评测、感想等内容的资料性质的网站。
|
| Version | Downloads | Last Updated |
|---|---|---|
| 6.0.13 | 1,278 | 10/20/2022 |
| 6.0.12 | 515 | 7/1/2022 |
| 6.0.11 | 521 | 6/29/2022 |
| 6.0.10 | 431 | 12/28/2021 |
| 6.0.9 | 377 | 12/24/2021 |
| 6.0.9-preview1.0 | 229 | 12/22/2021 |
| 6.0.8 | 382 | 12/20/2021 |
| 6.0.7 | 428 | 12/19/2021 |
| 6.0.6 | 402 | 12/18/2021 |
| 6.0.5 | 367 | 12/17/2021 |
| 6.0.4 | 391 | 12/16/2021 |
| 6.0.2 | 394 | 12/16/2021 |
| 6.0.0 | 420 | 12/15/2021 |
| 5.0.10 | 410 | 12/28/2021 |
| 5.0.9 | 377 | 12/24/2021 |
| 5.0.9-preview1.0 | 230 | 12/22/2021 |
| 5.0.8 | 369 | 12/20/2021 |
| 5.0.7 | 405 | 12/19/2021 |
| 5.0.6 | 397 | 12/18/2021 |
| 5.0.5 | 396 | 12/17/2021 |
| 5.0.4 | 396 | 12/16/2021 |
| 5.0.2 | 404 | 12/16/2021 |
| 5.0.0 | 413 | 12/15/2021 |
| 4.7.3.10 | 408 | 12/28/2021 |
| 4.7.3 | 400 | 12/20/2021 |
| 1.2.1 | 375 | 12/14/2021 |
| 1.2.0 | 405 | 12/14/2021 |
| 1.1.1 | 370 | 12/14/2021 |
| 1.1.0 | 543 | 12/13/2021 |
| 1.0.2 | 404 | 12/12/2021 |
| 1.0.1 | 378 | 12/12/2021 |
| 1.0.0 | 409 | 12/12/2021 |