Documentation ¶
Index ¶
- Variables
- func CQCodeEscapeText(raw string) string
- func CQCodeEscapeValue(value string) string
- func CQCodeUnescapeText(content string) string
- func CQCodeUnescapeValue(content string) string
- func ToGlobalId(code int64, msgId int32) int32
- func ToStringMessage(e []message.IMessageElement, code int64, raw ...bool) (r string)
- func XmlEscape(c string) string
- type CoreBot
- func (bot *CoreBot) CQCanSendImage() MSG
- func (bot *CoreBot) CQCanSendRecord() MSG
- func (bot *CoreBot) CQDownloadFile(url string, headers map[string]string, threadCount int) MSG
- func (bot *CoreBot) CQGetAtAllRemain(groupId int64) MSG
- func (bot *CoreBot) CQGetForwardMessage(resId string) MSG
- func (bot *CoreBot) CQGetFriendList() MSG
- func (bot *CoreBot) CQGetGroupFileSystemInfo(groupId int64) MSG
- func (bot *CoreBot) CQGetGroupFileUrl(groupId int64, fileId string, busId int32) MSG
- func (bot *CoreBot) CQGetGroupFilesByFolderId(groupId int64, folderId string) MSG
- func (bot *CoreBot) CQGetGroupHonorInfo(groupId int64, t string) MSG
- func (bot *CoreBot) CQGetGroupInfo(groupId int64, noCache bool) MSG
- func (bot *CoreBot) CQGetGroupList(noCache bool) MSG
- func (bot *CoreBot) CQGetGroupMemberInfo(groupId, userId int64) MSG
- func (bot *CoreBot) CQGetGroupMemberList(groupId int64, noCache bool) MSG
- func (bot *CoreBot) CQGetGroupMessageHistory(groupId int64, seq int64) MSG
- func (bot *CoreBot) CQGetGroupRootFiles(groupId int64) MSG
- func (bot *CoreBot) CQGetGroupSystemMessages() MSG
- func (bot *CoreBot) CQGetImage(file string) MSG
- func (bot *CoreBot) CQGetLoginInfo() MSG
- func (bot *CoreBot) CQGetOnlineClients(noCache bool) MSG
- func (bot *CoreBot) CQGetStatus() MSG
- func (bot *CoreBot) CQGetStrangerInfo(userId int64) MSG
- func (bot *CoreBot) CQGetVersionInfo() MSG
- func (bot *CoreBot) CQGetVipInfo(userId int64) MSG
- func (bot *CoreBot) CQGetWordSlices(content string) MSG
- func (bot *CoreBot) CQHandleQuickOperation(context, operation gjson.Result) MSG
- func (bot *CoreBot) CQOcrImage(imageId string) MSG
- func (bot *CoreBot) CQProcessFriendRequest(flag string, approve bool) MSG
- func (bot *CoreBot) CQProcessGroupRequest(flag, subType, reason string, approve bool) MSG
- func (bot *CoreBot) CQSendGroupMessage(groupId int64, i interface{}, autoEscape bool) MSG
- func (bot *CoreBot) CQSendPrivateMessage(userId int64, i interface{}, autoEscape bool) MSG
- func (bot *CoreBot) CQSetGroupAdmin(groupId, userId int64, enable bool) MSG
- func (bot *CoreBot) CQSetGroupAnonymousBan(groupId int64, flag string, duration int32) MSG
- func (bot *CoreBot) CQSetGroupBan(groupId, userId int64, duration uint32) MSG
- func (bot *CoreBot) CQSetGroupCard(groupId, userId int64, card string) MSG
- func (bot *CoreBot) CQSetGroupKick(groupId, userId int64, msg string, block bool) MSG
- func (bot *CoreBot) CQSetGroupLeave(groupId int64) MSG
- func (bot *CoreBot) CQSetGroupMemo(groupId int64, msg string) MSG
- func (bot *CoreBot) CQSetGroupName(groupId int64, name string) MSG
- func (bot *CoreBot) CQSetGroupPortrait(groupId int64, file, cache string) MSG
- func (bot *CoreBot) CQSetGroupSpecialTitle(groupId, userId int64, title string) MSG
- func (bot *CoreBot) CQSetGroupWholeBan(groupId int64, enable bool) MSG
- func (bot *CoreBot) ConvertObjectMessage(m gjson.Result, group bool) (r []message.IMessageElement)
- func (bot *CoreBot) ConvertStringMessage(msg string, group bool) (r []message.IMessageElement)
- func (bot *CoreBot) SendGroupMessage(groupId int64, m *message.SendingMessage) int32
- func (bot *CoreBot) SendPrivateMessage(target int64, m *message.SendingMessage) int32
- func (bot *CoreBot) Start() error
- func (bot *CoreBot) ToElement(t string, d map[string]string, group bool) (m interface{}, err error)
- func (bot *CoreBot) ToFormattedMessage(e []message.IMessageElement, id int64, raw ...bool) (r interface{})
- func (bot *CoreBot) UploadLocalImageAsGroup(groupCode int64, img *LocalImageElement) (*message.GroupImageElement, error)
- func (bot *CoreBot) UploadLocalImageAsPrivate(userId int64, img *LocalImageElement) (*message.FriendImageElement, error)
- func (bot *CoreBot) UploadLocalVideo(target int64, v *LocalVideoElement) (*message.ShortVideoElement, error)
- type GiftElement
- type LocalImageElement
- type LocalVideoElement
- type LocalVoiceElement
- type MSG
- type PokeElement
Constants ¶
This section is empty.
Variables ¶
var ( ErrSliderNeeded = errors.New("需要滑条验证") ErrSMSNeeded = errors.New("需要短信验证码") ErrCaptchaNeeded = errors.New("需要验证码") ErrSMSOrVerifyNeeded = errors.New("设备锁需要验证") ErrUnsafeDevice = errors.New("设备锁需要验证") ErrWrongPasswordOrAccountFreeze = errors.New("密码错误或账号冻结") ErrAbnormal = errors.New("上网环境异常") )
var GiftId = [...]message.GroupGift{ message.SweetWink, message.HappyCola, message.LuckyBracelet, message.Cappuccino, message.CatWatch, message.FleeceGloves, message.RainbowCandy, message.Stronger, message.LoveMicrophone, message.HoldingYourHand, message.CuteCat, message.MysteryMask, message.ImBusy, message.LoveMask, }
var IgnoreInvalidCQCode = false
var JsonAPI = map[string]func(*CoreBot, gjson.Result) MSG{ "get_login_info": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetLoginInfo() }, "get_friend_list": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetFriendList() }, "get_group_list": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetGroupList(p.Get("no_cache").Bool()) }, "get_group_info": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetGroupInfo(p.Get("group_id").Int(), p.Get("no_cache").Bool()) }, "get_group_member_list": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetGroupMemberList(p.Get("group_id").Int(), p.Get("no_cache").Bool()) }, "get_group_member_info": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetGroupMemberInfo( p.Get("group_id").Int(), p.Get("user_id").Int(), ) }, "send_msg": func(bot *CoreBot, p gjson.Result) MSG { autoEscape := utils.EnsureBool(p.Get("auto_escape"), false) if p.Get("message_type").Str == "private" { return bot.CQSendPrivateMessage(p.Get("user_id").Int(), p.Get("message"), autoEscape) } if p.Get("message_type").Str == "group" { return bot.CQSendGroupMessage(p.Get("group_id").Int(), p.Get("message"), autoEscape) } if p.Get("group_id").Int() != 0 { return bot.CQSendGroupMessage(p.Get("group_id").Int(), p.Get("message"), autoEscape) } if p.Get("user_id").Int() != 0 { return bot.CQSendPrivateMessage(p.Get("user_id").Int(), p.Get("message"), autoEscape) } return MSG{} }, "send_group_msg": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQSendGroupMessage(p.Get("group_id").Int(), p.Get("message"), utils.EnsureBool(p.Get("auto_escape"), false)) }, "send_group_forward_msg": func(bot *CoreBot, p gjson.Result) MSG { return Failed(-1, "not support yet") }, "send_private_msg": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQSendPrivateMessage(p.Get("user_id").Int(), p.Get("message"), utils.EnsureBool(p.Get("auto_escape"), false)) }, "delete_msg": func(bot *CoreBot, p gjson.Result) MSG { return Failed(-1, "not support yet") }, "set_friend_add_request": func(bot *CoreBot, p gjson.Result) MSG { apr := true if p.Get("approve").Exists() { apr = p.Get("approve").Bool() } return bot.CQProcessFriendRequest(p.Get("flag").Str, apr) }, "set_group_add_request": func(bot *CoreBot, p gjson.Result) MSG { subType := p.Get("sub_type").Str apr := true if subType == "" { subType = p.Get("type").Str } if p.Get("approve").Exists() { apr = p.Get("approve").Bool() } return bot.CQProcessGroupRequest(p.Get("flag").Str, subType, p.Get("reason").Str, apr) }, "set_group_card": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQSetGroupCard(p.Get("group_id").Int(), p.Get("user_id").Int(), p.Get("card").Str) }, "set_group_special_title": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQSetGroupSpecialTitle(p.Get("group_id").Int(), p.Get("user_id").Int(), p.Get("special_title").Str) }, "set_group_kick": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQSetGroupKick(p.Get("group_id").Int(), p.Get("user_id").Int(), p.Get("message").Str, p.Get("reject_add_request").Bool()) }, "set_group_ban": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQSetGroupBan(p.Get("group_id").Int(), p.Get("user_id").Int(), func() uint32 { if p.Get("duration").Exists() { return uint32(p.Get("duration").Int()) } return 1800 }()) }, "set_group_whole_ban": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQSetGroupWholeBan(p.Get("group_id").Int(), func() bool { if p.Get("enable").Exists() { return p.Get("enable").Bool() } return true }()) }, "set_group_name": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQSetGroupName(p.Get("group_id").Int(), p.Get("group_name").Str) }, "set_group_admin": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQSetGroupAdmin(p.Get("group_id").Int(), p.Get("user_id").Int(), func() bool { if p.Get("enable").Exists() { return p.Get("enable").Bool() } return true }()) }, "_send_group_notice": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQSetGroupMemo(p.Get("group_id").Int(), p.Get("content").Str) }, "set_group_leave": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQSetGroupLeave(p.Get("group_id").Int()) }, "get_image": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetImage(p.Get("file").Str) }, "get_forward_msg": func(bot *CoreBot, p gjson.Result) MSG { id := p.Get("message_id").Str if id == "" { id = p.Get("id").Str } return bot.CQGetForwardMessage(id) }, "get_msg": func(bot *CoreBot, p gjson.Result) MSG { return Failed(-1, "not support yet") }, "download_file": func(bot *CoreBot, p gjson.Result) MSG { headers := map[string]string{} headersToken := p.Get("headers") if headersToken.IsArray() { for _, sub := range headersToken.Array() { str := strings.SplitN(sub.String(), "=", 2) if len(str) == 2 { headers[str[0]] = str[1] } } } if headersToken.Type == gjson.String { lines := strings.Split(headersToken.String(), "\r\n") for _, sub := range lines { str := strings.SplitN(sub, "=", 2) if len(str) == 2 { headers[str[0]] = str[1] } } } return bot.CQDownloadFile(p.Get("url").Str, headers, int(p.Get("thread_count").Int())) }, "get_group_honor_info": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetGroupHonorInfo(p.Get("group_id").Int(), p.Get("type").Str) }, "set_restart": func(c *CoreBot, p gjson.Result) MSG { return Failed(-1, "not support yet") }, "can_send_image": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQCanSendImage() }, "can_send_record": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQCanSendRecord() }, "get_stranger_info": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetStrangerInfo(p.Get("user_id").Int()) }, "get_status": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetStatus() }, "get_version_info": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetVersionInfo() }, "get_group_system_msg": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetGroupSystemMessages() }, "get_group_file_system_info": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetGroupFileSystemInfo(p.Get("group_id").Int()) }, "get_group_root_files": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetGroupRootFiles(p.Get("group_id").Int()) }, "get_group_files_by_folder": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetGroupFilesByFolderId(p.Get("group_id").Int(), p.Get("folder_id").Str) }, "get_group_file_url": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetGroupFileUrl(p.Get("group_id").Int(), p.Get("file_id").Str, int32(p.Get("busid").Int())) }, "get_group_msg_history": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetGroupMessageHistory(p.Get("group_id").Int(), p.Get("message_seq").Int()) }, "_get_vip_info": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetVipInfo(p.Get("user_id").Int()) }, "reload_event_filter": func(bot *CoreBot, p gjson.Result) MSG { return Failed(-1, "not support yet") }, ".ocr_image": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQOcrImage(p.Get("image").Str) }, "ocr_image": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQOcrImage(p.Get("image").Str) }, "get_group_at_all_remain": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetAtAllRemain(p.Get("group_id").Int()) }, "get_online_clients": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetOnlineClients(p.Get("no_cache").Bool()) }, ".get_word_slices": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQGetWordSlices(p.Get("content").Str) }, "set_group_portrait": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQSetGroupPortrait(p.Get("group_id").Int(), p.Get("file").String(), p.Get("cache").String()) }, "set_group_anonymous_ban": func(bot *CoreBot, p gjson.Result) MSG { obj := p.Get("anonymous") flag := p.Get("anonymous_flag") if !flag.Exists() { flag = p.Get("flag") } if !flag.Exists() && !obj.Exists() { return Failed(100, "FLAG_NOT_FOUND", "flag未找到") } if !flag.Exists() { flag = obj.Get("flag") } return bot.CQSetGroupAnonymousBan(p.Get("group_id").Int(), flag.String(), int32(p.Get("duration").Int())) }, ".handle_quick_operation": func(bot *CoreBot, p gjson.Result) MSG { return bot.CQHandleQuickOperation(p.Get("context"), p.Get("operation")) }, }
var SplitUrl = false
var Version = "unknown"
Functions ¶
func CQCodeEscapeText ¶
func CQCodeEscapeValue ¶
func CQCodeUnescapeText ¶
func CQCodeUnescapeValue ¶
func ToGlobalId ¶
func ToStringMessage ¶
func ToStringMessage(e []message.IMessageElement, code int64, raw ...bool) (r string)
Types ¶
type CoreBot ¶
type CoreBot struct { Client *client.QQClient ForceFragmented bool MessageFormat string EventChannel chan MSG // contains filtered or unexported fields }
func (*CoreBot) CQCanSendImage ¶
func (*CoreBot) CQCanSendRecord ¶
func (*CoreBot) CQDownloadFile ¶
func (*CoreBot) CQGetAtAllRemain ¶
func (*CoreBot) CQGetForwardMessage ¶
func (*CoreBot) CQGetFriendList ¶
func (*CoreBot) CQGetGroupFileSystemInfo ¶
func (*CoreBot) CQGetGroupFileUrl ¶
func (*CoreBot) CQGetGroupFilesByFolderId ¶
func (*CoreBot) CQGetGroupHonorInfo ¶
func (*CoreBot) CQGetGroupInfo ¶
https://cqhttp.cc/docs/4.15/#/API?id=get_group_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E4%BF%A1%E6%81%AF
func (*CoreBot) CQGetGroupList ¶
https://cqhttp.cc/docs/4.15/#/API?id=get_group_list-%E8%8E%B7%E5%8F%96%E7%BE%A4%E5%88%97%E8%A1%A8
func (*CoreBot) CQGetGroupMemberInfo ¶
func (*CoreBot) CQGetGroupMemberList ¶
func (*CoreBot) CQGetGroupMessageHistory ¶
func (*CoreBot) CQGetGroupRootFiles ¶
func (*CoreBot) CQGetGroupSystemMessages ¶
func (*CoreBot) CQGetImage ¶
func (*CoreBot) CQGetLoginInfo ¶
func (*CoreBot) CQGetOnlineClients ¶
func (*CoreBot) CQGetStatus ¶
func (*CoreBot) CQGetStrangerInfo ¶
func (*CoreBot) CQGetVersionInfo ¶
func (*CoreBot) CQGetVipInfo ¶
func (*CoreBot) CQGetWordSlices ¶
func (*CoreBot) CQHandleQuickOperation ¶
https://cqhttp.cc/docs/4.15/#/API?id=-handle_quick_operation-%E5%AF%B9%E4%BA%8B%E4%BB%B6%E6%89%A7%E8%A1%8C%E5%BF%AB%E9%80%9F%E6%93%8D%E4%BD%9C https://github.com/richardchien/coolq-http-api/blob/master/src/cqhttp/plugins/web/http.cpp#L376
func (*CoreBot) CQOcrImage ¶
func (*CoreBot) CQProcessFriendRequest ¶
func (*CoreBot) CQProcessGroupRequest ¶
func (*CoreBot) CQSendGroupMessage ¶
https://cqhttp.cc/docs/4.15/#/API?id=send_group_msg-%E5%8F%91%E9%80%81%E7%BE%A4%E6%B6%88%E6%81%AF
func (*CoreBot) CQSendPrivateMessage ¶
func (*CoreBot) CQSetGroupAdmin ¶
func (*CoreBot) CQSetGroupAnonymousBan ¶
func (*CoreBot) CQSetGroupBan ¶
func (*CoreBot) CQSetGroupCard ¶
func (*CoreBot) CQSetGroupKick ¶
https://cqhttp.cc/docs/4.15/#/API?id=set_group_kick-%E7%BE%A4%E7%BB%84%E8%B8%A2%E4%BA%BA
func (*CoreBot) CQSetGroupLeave ¶
https://cqhttp.cc/docs/4.15/#/API?id=set_group_leave-%E9%80%80%E5%87%BA%E7%BE%A4%E7%BB%84
func (*CoreBot) CQSetGroupPortrait ¶
func (*CoreBot) CQSetGroupSpecialTitle ¶
func (*CoreBot) CQSetGroupWholeBan ¶
func (*CoreBot) ConvertObjectMessage ¶
func (*CoreBot) ConvertStringMessage ¶
func (bot *CoreBot) ConvertStringMessage(msg string, group bool) (r []message.IMessageElement)
func (*CoreBot) SendGroupMessage ¶
func (bot *CoreBot) SendGroupMessage(groupId int64, m *message.SendingMessage) int32
func (*CoreBot) SendPrivateMessage ¶
func (bot *CoreBot) SendPrivateMessage(target int64, m *message.SendingMessage) int32
func (*CoreBot) ToElement ¶
ToElement 将解码后的CQCode转换为Element. 返回 interface{} 存在三种类型 message.IMessageElement []message.IMessageElement nil
func (*CoreBot) ToFormattedMessage ¶
func (bot *CoreBot) ToFormattedMessage(e []message.IMessageElement, id int64, raw ...bool) (r interface{})
ToFormattedMessage 将给定[]message.IMessageElement转换为通过coolq.SetMessageFormat所定义的消息上报格式
func (*CoreBot) UploadLocalImageAsGroup ¶
func (bot *CoreBot) UploadLocalImageAsGroup(groupCode int64, img *LocalImageElement) (*message.GroupImageElement, error)
func (*CoreBot) UploadLocalImageAsPrivate ¶
func (bot *CoreBot) UploadLocalImageAsPrivate(userId int64, img *LocalImageElement) (*message.FriendImageElement, error)
func (*CoreBot) UploadLocalVideo ¶
func (bot *CoreBot) UploadLocalVideo(target int64, v *LocalVideoElement) (*message.ShortVideoElement, error)
type GiftElement ¶
func (*GiftElement) Type ¶
func (e *GiftElement) Type() message.ElementType
type LocalImageElement ¶
type LocalImageElement struct { message.ImageElement Stream io.ReadSeeker File string }
type LocalVideoElement ¶
type LocalVideoElement struct { message.ShortVideoElement File string // contains filtered or unexported fields }
type LocalVoiceElement ¶
type LocalVoiceElement struct { message.VoiceElement Stream io.ReadSeeker }
type MSG ¶
type MSG map[string]interface{}
func ToArrayMessage ¶
func ToArrayMessage(e []message.IMessageElement, code int64, raw ...bool) (r []MSG)
type PokeElement ¶
type PokeElement struct {
Target int64
}
func (*PokeElement) Type ¶
func (e *PokeElement) Type() message.ElementType