go_dreamfactory/cmd/robot/readme.md
2022-06-09 18:45:50 +08:00

60 lines
896 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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)
...
}
```