ProcedureOrientedSessionFramework 1.0.0
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 ProcedureOrientedSessionFramework --version 1.0.0
NuGet\Install-Package ProcedureOrientedSessionFramework -Version 1.0.0
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="ProcedureOrientedSessionFramework" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ProcedureOrientedSessionFramework --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ProcedureOrientedSessionFramework, 1.0.0"
#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 ProcedureOrientedSessionFramework as a Cake Addin #addin nuget:?package=ProcedureOrientedSessionFramework&version=1.0.0 // Install ProcedureOrientedSessionFramework as a Cake Tool #tool nuget:?package=ProcedureOrientedSessionFramework&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ProcedureOrientedSessionFramework
介绍
面向对象基于会话的Mirai机器人开发框架
为什么需要
新手开发机器人时,常因为各种风骚的异步写法无法简单上手。
本框架倒行逆施,将异步写法封装成了同步的,主要业务流程可以直接顺序写完,方便新手上手,在编写一些基于固定顺序逻辑的项目时也很方便。
安装教程
建议使用Nuget安装
也可以克隆本仓库并创建项目引用
示例代码
In program.cs write:
static void Main(){
long qq=123456;//Your qq logged in on Mirai
var opt = new MiraiHttpSessionOptions();
//Fill your own options here
var session = new MiraiHttpSession();
session.ConnectAsync(options, qq).Wait();
SessionHandler sh = new SessionHandler(session, (msg,sess)=>new MyProcedure(msg,sess));
// SessionHandler call its second parameter evey time to get a user defined procedure
// when a message is received and no procedure exists to handle that session.
// If no procedure should be started, return null is fine.
}
Create a new class called MyProcedure and let it inherit ProcedureOrientedSessionFramework.Procedure:
using ProcedureOrientedSessionFramework;
class MyProcedure : Procedure
{
public MyProcedure (Procedure.Message msg, MiraiHttpSession ss) : base(msg, ss) { }
// Always remember to pass the constructor parameters to base class.
// It will handle many operation for you.
public override void Main()
{
ReadLine();
// The first read message operation (any kind of read) gets the message that led to the procedure creation.
// To avoid confusion, we get rid of it first.
string str = ReadLine();// Read all the text components in the next message.
WriteLine("You wrote:" + str);// Send a simple text message to user.
//Send mixed message (with texts and pictures, in any order and amount you provide) to user.
WriteObject(Txt("This is a block of string"),
Pic(new Bitmap())//This is a block of image. Accepts Bitmap format, and handle it as PNG files.
);
}
}
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net5.0
- Mirai-CSharp (>= 1.0.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.