60 lines
896 B
Markdown
60 lines
896 B
Markdown
# Robot使用
|
||
|
||
## 命令行
|
||
```sh
|
||
#使用已存在的账号测试接口
|
||
go run cmd.go run --account yourAccount
|
||
```
|
||
|
||
```sh
|
||
#使用新账号测试接口
|
||
go run cmd.go run --account newAccount --create true
|
||
```
|
||
|
||
@[TOC]
|
||
|
||
|
||
### 添加测试接口
|
||
|
||
* 请求的方法
|
||
|
||
```go
|
||
// 好友申请,参数根据实际业务添加
|
||
func (r *Robot) FriendApply(friendIds []string) {
|
||
...
|
||
}
|
||
```
|
||
|
||
* 响应的方法
|
||
|
||
```go
|
||
func (r *Robot) handleFriendApply(msg *pb.UserMessage) {
|
||
...
|
||
}
|
||
```
|
||
|
||
### 添加subType,调用响应方法
|
||
|
||
```go
|
||
//根据实际情况添加subtype
|
||
func (r *Robot) handleFriendMsg(msg *pb.UserMessage) {
|
||
switch msg.SubType {
|
||
case "apply":
|
||
//调用响应
|
||
r.handleFriendApply(msg)
|
||
}
|
||
}
|
||
```
|
||
|
||
### 修改请求方法调用
|
||
|
||
```go
|
||
func (r *Robot) onUserLoaded() {
|
||
switch msg.MainType {
|
||
case "user":
|
||
r.handleUserMsg(msg)
|
||
case "friend":
|
||
r.handleFriendMsg(msg)
|
||
...
|
||
}
|
||
``` |