forked from LenLiin/PCQQ-Protocol--New
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# 接收/回复包 | ||
|
||
#### 添加一个接收包处理 | ||
|
||
1. 首先在`Domains/Commands`下对应目录新建Command, 继承`ReceiveCommand<要处理的包类型>`。 | ||
2. 在新建的Commad上添加`[ReceivePackageCommand(QQCommand.具体你的包名)]`, 这个属性就是包分发的依据,你填写的是什么Command,那么当接收到这个包的时候就会分发给这个类来处理。 | ||
3. 构造函数中实例化对应`Packet`和`QQQEventArgs`。 | ||
4. 在`Process`方法中写你的具体逻辑即可。 | ||
|
||
Tips: 可以参考`Domains/Commands/ReceiveCommands/LoginPingCommand`的写法, 这个是对于Login0x0825包的处理。 | ||
|
||
#### 添加一个回复包 | ||
|
||
1. 首先在`Domains/Commands`下对应目录新建Command, 继承`ResponseCommand<要处理的包类型>`。 | ||
2. 在新建的Commad上添加`[ResponsePacketCommand(QQCommand.具体你的包名)]`, 这个属性就是包分发的依据,你填写的是什么Command,那么当接收到这个包的时候就会分发给这个类来处理。 | ||
3. 构造函数中会传入`QQQEventArgs`。 | ||
4. 在`Process`方法中写你的具体逻辑即可。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# 自定义机器人(非完整版) | ||
|
||
1. 新建你的机器人类`YourRoBotClass`, 实现接口`ServerMessageObserver`。 | ||
2. 构造函数带`ServerMessageSubject`参数, 并在构造函数中添加一行代码`ServerMessageSubject.AddCustomRoBot(this)` | ||
3. 在对应事件实现你想要的功能。 | ||
|
||
demo待补充, 此处暂未重构完 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace QQ.Framework.Domains.Observers | ||
{ | ||
/// <summary> | ||
/// 响应接收到的消息。 | ||
/// 可响应的事件均定义在此处,实现个性化机器人需实现此类 | ||
/// </summary> | ||
public interface ServerMessageObserver | ||
{ | ||
/// <summary> | ||
/// 收到好友消息 | ||
/// </summary> | ||
void ReceiveFriendMessage(); | ||
|
||
/// <summary> | ||
/// 收到群组消息 | ||
/// </summary> | ||
void ReceiveGroupMessage(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using QQ.Framework.Domains.Observers; | ||
|
||
namespace QQ.Framework.Domains | ||
{ | ||
/// <summary> | ||
/// 服务端主题, 用来转发可处理的消息 | ||
/// </summary> | ||
public interface ServerMessageSubject | ||
{ | ||
/// <summary> | ||
/// 将自定义机器人加入观察者列表。 | ||
/// </summary> | ||
/// <param name="robot"></param> | ||
void AddCustomRoBot(ServerMessageObserver robot); | ||
|
||
/// <summary> | ||
/// 将自定义机器人移除观察者列表。 | ||
/// 移除后将不能响应收到的信息。 | ||
/// </summary> | ||
/// <param name="robot"></param> | ||
void RemoveCustomRoBot(ServerMessageObserver robot); | ||
|
||
/// <summary> | ||
/// 收到好友消息 | ||
/// </summary> | ||
void ReceiveFriendMessage(); | ||
|
||
/// <summary> | ||
/// 收到群组消息 | ||
/// </summary> | ||
void ReceiveGroupMessage(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters