1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-08 04:55:55 +08:00

refactor: simply api gen annotation

This commit is contained in:
wdvxdr 2021-10-29 22:15:00 +08:00
parent 18944198ae
commit 625322d7e7
No known key found for this signature in database
GPG Key ID: 703F8C071DE7A1B6
2 changed files with 131 additions and 120 deletions

View File

@ -138,20 +138,24 @@ func main() {
case "": case "":
continue continue
case "route": case "route":
router.Path = args["path"] router.Path = args
if args["alias"] != "" { case "alias":
router.Aliases = append(router.Aliases, args["alias"]) router.Aliases = append(router.Aliases, args)
case "default":
for name, value := range parseMap(args, "=") {
for i, p := range router.Params {
if p.Name == name {
router.Params[i].Default = convDefault(value, p.Type)
}
}
} }
case "param": case "rename":
i, err := strconv.Atoi(args["index"]) for name, value := range parseMap(args, "->") {
if err != nil { for i, p := range router.Params {
continue if p.Name == name {
} router.Params[i].Name = value
if args["name"] != "" { }
router.Params[i].Name = args["name"] }
}
if args["default"] != "" {
router.Params[i].Default = convDefault(args["default"], router.Params[i].Type)
} }
} }
} }
@ -180,34 +184,42 @@ func main() {
} }
} }
func match(text string) (string, map[string]string) { func unquote(s string) string {
switch s[0] {
case '"':
s, _ = strconv.Unquote(s)
case '`':
s = strings.Trim(s, "`")
}
return s
}
func parseMap(input string, sep string) map[string]string {
out := make(map[string]string)
for _, arg := range strings.Split(input, ",") {
k, v, ok := cut(arg, sep)
if !ok {
out[k] = "true"
}
k = strings.TrimSpace(k)
v = unquote(strings.TrimSpace(v))
out[k] = v
}
return out
}
func match(text string) (string, string) {
text = strings.TrimPrefix(text, "//") text = strings.TrimPrefix(text, "//")
text = strings.TrimSpace(text) text = strings.TrimSpace(text)
if !strings.HasPrefix(text, "@") || !strings.HasSuffix(text, ")") { if !strings.HasPrefix(text, "@") || !strings.HasSuffix(text, ")") {
return "", nil return "", ""
} }
text = strings.Trim(text, "@)") text = strings.Trim(text, "@)")
cmd, args, ok := cut(text, "(") cmd, args, ok := cut(text, "(")
if !ok { if !ok {
return "", nil return "", ""
} }
params := make(map[string]string) return cmd, unquote(args)
for _, arg := range strings.Split(args, ",") {
k, v, ok := cut(arg, "=")
if !ok {
params[k] = "true"
}
k = strings.TrimSpace(k)
v = strings.TrimSpace(v)
switch v[0] {
case '"':
v, _ = strconv.Unquote(v)
case '`':
v = strings.Trim(v, "`")
}
params[k] = v
}
return cmd, params
} }
func cut(s, sep string) (before, after string, found bool) { func cut(s, sep string) (before, after string, found bool) {

View File

@ -32,13 +32,13 @@ import (
// CQGetLoginInfo 获取登录号信息 // CQGetLoginInfo 获取登录号信息
// //
// https://git.io/Jtz1I // https://git.io/Jtz1I
// @route(path=get_login_info) // @route(get_login_info)
func (bot *CQBot) CQGetLoginInfo() global.MSG { func (bot *CQBot) CQGetLoginInfo() global.MSG {
return OK(global.MSG{"user_id": bot.Client.Uin, "nickname": bot.Client.Nickname}) return OK(global.MSG{"user_id": bot.Client.Uin, "nickname": bot.Client.Nickname})
} }
// CQGetQiDianAccountInfo 获取企点账号信息 // CQGetQiDianAccountInfo 获取企点账号信息
// @route(path=qidian_get_account_info) // @route(qidian_get_account_info)
func (bot *CQBot) CQGetQiDianAccountInfo() global.MSG { func (bot *CQBot) CQGetQiDianAccountInfo() global.MSG {
if bot.Client.QiDian == nil { if bot.Client.QiDian == nil {
return Failed(100, "QIDIAN_PROTOCOL_REQUEST", "请使用企点协议") return Failed(100, "QIDIAN_PROTOCOL_REQUEST", "请使用企点协议")
@ -53,7 +53,7 @@ func (bot *CQBot) CQGetQiDianAccountInfo() global.MSG {
// CQGetFriendList 获取好友列表 // CQGetFriendList 获取好友列表
// //
// https://git.io/Jtz1L // https://git.io/Jtz1L
// @route(path=get_friend_list) // @route(get_friend_list)
func (bot *CQBot) CQGetFriendList() global.MSG { func (bot *CQBot) CQGetFriendList() global.MSG {
fs := make([]global.MSG, 0, len(bot.Client.FriendList)) fs := make([]global.MSG, 0, len(bot.Client.FriendList))
for _, f := range bot.Client.FriendList { for _, f := range bot.Client.FriendList {
@ -68,7 +68,7 @@ func (bot *CQBot) CQGetFriendList() global.MSG {
// CQGetUnidirectionalFriendList 获取单向好友列表 // CQGetUnidirectionalFriendList 获取单向好友列表
// //
// @route(path=get_unidirectional_friend_list) // @route(get_unidirectional_friend_list)
func (bot *CQBot) CQGetUnidirectionalFriendList() global.MSG { func (bot *CQBot) CQGetUnidirectionalFriendList() global.MSG {
list, err := bot.Client.GetUnidirectionalFriendList() list, err := bot.Client.GetUnidirectionalFriendList()
if err != nil { if err != nil {
@ -88,8 +88,8 @@ func (bot *CQBot) CQGetUnidirectionalFriendList() global.MSG {
// CQDeleteUnidirectionalFriend 删除单向好友 // CQDeleteUnidirectionalFriend 删除单向好友
// //
// @route(path=delete_unidirectional_friend) // @route(delete_unidirectional_friend)
// @param(index=0, name=user_id) // @rename(uin->user_id)
func (bot *CQBot) CQDeleteUnidirectionalFriend(uin int64) global.MSG { func (bot *CQBot) CQDeleteUnidirectionalFriend(uin int64) global.MSG {
list, err := bot.Client.GetUnidirectionalFriendList() list, err := bot.Client.GetUnidirectionalFriendList()
if err != nil { if err != nil {
@ -109,8 +109,8 @@ func (bot *CQBot) CQDeleteUnidirectionalFriend(uin int64) global.MSG {
} }
// CQDeleteFriend 删除好友 // CQDeleteFriend 删除好友
// @route(path=delete_friend) // @route(delete_friend)
// @param(index=0,name="[user_id\x2Cid].0") // @rename(uin->"[user_id\x2Cid].0")
func (bot *CQBot) CQDeleteFriend(uin int64) global.MSG { func (bot *CQBot) CQDeleteFriend(uin int64) global.MSG {
if bot.Client.FindFriend(uin) == nil { if bot.Client.FindFriend(uin) == nil {
return Failed(100, "FRIEND_NOT_FOUND", "好友不存在") return Failed(100, "FRIEND_NOT_FOUND", "好友不存在")
@ -125,7 +125,7 @@ func (bot *CQBot) CQDeleteFriend(uin int64) global.MSG {
// CQGetGroupList 获取群列表 // CQGetGroupList 获取群列表
// //
// https://git.io/Jtz1t // https://git.io/Jtz1t
// @route(path=get_group_list) // @route(get_group_list)
func (bot *CQBot) CQGetGroupList(noCache bool) global.MSG { func (bot *CQBot) CQGetGroupList(noCache bool) global.MSG {
gs := make([]global.MSG, 0, len(bot.Client.GroupList)) gs := make([]global.MSG, 0, len(bot.Client.GroupList))
if noCache { if noCache {
@ -148,7 +148,7 @@ func (bot *CQBot) CQGetGroupList(noCache bool) global.MSG {
// CQGetGroupInfo 获取群信息 // CQGetGroupInfo 获取群信息
// //
// https://git.io/Jtz1O // https://git.io/Jtz1O
// @route(path=get_group_info) // @route(get_group_info)
func (bot *CQBot) CQGetGroupInfo(groupID int64, noCache bool) global.MSG { func (bot *CQBot) CQGetGroupInfo(groupID int64, noCache bool) global.MSG {
group := bot.Client.FindGroup(groupID) group := bot.Client.FindGroup(groupID)
if group == nil || noCache { if group == nil || noCache {
@ -190,7 +190,7 @@ func (bot *CQBot) CQGetGroupInfo(groupID int64, noCache bool) global.MSG {
// CQGetGroupMemberList 获取群成员列表 // CQGetGroupMemberList 获取群成员列表
// //
// https://git.io/Jtz13 // https://git.io/Jtz13
// @route(path=get_group_member_list) // @route(get_group_member_list)
func (bot *CQBot) CQGetGroupMemberList(groupID int64, noCache bool) global.MSG { func (bot *CQBot) CQGetGroupMemberList(groupID int64, noCache bool) global.MSG {
group := bot.Client.FindGroup(groupID) group := bot.Client.FindGroup(groupID)
if group == nil { if group == nil {
@ -214,7 +214,7 @@ func (bot *CQBot) CQGetGroupMemberList(groupID int64, noCache bool) global.MSG {
// CQGetGroupMemberInfo 获取群成员信息 // CQGetGroupMemberInfo 获取群成员信息
// //
// https://git.io/Jtz1s // https://git.io/Jtz1s
// @route(path=get_group_member_info) // @route(get_group_member_info)
func (bot *CQBot) CQGetGroupMemberInfo(groupID, userID int64, noCache bool) global.MSG { func (bot *CQBot) CQGetGroupMemberInfo(groupID, userID int64, noCache bool) global.MSG {
group := bot.Client.FindGroup(groupID) group := bot.Client.FindGroup(groupID)
if group == nil { if group == nil {
@ -240,7 +240,7 @@ func (bot *CQBot) CQGetGroupMemberInfo(groupID, userID int64, noCache bool) glob
// CQGetGroupFileSystemInfo 扩展API-获取群文件系统信息 // CQGetGroupFileSystemInfo 扩展API-获取群文件系统信息
// //
// https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E4%BF%A1%E6%81%AF // https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E4%BF%A1%E6%81%AF
// @route(path=get_group_file_system_info) // @route(get_group_file_system_info)
func (bot *CQBot) CQGetGroupFileSystemInfo(groupID int64) global.MSG { func (bot *CQBot) CQGetGroupFileSystemInfo(groupID int64) global.MSG {
fs, err := bot.Client.GetGroupFileSystem(groupID) fs, err := bot.Client.GetGroupFileSystem(groupID)
if err != nil { if err != nil {
@ -253,7 +253,7 @@ func (bot *CQBot) CQGetGroupFileSystemInfo(groupID int64) global.MSG {
// CQGetGroupRootFiles 扩展API-获取群根目录文件列表 // CQGetGroupRootFiles 扩展API-获取群根目录文件列表
// //
// https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%A0%B9%E7%9B%AE%E5%BD%95%E6%96%87%E4%BB%B6%E5%88%97%E8%A1%A8 // https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%A0%B9%E7%9B%AE%E5%BD%95%E6%96%87%E4%BB%B6%E5%88%97%E8%A1%A8
// @route(path=get_group_root_files) // @route(get_group_root_files)
func (bot *CQBot) CQGetGroupRootFiles(groupID int64) global.MSG { func (bot *CQBot) CQGetGroupRootFiles(groupID int64) global.MSG {
fs, err := bot.Client.GetGroupFileSystem(groupID) fs, err := bot.Client.GetGroupFileSystem(groupID)
if err != nil { if err != nil {
@ -274,7 +274,7 @@ func (bot *CQBot) CQGetGroupRootFiles(groupID int64) global.MSG {
// CQGetGroupFilesByFolderID 扩展API-获取群子目录文件列表 // CQGetGroupFilesByFolderID 扩展API-获取群子目录文件列表
// //
// https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%BE%A4%E5%AD%90%E7%9B%AE%E5%BD%95%E6%96%87%E4%BB%B6%E5%88%97%E8%A1%A8 // https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%BE%A4%E5%AD%90%E7%9B%AE%E5%BD%95%E6%96%87%E4%BB%B6%E5%88%97%E8%A1%A8
// @route(path=get_group_files_by_folder) // @route(get_group_files_by_folder)
func (bot *CQBot) CQGetGroupFilesByFolderID(groupID int64, folderID string) global.MSG { func (bot *CQBot) CQGetGroupFilesByFolderID(groupID int64, folderID string) global.MSG {
fs, err := bot.Client.GetGroupFileSystem(groupID) fs, err := bot.Client.GetGroupFileSystem(groupID)
if err != nil { if err != nil {
@ -295,7 +295,7 @@ func (bot *CQBot) CQGetGroupFilesByFolderID(groupID int64, folderID string) glob
// CQGetGroupFileURL 扩展API-获取群文件资源链接 // CQGetGroupFileURL 扩展API-获取群文件资源链接
// //
// https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%96%87%E4%BB%B6%E8%B5%84%E6%BA%90%E9%93%BE%E6%8E%A5 // https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%96%87%E4%BB%B6%E8%B5%84%E6%BA%90%E9%93%BE%E6%8E%A5
// @route(path=get_group_file_url) // @route(get_group_file_url)
func (bot *CQBot) CQGetGroupFileURL(groupID int64, fileID string, busID int32) global.MSG { func (bot *CQBot) CQGetGroupFileURL(groupID int64, fileID string, busID int32) global.MSG {
url := bot.Client.GetGroupFileUrl(groupID, fileID, busID) url := bot.Client.GetGroupFileUrl(groupID, fileID, busID)
if url == "" { if url == "" {
@ -309,7 +309,7 @@ func (bot *CQBot) CQGetGroupFileURL(groupID int64, fileID string, busID int32) g
// CQUploadGroupFile 扩展API-上传群文件 // CQUploadGroupFile 扩展API-上传群文件
// //
// https://docs.go-cqhttp.org/api/#%E4%B8%8A%E4%BC%A0%E7%BE%A4%E6%96%87%E4%BB%B6 // https://docs.go-cqhttp.org/api/#%E4%B8%8A%E4%BC%A0%E7%BE%A4%E6%96%87%E4%BB%B6
// @route(path=upload_group_file) // @route(upload_group_file)
func (bot *CQBot) CQUploadGroupFile(groupID int64, file, name, folder string) global.MSG { func (bot *CQBot) CQUploadGroupFile(groupID int64, file, name, folder string) global.MSG {
if !global.PathExists(file) { if !global.PathExists(file) {
log.Errorf("上传群文件 %v 失败: 文件不存在", file) log.Errorf("上传群文件 %v 失败: 文件不存在", file)
@ -332,7 +332,7 @@ func (bot *CQBot) CQUploadGroupFile(groupID int64, file, name, folder string) gl
// CQGroupFileCreateFolder 拓展API-创建群文件文件夹 // CQGroupFileCreateFolder 拓展API-创建群文件文件夹
// //
// @route(path=create_group_file_folder) // @route(create_group_file_folder)
func (bot *CQBot) CQGroupFileCreateFolder(groupID int64, parentID, name string) global.MSG { func (bot *CQBot) CQGroupFileCreateFolder(groupID int64, parentID, name string) global.MSG {
fs, err := bot.Client.GetGroupFileSystem(groupID) fs, err := bot.Client.GetGroupFileSystem(groupID)
if err != nil { if err != nil {
@ -348,8 +348,8 @@ func (bot *CQBot) CQGroupFileCreateFolder(groupID int64, parentID, name string)
// CQGroupFileDeleteFolder 拓展API-删除群文件文件夹 // CQGroupFileDeleteFolder 拓展API-删除群文件文件夹
// //
// @route(path=delete_group_folder) // @route(delete_group_folder)
// @param(index=1, name=folder_id) // @rename(id->folder_id)
func (bot *CQBot) CQGroupFileDeleteFolder(groupID int64, id string) global.MSG { func (bot *CQBot) CQGroupFileDeleteFolder(groupID int64, id string) global.MSG {
fs, err := bot.Client.GetGroupFileSystem(groupID) fs, err := bot.Client.GetGroupFileSystem(groupID)
if err != nil { if err != nil {
@ -365,8 +365,8 @@ func (bot *CQBot) CQGroupFileDeleteFolder(groupID int64, id string) global.MSG {
// CQGroupFileDeleteFile 拓展API-删除群文件 // CQGroupFileDeleteFile 拓展API-删除群文件
// //
// @route(path=delete_group_file) // @route(delete_group_file)
// @param(index=1, name=file_id) // @rename(id->file_id)
func (bot *CQBot) CQGroupFileDeleteFile(groupID int64, id string, busID int32) global.MSG { func (bot *CQBot) CQGroupFileDeleteFile(groupID int64, id string, busID int32) global.MSG {
fs, err := bot.Client.GetGroupFileSystem(groupID) fs, err := bot.Client.GetGroupFileSystem(groupID)
if err != nil { if err != nil {
@ -383,7 +383,7 @@ func (bot *CQBot) CQGroupFileDeleteFile(groupID int64, id string, busID int32) g
// CQGetWordSlices 隐藏API-获取中文分词 // CQGetWordSlices 隐藏API-获取中文分词
// //
// https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E4%B8%AD%E6%96%87%E5%88%86%E8%AF%8D-%E9%9A%90%E8%97%8F-api // https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E4%B8%AD%E6%96%87%E5%88%86%E8%AF%8D-%E9%9A%90%E8%97%8F-api
// @route(path=.get_word_slices) // @route(.get_word_slices)
func (bot *CQBot) CQGetWordSlices(content string) global.MSG { func (bot *CQBot) CQGetWordSlices(content string) global.MSG {
slices, err := bot.Client.GetWordSegmentation(content) slices, err := bot.Client.GetWordSegmentation(content)
if err != nil { if err != nil {
@ -397,8 +397,8 @@ func (bot *CQBot) CQGetWordSlices(content string) global.MSG {
// CQSendMessage 发送消息 // CQSendMessage 发送消息
// //
// @route(path=send_msg) // @route(send_msg)
// @param(index=2, name=message) // @rename(m->message)
func (bot *CQBot) CQSendMessage(groupID, userID int64, m gjson.Result, messageType string, autoEscape bool) global.MSG { func (bot *CQBot) CQSendMessage(groupID, userID int64, m gjson.Result, messageType string, autoEscape bool) global.MSG {
switch { switch {
case messageType == "group": case messageType == "group":
@ -416,8 +416,8 @@ func (bot *CQBot) CQSendMessage(groupID, userID int64, m gjson.Result, messageTy
// CQSendGroupMessage 发送群消息 // CQSendGroupMessage 发送群消息
// //
// https://git.io/Jtz1c // https://git.io/Jtz1c
// @route(path=send_group_msg) // @route(send_group_msg)
// @param(index=1, name=message) // @rename(m->message)
func (bot *CQBot) CQSendGroupMessage(groupID int64, m gjson.Result, autoEscape bool) global.MSG { func (bot *CQBot) CQSendGroupMessage(groupID int64, m gjson.Result, autoEscape bool) global.MSG {
group := bot.Client.FindGroup(groupID) group := bot.Client.FindGroup(groupID)
if group == nil { if group == nil {
@ -463,8 +463,8 @@ func (bot *CQBot) CQSendGroupMessage(groupID int64, m gjson.Result, autoEscape b
// CQSendGroupForwardMessage 扩展API-发送合并转发(群) // CQSendGroupForwardMessage 扩展API-发送合并转发(群)
// //
// https://docs.go-cqhttp.org/api/#%E5%8F%91%E9%80%81%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91-%E7%BE%A4 // https://docs.go-cqhttp.org/api/#%E5%8F%91%E9%80%81%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91-%E7%BE%A4
// @route(path=send_group_forward_msg) // @route(send_group_forward_msg)
// @param(index=1, name=messages) // @rename(m->messages)
func (bot *CQBot) CQSendGroupForwardMessage(groupID int64, m gjson.Result) global.MSG { func (bot *CQBot) CQSendGroupForwardMessage(groupID int64, m gjson.Result) global.MSG {
if m.Type != gjson.JSON { if m.Type != gjson.JSON {
return Failed(100) return Failed(100)
@ -596,8 +596,8 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupID int64, m gjson.Result) globa
// CQSendPrivateMessage 发送私聊消息 // CQSendPrivateMessage 发送私聊消息
// //
// https://git.io/Jtz1l // https://git.io/Jtz1l
// @route(path=send_private_msg) // @route(send_private_msg)
// @param(index=2, name=message) // @rename(m->message)
func (bot *CQBot) CQSendPrivateMessage(userID int64, groupID int64, m gjson.Result, autoEscape bool) global.MSG { func (bot *CQBot) CQSendPrivateMessage(userID int64, groupID int64, m gjson.Result, autoEscape bool) global.MSG {
var elem []message.IMessageElement var elem []message.IMessageElement
if m.Type == gjson.JSON { if m.Type == gjson.JSON {
@ -624,7 +624,7 @@ func (bot *CQBot) CQSendPrivateMessage(userID int64, groupID int64, m gjson.Resu
// CQSetGroupCard 设置群名片(群备注) // CQSetGroupCard 设置群名片(群备注)
// //
// https://git.io/Jtz1B // https://git.io/Jtz1B
// @route(path=set_group_card) // @route(set_group_card)
func (bot *CQBot) CQSetGroupCard(groupID, userID int64, card string) global.MSG { func (bot *CQBot) CQSetGroupCard(groupID, userID int64, card string) global.MSG {
if g := bot.Client.FindGroup(groupID); g != nil { if g := bot.Client.FindGroup(groupID); g != nil {
if m := g.FindMember(userID); m != nil { if m := g.FindMember(userID); m != nil {
@ -638,7 +638,7 @@ func (bot *CQBot) CQSetGroupCard(groupID, userID int64, card string) global.MSG
// CQSetGroupSpecialTitle 设置群组专属头衔 // CQSetGroupSpecialTitle 设置群组专属头衔
// //
// https://git.io/Jtz10 // https://git.io/Jtz10
// @route(path=set_group_special_title) // @route(set_group_special_title)
func (bot *CQBot) CQSetGroupSpecialTitle(groupID, userID int64, title string) global.MSG { func (bot *CQBot) CQSetGroupSpecialTitle(groupID, userID int64, title string) global.MSG {
if g := bot.Client.FindGroup(groupID); g != nil { if g := bot.Client.FindGroup(groupID); g != nil {
if m := g.FindMember(userID); m != nil { if m := g.FindMember(userID); m != nil {
@ -652,8 +652,8 @@ func (bot *CQBot) CQSetGroupSpecialTitle(groupID, userID int64, title string) gl
// CQSetGroupName 设置群名 // CQSetGroupName 设置群名
// //
// https://git.io/Jtz12 // https://git.io/Jtz12
// @route(path=set_group_name) // @route(set_group_name)
// @param(index=1, name=group_name) // @rename(name->group_name)
func (bot *CQBot) CQSetGroupName(groupID int64, name string) global.MSG { func (bot *CQBot) CQSetGroupName(groupID int64, name string) global.MSG {
if g := bot.Client.FindGroup(groupID); g != nil { if g := bot.Client.FindGroup(groupID); g != nil {
g.UpdateName(name) g.UpdateName(name)
@ -665,9 +665,8 @@ func (bot *CQBot) CQSetGroupName(groupID int64, name string) global.MSG {
// CQSetGroupMemo 扩展API-发送群公告 // CQSetGroupMemo 扩展API-发送群公告
// //
// https://docs.go-cqhttp.org/api/#%E5%8F%91%E9%80%81%E7%BE%A4%E5%85%AC%E5%91%8A // https://docs.go-cqhttp.org/api/#%E5%8F%91%E9%80%81%E7%BE%A4%E5%85%AC%E5%91%8A
// @route(path=_send_group_notice) // @route(_send_group_notice)
// @param(index=1, name=content) // @rename(msg->content, img->image)
// @param(index=2, name=image)
func (bot *CQBot) CQSetGroupMemo(groupID int64, msg, img string) global.MSG { func (bot *CQBot) CQSetGroupMemo(groupID int64, msg, img string) global.MSG {
if g := bot.Client.FindGroup(groupID); g != nil { if g := bot.Client.FindGroup(groupID); g != nil {
if g.SelfPermission() == client.Member { if g.SelfPermission() == client.Member {
@ -696,9 +695,8 @@ func (bot *CQBot) CQSetGroupMemo(groupID int64, msg, img string) global.MSG {
// CQSetGroupKick 群组踢人 // CQSetGroupKick 群组踢人
// //
// https://git.io/Jtz1V // https://git.io/Jtz1V
// @route(path=set_group_kick) // @route(set_group_kick)
// @param(index=2, name=message) // @rename(msg->message, block->reject_add_request)
// @param(index=3, name=reject_add_request)
func (bot *CQBot) CQSetGroupKick(groupID int64, userID int64, msg string, block bool) global.MSG { func (bot *CQBot) CQSetGroupKick(groupID int64, userID int64, msg string, block bool) global.MSG {
if g := bot.Client.FindGroup(groupID); g != nil { if g := bot.Client.FindGroup(groupID); g != nil {
if m := g.FindMember(userID); m != nil { if m := g.FindMember(userID); m != nil {
@ -715,8 +713,8 @@ func (bot *CQBot) CQSetGroupKick(groupID int64, userID int64, msg string, block
// CQSetGroupBan 群组单人禁言 // CQSetGroupBan 群组单人禁言
// //
// https://git.io/Jtz1w // https://git.io/Jtz1w
// @route(path=set_group_ban) // @route(set_group_ban)
// @param(index=2, default=1800) // @default(duration=1800)
func (bot *CQBot) CQSetGroupBan(groupID, userID int64, duration uint32) global.MSG { func (bot *CQBot) CQSetGroupBan(groupID, userID int64, duration uint32) global.MSG {
if g := bot.Client.FindGroup(groupID); g != nil { if g := bot.Client.FindGroup(groupID); g != nil {
if m := g.FindMember(userID); m != nil { if m := g.FindMember(userID); m != nil {
@ -736,8 +734,8 @@ func (bot *CQBot) CQSetGroupBan(groupID, userID int64, duration uint32) global.M
// CQSetGroupWholeBan 群组全员禁言 // CQSetGroupWholeBan 群组全员禁言
// //
// https://git.io/Jtz1o // https://git.io/Jtz1o
// @route(path=set_group_whole_ban) // @route(set_group_whole_ban)
// @param(index=1, default=true) // @default(enable=true)
func (bot *CQBot) CQSetGroupWholeBan(groupID int64, enable bool) global.MSG { func (bot *CQBot) CQSetGroupWholeBan(groupID int64, enable bool) global.MSG {
if g := bot.Client.FindGroup(groupID); g != nil { if g := bot.Client.FindGroup(groupID); g != nil {
g.MuteAll(enable) g.MuteAll(enable)
@ -749,7 +747,7 @@ func (bot *CQBot) CQSetGroupWholeBan(groupID int64, enable bool) global.MSG {
// CQSetGroupLeave 退出群组 // CQSetGroupLeave 退出群组
// //
// https://git.io/Jtz1K // https://git.io/Jtz1K
// @route(path=set_group_leave) // @route(set_group_leave)
func (bot *CQBot) CQSetGroupLeave(groupID int64) global.MSG { func (bot *CQBot) CQSetGroupLeave(groupID int64) global.MSG {
if g := bot.Client.FindGroup(groupID); g != nil { if g := bot.Client.FindGroup(groupID); g != nil {
g.Quit() g.Quit()
@ -761,7 +759,7 @@ func (bot *CQBot) CQSetGroupLeave(groupID int64) global.MSG {
// CQGetAtAllRemain 扩展API-获取群 @全体成员 剩余次数 // CQGetAtAllRemain 扩展API-获取群 @全体成员 剩余次数
// //
// https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%BE%A4-%E5%85%A8%E4%BD%93%E6%88%90%E5%91%98-%E5%89%A9%E4%BD%99%E6%AC%A1%E6%95%B0 // https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%BE%A4-%E5%85%A8%E4%BD%93%E6%88%90%E5%91%98-%E5%89%A9%E4%BD%99%E6%AC%A1%E6%95%B0
// @route(path=get_group_at_all_remain) // @route(get_group_at_all_remain)
func (bot *CQBot) CQGetAtAllRemain(groupID int64) global.MSG { func (bot *CQBot) CQGetAtAllRemain(groupID int64) global.MSG {
if g := bot.Client.FindGroup(groupID); g != nil { if g := bot.Client.FindGroup(groupID); g != nil {
i, err := bot.Client.GetAtAllRemain(groupID) i, err := bot.Client.GetAtAllRemain(groupID)
@ -776,8 +774,8 @@ func (bot *CQBot) CQGetAtAllRemain(groupID int64) global.MSG {
// CQProcessFriendRequest 处理加好友请求 // CQProcessFriendRequest 处理加好友请求
// //
// https://git.io/Jtz11 // https://git.io/Jtz11
// @route(path=set_friend_add_request) // @route(set_friend_add_request)
// @param(index=1, default=true) // @default(approve=true)
func (bot *CQBot) CQProcessFriendRequest(flag string, approve bool) global.MSG { func (bot *CQBot) CQProcessFriendRequest(flag string, approve bool) global.MSG {
req, ok := bot.friendReqCache.Load(flag) req, ok := bot.friendReqCache.Load(flag)
if !ok { if !ok {
@ -794,9 +792,9 @@ func (bot *CQBot) CQProcessFriendRequest(flag string, approve bool) global.MSG {
// CQProcessGroupRequest 处理加群请求/邀请 // CQProcessGroupRequest 处理加群请求/邀请
// //
// https://git.io/Jtz1D // https://git.io/Jtz1D
// @route(path=set_group_add_request) // @route(set_group_add_request)
// @param(index=1, name="[sub_type\x2Ctype].0") // @rename(sub_type->"[sub_type\x2Ctype].0")
// @param(index=3, default=true) // @default(approve=true)
func (bot *CQBot) CQProcessGroupRequest(flag, subType, reason string, approve bool) global.MSG { func (bot *CQBot) CQProcessGroupRequest(flag, subType, reason string, approve bool) global.MSG {
msgs, err := bot.Client.GetGroupSystemMessages() msgs, err := bot.Client.GetGroupSystemMessages()
if err != nil { if err != nil {
@ -841,7 +839,7 @@ func (bot *CQBot) CQProcessGroupRequest(flag, subType, reason string, approve bo
// CQDeleteMessage 撤回消息 // CQDeleteMessage 撤回消息
// //
// https:// git.io/Jtz1y // https:// git.io/Jtz1y
// @route(path=delete_msg) // @route(delete_msg)
func (bot *CQBot) CQDeleteMessage(messageID int32) global.MSG { func (bot *CQBot) CQDeleteMessage(messageID int32) global.MSG {
msg, err := db.GetMessageByGlobalID(messageID) msg, err := db.GetMessageByGlobalID(messageID)
if err != nil { if err != nil {
@ -872,8 +870,8 @@ func (bot *CQBot) CQDeleteMessage(messageID int32) global.MSG {
// CQSetGroupAdmin 群组设置管理员 // CQSetGroupAdmin 群组设置管理员
// //
// https://git.io/Jtz1S // https://git.io/Jtz1S
// @route(path=set_group_admin) // @route(set_group_admin)
// @param(index=2, default=true) // @default(enable=true)
func (bot *CQBot) CQSetGroupAdmin(groupID, userID int64, enable bool) global.MSG { func (bot *CQBot) CQSetGroupAdmin(groupID, userID int64, enable bool) global.MSG {
group := bot.Client.FindGroup(groupID) group := bot.Client.FindGroup(groupID)
if group == nil || group.OwnerUin != bot.Client.Uin { if group == nil || group.OwnerUin != bot.Client.Uin {
@ -896,7 +894,7 @@ func (bot *CQBot) CQSetGroupAdmin(groupID, userID int64, enable bool) global.MSG
// CQGetVipInfo 扩展API-获取VIP信息 // CQGetVipInfo 扩展API-获取VIP信息
// //
// https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96vip%E4%BF%A1%E6%81%AF // https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96vip%E4%BF%A1%E6%81%AF
// @route(path=_get_vip_info) // @route(_get_vip_info)
func (bot *CQBot) CQGetVipInfo(userID int64) global.MSG { func (bot *CQBot) CQGetVipInfo(userID int64) global.MSG {
vip, err := bot.Client.GetVipInfo(userID) vip, err := bot.Client.GetVipInfo(userID)
if err != nil { if err != nil {
@ -917,8 +915,8 @@ func (bot *CQBot) CQGetVipInfo(userID int64) global.MSG {
// CQGetGroupHonorInfo 获取群荣誉信息 // CQGetGroupHonorInfo 获取群荣誉信息
// //
// https://git.io/Jtz1H // https://git.io/Jtz1H
// @route(path=get_group_honor_info) // @route(get_group_honor_info)
// @param(index=1, name=type) // @rename(t->type)
func (bot *CQBot) CQGetGroupHonorInfo(groupID int64, t string) global.MSG { func (bot *CQBot) CQGetGroupHonorInfo(groupID int64, t string) global.MSG {
msg := global.MSG{"group_id": groupID} msg := global.MSG{"group_id": groupID}
convertMem := func(memList []client.HonorMemberInfo) (ret []global.MSG) { convertMem := func(memList []client.HonorMemberInfo) (ret []global.MSG) {
@ -976,7 +974,7 @@ func (bot *CQBot) CQGetGroupHonorInfo(groupID int64, t string) global.MSG {
// CQGetStrangerInfo 获取陌生人信息 // CQGetStrangerInfo 获取陌生人信息
// //
// https://git.io/Jtz17 // https://git.io/Jtz17
// @route(path=get_stranger_info) // @route(get_stranger_info)
func (bot *CQBot) CQGetStrangerInfo(userID int64) global.MSG { func (bot *CQBot) CQGetStrangerInfo(userID int64) global.MSG {
info, err := bot.Client.GetSummaryInfo(userID) info, err := bot.Client.GetSummaryInfo(userID)
if err != nil { if err != nil {
@ -1004,7 +1002,7 @@ func (bot *CQBot) CQGetStrangerInfo(userID int64) global.MSG {
// CQHandleQuickOperation 隐藏API-对事件执行快速操作 // CQHandleQuickOperation 隐藏API-对事件执行快速操作
// //
// https://git.io/Jtz15 // https://git.io/Jtz15
// @route(path=".handle_quick_operation") // @route(".handle_quick_operation")
func (bot *CQBot) CQHandleQuickOperation(context, operation gjson.Result) global.MSG { func (bot *CQBot) CQHandleQuickOperation(context, operation gjson.Result) global.MSG {
postType := context.Get("post_type").Str postType := context.Get("post_type").Str
@ -1094,7 +1092,7 @@ func (bot *CQBot) CQHandleQuickOperation(context, operation gjson.Result) global
// CQGetImage 获取图片(修改自OneBot) // CQGetImage 获取图片(修改自OneBot)
// //
// https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E5%9B%BE%E7%89%87%E4%BF%A1%E6%81%AF // https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E5%9B%BE%E7%89%87%E4%BF%A1%E6%81%AF
// @route(path=get_image) // @route(get_image)
func (bot *CQBot) CQGetImage(file string) global.MSG { func (bot *CQBot) CQGetImage(file string) global.MSG {
var b []byte var b []byte
var err error var err error
@ -1140,7 +1138,7 @@ func (bot *CQBot) CQGetImage(file string) global.MSG {
// CQDownloadFile 扩展API-下载文件到缓存目录 // CQDownloadFile 扩展API-下载文件到缓存目录
// //
// https://docs.go-cqhttp.org/api/#%E4%B8%8B%E8%BD%BD%E6%96%87%E4%BB%B6%E5%88%B0%E7%BC%93%E5%AD%98%E7%9B%AE%E5%BD%95 // https://docs.go-cqhttp.org/api/#%E4%B8%8B%E8%BD%BD%E6%96%87%E4%BB%B6%E5%88%B0%E7%BC%93%E5%AD%98%E7%9B%AE%E5%BD%95
// @route(path=download_file) // @route(download_file)
func (bot *CQBot) CQDownloadFile(url string, headers gjson.Result, threadCount int) global.MSG { func (bot *CQBot) CQDownloadFile(url string, headers gjson.Result, threadCount int) global.MSG {
h := map[string]string{} h := map[string]string{}
if headers.IsArray() { if headers.IsArray() {
@ -1182,8 +1180,8 @@ func (bot *CQBot) CQDownloadFile(url string, headers gjson.Result, threadCount i
// CQGetForwardMessage 获取合并转发消息 // CQGetForwardMessage 获取合并转发消息
// //
// https://git.io/Jtz1F // https://git.io/Jtz1F
// @route(path=get_forward_msg) // @route(get_forward_msg)
// @param(index=0, name="[message_id\x2Cid].0") // @rename(res_id->"[message_id\x2Cid].0")
func (bot *CQBot) CQGetForwardMessage(resID string) global.MSG { func (bot *CQBot) CQGetForwardMessage(resID string) global.MSG {
m := bot.Client.GetForwardMessage(resID) m := bot.Client.GetForwardMessage(resID)
if m == nil { if m == nil {
@ -1209,7 +1207,7 @@ func (bot *CQBot) CQGetForwardMessage(resID string) global.MSG {
// CQGetMessage 获取消息 // CQGetMessage 获取消息
// //
// https://git.io/Jtz1b // https://git.io/Jtz1b
// @route(path=get_msg) // @route(get_msg)
func (bot *CQBot) CQGetMessage(messageID int32) global.MSG { func (bot *CQBot) CQGetMessage(messageID int32) global.MSG {
msg, err := db.GetMessageByGlobalID(messageID) msg, err := db.GetMessageByGlobalID(messageID)
if err != nil { if err != nil {
@ -1242,7 +1240,7 @@ func (bot *CQBot) CQGetMessage(messageID int32) global.MSG {
// CQGetGroupSystemMessages 扩展API-获取群文件系统消息 // CQGetGroupSystemMessages 扩展API-获取群文件系统消息
// //
// https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%B3%BB%E7%BB%9F%E6%B6%88%E6%81%AF // https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%B3%BB%E7%BB%9F%E6%B6%88%E6%81%AF
// @route(path=get_group_system_msg) // @route(get_group_system_msg)
func (bot *CQBot) CQGetGroupSystemMessages() global.MSG { func (bot *CQBot) CQGetGroupSystemMessages() global.MSG {
msg, err := bot.Client.GetGroupSystemMessages() msg, err := bot.Client.GetGroupSystemMessages()
if err != nil { if err != nil {
@ -1255,8 +1253,8 @@ func (bot *CQBot) CQGetGroupSystemMessages() global.MSG {
// CQGetGroupMessageHistory 获取群消息历史记录 // CQGetGroupMessageHistory 获取群消息历史记录
// //
// https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%B6%88%E6%81%AF%E5%8E%86%E5%8F%B2%E8%AE%B0%E5%BD%95 // https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%B6%88%E6%81%AF%E5%8E%86%E5%8F%B2%E8%AE%B0%E5%BD%95
// @route(path=get_group_msg_history) // @route(get_group_msg_history)
// @param(index=1, name=message_seq) // @rename(seq->message_seq)
func (bot *CQBot) CQGetGroupMessageHistory(groupID int64, seq int64) global.MSG { func (bot *CQBot) CQGetGroupMessageHistory(groupID int64, seq int64) global.MSG {
if g := bot.Client.FindGroup(groupID); g == nil { if g := bot.Client.FindGroup(groupID); g == nil {
return Failed(100, "GROUP_NOT_FOUND", "群聊不存在") return Failed(100, "GROUP_NOT_FOUND", "群聊不存在")
@ -1289,7 +1287,7 @@ func (bot *CQBot) CQGetGroupMessageHistory(groupID int64, seq int64) global.MSG
// CQGetOnlineClients 扩展API-获取当前账号在线客户端列表 // CQGetOnlineClients 扩展API-获取当前账号在线客户端列表
// //
// https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E5%BD%93%E5%89%8D%E8%B4%A6%E5%8F%B7%E5%9C%A8%E7%BA%BF%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%88%97%E8%A1%A8 // https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E5%BD%93%E5%89%8D%E8%B4%A6%E5%8F%B7%E5%9C%A8%E7%BA%BF%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%88%97%E8%A1%A8
// @route(path=get_online_clients) // @route(get_online_clients)
func (bot *CQBot) CQGetOnlineClients(noCache bool) global.MSG { func (bot *CQBot) CQGetOnlineClients(noCache bool) global.MSG {
if noCache { if noCache {
if err := bot.Client.RefreshStatus(); err != nil { if err := bot.Client.RefreshStatus(); err != nil {
@ -1313,7 +1311,7 @@ func (bot *CQBot) CQGetOnlineClients(noCache bool) global.MSG {
// CQCanSendImage 检查是否可以发送图片(此处永远返回true) // CQCanSendImage 检查是否可以发送图片(此处永远返回true)
// //
// https://git.io/Jtz1N // https://git.io/Jtz1N
// @route(path=can_send_image) // @route(can_send_image)
func (bot *CQBot) CQCanSendImage() global.MSG { func (bot *CQBot) CQCanSendImage() global.MSG {
return OK(global.MSG{"yes": true}) return OK(global.MSG{"yes": true})
} }
@ -1321,7 +1319,7 @@ func (bot *CQBot) CQCanSendImage() global.MSG {
// CQCanSendRecord 检查是否可以发送语音(此处永远返回true) // CQCanSendRecord 检查是否可以发送语音(此处永远返回true)
// //
// https://git.io/Jtz1x // https://git.io/Jtz1x
// @route(path=can_send_record) // @route(can_send_record)
func (bot *CQBot) CQCanSendRecord() global.MSG { func (bot *CQBot) CQCanSendRecord() global.MSG {
return OK(global.MSG{"yes": true}) return OK(global.MSG{"yes": true})
} }
@ -1329,8 +1327,9 @@ func (bot *CQBot) CQCanSendRecord() global.MSG {
// CQOcrImage 扩展API-图片OCR // CQOcrImage 扩展API-图片OCR
// //
// https://docs.go-cqhttp.org/api/#%E5%9B%BE%E7%89%87-ocr // https://docs.go-cqhttp.org/api/#%E5%9B%BE%E7%89%87-ocr
// @route(path=ocr_image, alias=.ocr_image) // @route(ocr_image)
// @param(index=0, name=image) // @alias(.ocr_image)
// @rename(image_id->image)
func (bot *CQBot) CQOcrImage(imageID string) global.MSG { func (bot *CQBot) CQOcrImage(imageID string) global.MSG {
img, err := bot.makeImageOrVideoElem(map[string]string{"file": imageID}, false, true) img, err := bot.makeImageOrVideoElem(map[string]string{"file": imageID}, false, true)
if err != nil { if err != nil {
@ -1348,7 +1347,7 @@ func (bot *CQBot) CQOcrImage(imageID string) global.MSG {
// CQSetGroupPortrait 扩展API-设置群头像 // CQSetGroupPortrait 扩展API-设置群头像
// //
// https://docs.go-cqhttp.org/api/#%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%A4%B4%E5%83%8F // https://docs.go-cqhttp.org/api/#%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%A4%B4%E5%83%8F
// @route(path=set_group_portrait) // @route(set_group_portrait)
func (bot *CQBot) CQSetGroupPortrait(groupID int64, file, cache string) global.MSG { func (bot *CQBot) CQSetGroupPortrait(groupID int64, file, cache string) global.MSG {
if g := bot.Client.FindGroup(groupID); g != nil { if g := bot.Client.FindGroup(groupID); g != nil {
img, err := global.FindFile(file, cache, global.ImagePath) img, err := global.FindFile(file, cache, global.ImagePath)
@ -1365,8 +1364,8 @@ func (bot *CQBot) CQSetGroupPortrait(groupID int64, file, cache string) global.M
// CQSetGroupAnonymousBan 群组匿名用户禁言 // CQSetGroupAnonymousBan 群组匿名用户禁言
// //
// https://git.io/Jtz1p // https://git.io/Jtz1p
// @route(path=set_group_anonymous_ban) // @route(set_group_anonymous_ban)
// @param(index=1, name="[anonymous_flag\x2Canonymous.flag].0") // @rename(flag->"[anonymous_flag\x2Canonymous.flag].0")
func (bot *CQBot) CQSetGroupAnonymousBan(groupID int64, flag string, duration int32) global.MSG { func (bot *CQBot) CQSetGroupAnonymousBan(groupID int64, flag string, duration int32) global.MSG {
if flag == "" { if flag == "" {
return Failed(100, "INVALID_FLAG", "无效的flag") return Failed(100, "INVALID_FLAG", "无效的flag")
@ -1390,7 +1389,7 @@ func (bot *CQBot) CQSetGroupAnonymousBan(groupID int64, flag string, duration in
// CQGetStatus 获取运行状态 // CQGetStatus 获取运行状态
// //
// https://git.io/JtzMe // https://git.io/JtzMe
// @route(path=get_status) // @route(get_status)
func (bot *CQBot) CQGetStatus() global.MSG { func (bot *CQBot) CQGetStatus() global.MSG {
return OK(global.MSG{ return OK(global.MSG{
"app_initialized": true, "app_initialized": true,
@ -1406,7 +1405,7 @@ func (bot *CQBot) CQGetStatus() global.MSG {
// CQSetEssenceMessage 扩展API-设置精华消息 // CQSetEssenceMessage 扩展API-设置精华消息
// //
// https://docs.go-cqhttp.org/api/#%E8%AE%BE%E7%BD%AE%E7%B2%BE%E5%8D%8E%E6%B6%88%E6%81%AF // https://docs.go-cqhttp.org/api/#%E8%AE%BE%E7%BD%AE%E7%B2%BE%E5%8D%8E%E6%B6%88%E6%81%AF
// @route(path=set_essence_msg) // @route(set_essence_msg)
func (bot *CQBot) CQSetEssenceMessage(messageID int32) global.MSG { func (bot *CQBot) CQSetEssenceMessage(messageID int32) global.MSG {
msg, err := db.GetGroupMessageByGlobalID(messageID) msg, err := db.GetGroupMessageByGlobalID(messageID)
if err != nil { if err != nil {
@ -1422,7 +1421,7 @@ func (bot *CQBot) CQSetEssenceMessage(messageID int32) global.MSG {
// CQDeleteEssenceMessage 扩展API-移出精华消息 // CQDeleteEssenceMessage 扩展API-移出精华消息
// //
// https://docs.go-cqhttp.org/api/#%E7%A7%BB%E5%87%BA%E7%B2%BE%E5%8D%8E%E6%B6%88%E6%81%AF // https://docs.go-cqhttp.org/api/#%E7%A7%BB%E5%87%BA%E7%B2%BE%E5%8D%8E%E6%B6%88%E6%81%AF
// @route(path=delete_essence_msg) // @route(delete_essence_msg)
func (bot *CQBot) CQDeleteEssenceMessage(messageID int32) global.MSG { func (bot *CQBot) CQDeleteEssenceMessage(messageID int32) global.MSG {
msg, err := db.GetGroupMessageByGlobalID(messageID) msg, err := db.GetGroupMessageByGlobalID(messageID)
if err != nil { if err != nil {
@ -1438,7 +1437,7 @@ func (bot *CQBot) CQDeleteEssenceMessage(messageID int32) global.MSG {
// CQGetEssenceMessageList 扩展API-获取精华消息列表 // CQGetEssenceMessageList 扩展API-获取精华消息列表
// //
// https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%B2%BE%E5%8D%8E%E6%B6%88%E6%81%AF%E5%88%97%E8%A1%A8 // https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%B2%BE%E5%8D%8E%E6%B6%88%E6%81%AF%E5%88%97%E8%A1%A8
// @route(path=get_essence_msg_list) // @route(get_essence_msg_list)
func (bot *CQBot) CQGetEssenceMessageList(groupID int64) global.MSG { func (bot *CQBot) CQGetEssenceMessageList(groupID int64) global.MSG {
g := bot.Client.FindGroup(groupID) g := bot.Client.FindGroup(groupID)
if g == nil { if g == nil {
@ -1467,7 +1466,7 @@ func (bot *CQBot) CQGetEssenceMessageList(groupID int64) global.MSG {
// CQCheckURLSafely 扩展API-检查链接安全性 // CQCheckURLSafely 扩展API-检查链接安全性
// //
// https://docs.go-cqhttp.org/api/#%E6%A3%80%E6%9F%A5%E9%93%BE%E6%8E%A5%E5%AE%89%E5%85%A8%E6%80%A7 // https://docs.go-cqhttp.org/api/#%E6%A3%80%E6%9F%A5%E9%93%BE%E6%8E%A5%E5%AE%89%E5%85%A8%E6%80%A7
// @route(path=check_url_safely) // @route(check_url_safely)
func (bot *CQBot) CQCheckURLSafely(url string) global.MSG { func (bot *CQBot) CQCheckURLSafely(url string) global.MSG {
return OK(global.MSG{ return OK(global.MSG{
"level": bot.Client.CheckUrlSafely(url), "level": bot.Client.CheckUrlSafely(url),
@ -1477,7 +1476,7 @@ func (bot *CQBot) CQCheckURLSafely(url string) global.MSG {
// CQGetVersionInfo 获取版本信息 // CQGetVersionInfo 获取版本信息
// //
// https://git.io/JtwUs // https://git.io/JtwUs
// @route(path=get_version_info) // @route(get_version_info)
func (bot *CQBot) CQGetVersionInfo() global.MSG { func (bot *CQBot) CQGetVersionInfo() global.MSG {
wd, _ := os.Getwd() wd, _ := os.Getwd()
return OK(global.MSG{ return OK(global.MSG{
@ -1516,7 +1515,7 @@ func (bot *CQBot) CQGetVersionInfo() global.MSG {
// CQGetModelShow 获取在线机型 // CQGetModelShow 获取在线机型
// //
// https://club.vip.qq.com/onlinestatus/set // https://club.vip.qq.com/onlinestatus/set
// @route(path=_get_model_show) // @route(_get_model_show)
func (bot *CQBot) CQGetModelShow(model string) global.MSG { func (bot *CQBot) CQGetModelShow(model string) global.MSG {
variants, err := bot.Client.GetModelShow(model) variants, err := bot.Client.GetModelShow(model)
if err != nil { if err != nil {
@ -1537,7 +1536,7 @@ func (bot *CQBot) CQGetModelShow(model string) global.MSG {
// CQSetModelShow 设置在线机型 // CQSetModelShow 设置在线机型
// //
// https://club.vip.qq.com/onlinestatus/set // https://club.vip.qq.com/onlinestatus/set
// @route(path=_set_model_show) // @route(_set_model_show)
func (bot *CQBot) CQSetModelShow(model, modelShow string) global.MSG { func (bot *CQBot) CQSetModelShow(model, modelShow string) global.MSG {
err := bot.Client.SetModelShow(model, modelShow) err := bot.Client.SetModelShow(model, modelShow)
if err != nil { if err != nil {
@ -1547,8 +1546,8 @@ func (bot *CQBot) CQSetModelShow(model, modelShow string) global.MSG {
} }
// CQMarkMessageAsRead 标记消息已读 // CQMarkMessageAsRead 标记消息已读
// @route(path=mark_msg_as_read) // @route(mark_msg_as_read)
// @param(index=0, name=message_id) // @rename(msg_id->message_id)
func (bot *CQBot) CQMarkMessageAsRead(msgID int32) global.MSG { func (bot *CQBot) CQMarkMessageAsRead(msgID int32) global.MSG {
m, err := db.GetMessageByGlobalID(msgID) m, err := db.GetMessageByGlobalID(msgID)
if err != nil { if err != nil {
@ -1566,7 +1565,7 @@ func (bot *CQBot) CQMarkMessageAsRead(msgID int32) global.MSG {
// CQReloadEventFilter 重载事件过滤器 // CQReloadEventFilter 重载事件过滤器
// //
// @route(path=reload_event_filter) // @route(reload_event_filter)
func (bot *CQBot) CQReloadEventFilter(file string) global.MSG { func (bot *CQBot) CQReloadEventFilter(file string) global.MSG {
filter.Add(file) filter.Add(file)
return OK(nil) return OK(nil)