# API列表
本处列出的所有地址均为接入点地址(Endpoint),请自行拼接协议头和主机地址得到完整URL
常见的协议有:`ws`、`wss`、`http`、`https`
示例:`/api/manager?token=dummy` --> `ws://localhost:5000/api/manager?token=dummy`
## 数据类型
```golang
type msg_type int
const group_msg = 0
const private_msg = 1
type event_result_type int
const ignore_event = 0
const continue_event = 1
const complete_event = 2
type event_result struct{
type event_result_type
}
type event_result_with_reason struct{
type event_result_type
reason string optional
}
type msg_info struct{
id string
}
```
## `POST /api/manager/get_token`
您仅能通过HTTP Post请求访问该地址
### 请求数据 (`application/x-www-form-urlencoded`):
- user: 用户名
- password: 密码
>[info] 若未配置密码,则可以省略所有参数,直接 Get 或 Post 即可获取Token
> 若已配置密码,也可使用 Get 方法 + Basic Authentication 获取 Token
### 响应数据 (`text/plain`):
- 管理员Token
### 错误数据:
- HTTP状态码非`200(StatusOK)`则视为出错,此时返回信息为错误信息或空信息,格式及含义由具体实现定义
## `RPC /api/manager?token={管理员Token}`
```golang
// Call by client
func register_app(id string) string
func register_account(id string) string
```
## `RPC /api/account?id={帐号端ID}&token={帐号端Token}`
```golang
// Call by client
func on_receive_chat_message(type msg_type, source string, sender string, message string, info msg_info) event_result
func on_member_joined(source string, sender string, inviter string) event_result
func on_member_left(source string, sender string) event_result
func process_group_invitation(sender string, target string, reason string) event_result_with_reason
func process_friend_request(sender string, reason string) event_result_with_reason
func process_membership_request(source string, sender string, inviter string, reason string) event_result_with_reason
// Call by router
func get_group_name(id string) string
func get_user_mame(id string) string
func send_chat_message(type msg_type, source string, target string, message string)
func remove_member(source string, target string)
func shutup_member(source string, target string, duration int)
func shutup_all_member(source string, shutupSwitch bool)
func get_member_mame(source string, target string) string
func get_user_avatar(id string) string
func get_self_id() string
func get_platform_id() string
func get_group_list() []string
func get_member_list(id string) []string
```
## `RPC /api/app?id={应用端ID}&token={应用端Token}`
```golang
// Call by client
func get_group_name(bot string, id string) string
func get_user_mame(bot string, id string) string
func send_chat_message(bot string, type msg_type, source string, target string, message string)
func remove_member(bot string, source string, target string)
func shutup_member(bot string, source string, target string, duration int)
func shutup_all_member(bot string, source string, shutupSwitch bool)
func get_member_mame(bot string, source string, target string) string
func get_user_avatar(bot string, id string) string
func get_self_id(bot string) string
func get_platform_id(bot string) string
func get_group_list(bot string) []string
func get_member_list(bot string, id string) []string
// Call by router
func on_receive_chat_message(type msg_type, source string, sender string, message string, info msg_info) event_result
func on_member_joined(source string, sender string, inviter string) event_result
func on_member_left(source string, sender string) event_result
func process_group_invitation(bot string, sender string, target string, reason string) event_result_with_reason
func process_friend_request(bot string, sender string, reason string) event_result_with_reason
func process_membership_request(bot string, source string, sender string, inviter string, reason string) event_result_with_reason
```
## `RPC {Webhook控制器}`
在原有RPC连接上添加参数`webhook=1`表示连接到webhook控制器,此时您可以通过HTTP Post方法调用控制器的RPC方法注册、删除Webhook(参考[RPC通道](RPCChannel.md)中有关“HTTP Post 模式”的说明)
```golang
type webhook_info struct{
token string
address string
}
func create_webhook(address string) webhook_info
func delete_webhook(id string)
```