Documentation ¶
Overview ¶
Package coolq 包含CQBot实例,CQ码处理,消息发送,消息处理等的相关函数与结构体
Index ¶
- Variables
- func CQCodeEscapeText(raw string) string
- func CQCodeEscapeValue(value string) string
- func CQCodeUnescapeText(content string) string
- func CQCodeUnescapeValue(content string) string
- func SetMessageFormat(f string)
- func ToFormattedMessage(e []message.IMessageElement, id int64, isRaw ...bool) (r interface{})
- func ToStringMessage(e []message.IMessageElement, id int64, isRaw ...bool) (r string)
- func XMLEscape(c string) string
- type CQBot
- func (bot *CQBot) CQCanSendImage() MSG
- func (bot *CQBot) CQCanSendRecord() MSG
- func (bot *CQBot) CQCheckURLSafely(url string) MSG
- func (bot *CQBot) CQDeleteEssenceMessage(messageID int32) MSG
- func (bot *CQBot) CQDeleteMessage(messageID int32) MSG
- func (bot *CQBot) CQDownloadFile(url string, headers map[string]string, threadCount int) MSG
- func (bot *CQBot) CQGetAtAllRemain(groupID int64) MSG
- func (bot *CQBot) CQGetEssenceMessageList(groupCode int64) MSG
- func (bot *CQBot) CQGetForwardMessage(resID string) MSG
- func (bot *CQBot) CQGetFriendList() MSG
- func (bot *CQBot) CQGetGroupFileSystemInfo(groupID int64) MSG
- func (bot *CQBot) CQGetGroupFileURL(groupID int64, fileID string, busID int32) MSG
- func (bot *CQBot) CQGetGroupFilesByFolderID(groupID int64, folderID string) MSG
- func (bot *CQBot) CQGetGroupHonorInfo(groupID int64, t string) MSG
- func (bot *CQBot) CQGetGroupInfo(groupID int64, noCache bool) MSG
- func (bot *CQBot) CQGetGroupList(noCache bool) MSG
- func (bot *CQBot) CQGetGroupMemberInfo(groupID, userID int64) MSG
- func (bot *CQBot) CQGetGroupMemberList(groupID int64, noCache bool) MSG
- func (bot *CQBot) CQGetGroupMessageHistory(groupID int64, seq int64) MSG
- func (bot *CQBot) CQGetGroupRootFiles(groupID int64) MSG
- func (bot *CQBot) CQGetGroupSystemMessages() MSG
- func (bot *CQBot) CQGetImage(file string) MSG
- func (bot *CQBot) CQGetLoginInfo() MSG
- func (bot *CQBot) CQGetMessage(messageID int32) MSG
- func (bot *CQBot) CQGetOnlineClients(noCache bool) MSG
- func (bot *CQBot) CQGetStatus() MSG
- func (bot *CQBot) CQGetStrangerInfo(userID int64) MSG
- func (bot *CQBot) CQGetVersionInfo() MSG
- func (bot *CQBot) CQGetVipInfo(userID int64) MSG
- func (bot *CQBot) CQGetWordSlices(content string) MSG
- func (bot *CQBot) CQHandleQuickOperation(context, operation gjson.Result) MSG
- func (bot *CQBot) CQOcrImage(imageID string) MSG
- func (bot *CQBot) CQProcessFriendRequest(flag string, approve bool) MSG
- func (bot *CQBot) CQProcessGroupRequest(flag, subType, reason string, approve bool) MSG
- func (bot *CQBot) CQReloadEventFilter() MSG
- func (bot *CQBot) CQSendGroupForwardMessage(groupID int64, m gjson.Result) MSG
- func (bot *CQBot) CQSendGroupMessage(groupID int64, i interface{}, autoEscape bool) MSG
- func (bot *CQBot) CQSendPrivateMessage(userID int64, groupID int64, i interface{}, autoEscape bool) MSG
- func (bot *CQBot) CQSetEssenceMessage(messageID int32) MSG
- func (bot *CQBot) CQSetGroupAdmin(groupID, userID int64, enable bool) MSG
- func (bot *CQBot) CQSetGroupAnonymousBan(groupID int64, flag string, duration int32) MSG
- func (bot *CQBot) CQSetGroupBan(groupID, userID int64, duration uint32) MSG
- func (bot *CQBot) CQSetGroupCard(groupID, userID int64, card string) MSG
- func (bot *CQBot) CQSetGroupKick(groupID, userID int64, msg string, block bool) MSG
- func (bot *CQBot) CQSetGroupLeave(groupID int64) MSG
- func (bot *CQBot) CQSetGroupMemo(groupID int64, msg string) MSG
- func (bot *CQBot) CQSetGroupName(groupID int64, name string) MSG
- func (bot *CQBot) CQSetGroupPortrait(groupID int64, file, cache string) MSG
- func (bot *CQBot) CQSetGroupSpecialTitle(groupID, userID int64, title string) MSG
- func (bot *CQBot) CQSetGroupWholeBan(groupID int64, enable bool) MSG
- func (bot *CQBot) CQUploadGroupFile(groupID int64, file, name, folder string) MSG
- func (bot *CQBot) ConvertObjectMessage(m gjson.Result, isGroup bool) (r []message.IMessageElement)
- func (bot *CQBot) ConvertStringMessage(s string, isGroup bool) (r []message.IMessageElement)
- func (bot *CQBot) GetMessage(mid int32) MSG
- func (bot *CQBot) InsertGroupMessage(m *message.GroupMessage) int32
- func (bot *CQBot) InsertPrivateMessage(m *message.PrivateMessage) int32
- func (bot *CQBot) InsertTempMessage(target int64, m *message.TempMessage) int32
- func (bot *CQBot) OnEventPush(f func(buf *bytes.Buffer))
- func (bot *CQBot) Release()
- func (bot *CQBot) SendGroupMessage(groupID int64, m *message.SendingMessage) int32
- func (bot *CQBot) SendPrivateMessage(target int64, groupID int64, m *message.SendingMessage) int32
- func (bot *CQBot) ToElement(t string, d map[string]string, isGroup bool) (m interface{}, err error)
- func (bot *CQBot) UploadLocalImageAsGroup(groupCode int64, img *LocalImageElement) (*message.GroupImageElement, error)
- func (bot *CQBot) UploadLocalImageAsPrivate(userID int64, img *LocalImageElement) (*message.FriendImageElement, error)
- func (bot *CQBot) 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 ForceFragmented = false
ForceFragmented 是否启用强制分片
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, }
GiftID 礼物ID数组
var IgnoreInvalidCQCode = false
IgnoreInvalidCQCode 是否忽略无效CQ码
var SplitURL = false
SplitURL 是否分割URL
var Version = "unknown"
Version go-cqhttp的版本信息,在编译时使用ldflags进行覆盖
Functions ¶
func CQCodeEscapeText ¶ added in v0.9.16
CQCodeEscapeText 将字符串raw中部分字符转义
& -> &
[ -> [
] -> ]
func CQCodeEscapeValue ¶ added in v0.9.18
CQCodeEscapeValue 将字符串value中部分字符转义
, -> ,
& -> &
[ -> [
] -> ]
func CQCodeUnescapeText ¶ added in v0.9.16
CQCodeUnescapeText 将字符串content中部分字符反转义
& -> &
[ -> [
] -> ]
func CQCodeUnescapeValue ¶ added in v0.9.18
CQCodeUnescapeValue 将字符串content中部分字符反转义
, -> ,
& -> &
[ -> [
] -> ]
func SetMessageFormat ¶ added in v0.9.18
func SetMessageFormat(f string)
SetMessageFormat 设置消息上报格式,默认为string
func ToFormattedMessage ¶ added in v0.9.18
func ToFormattedMessage(e []message.IMessageElement, id int64, isRaw ...bool) (r interface{})
ToFormattedMessage 将给定[]message.IMessageElement转换为通过coolq.SetMessageFormat所定义的消息上报格式
func ToStringMessage ¶
func ToStringMessage(e []message.IMessageElement, id int64, isRaw ...bool) (r string)
ToStringMessage 将消息元素数组转为字符串以用于消息上报
Types ¶
type CQBot ¶
CQBot CQBot结构体,存储Bot实例相关配置
func NewQQBot ¶
func NewQQBot(cli *client.QQClient, conf *global.JSONConfig) *CQBot
NewQQBot 初始化一个QQBot实例
func (*CQBot) CQCanSendImage ¶
CQCanSendImage 检查是否可以发送图片(此处永远返回true)
func (*CQBot) CQCanSendRecord ¶
CQCanSendRecord 检查是否可以发送语音(此处永远返回true)
func (*CQBot) CQCheckURLSafely ¶ added in v1.0.0
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
func (*CQBot) CQDeleteEssenceMessage ¶ added in v0.9.40
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
func (*CQBot) CQDownloadFile ¶ added in v0.9.38
CQDownloadFile 扩展API-下载文件到缓存目录
func (*CQBot) CQGetAtAllRemain ¶ added in v0.9.35
CQGetAtAllRemain 扩展API-获取群 @全体成员 剩余次数
func (*CQBot) CQGetEssenceMessageList ¶ added in v0.9.40
CQGetEssenceMessageList 扩展API-获取精华消息列表
func (*CQBot) CQGetForwardMessage ¶ added in v0.9.3
CQGetForwardMessage 获取合并转发消息
func (*CQBot) CQGetFriendList ¶
CQGetFriendList 获取好友列表
func (*CQBot) CQGetGroupFileSystemInfo ¶ added in v0.9.30
CQGetGroupFileSystemInfo 扩展API-获取群文件系统信息
func (*CQBot) CQGetGroupFileURL ¶ added in v1.0.0
CQGetGroupFileURL 扩展API-获取群文件资源链接
func (*CQBot) CQGetGroupFilesByFolderID ¶ added in v1.0.0
CQGetGroupFilesByFolderID 扩展API-获取群子目录文件列表
func (*CQBot) CQGetGroupHonorInfo ¶ added in v0.9.20
CQGetGroupHonorInfo 获取群荣誉信息
func (*CQBot) CQGetGroupInfo ¶
CQGetGroupInfo 获取群信息
func (*CQBot) CQGetGroupList ¶
CQGetGroupList 获取群列表
func (*CQBot) CQGetGroupMemberInfo ¶
CQGetGroupMemberInfo 获取群成员信息
func (*CQBot) CQGetGroupMemberList ¶
CQGetGroupMemberList 获取群成员列表
func (*CQBot) CQGetGroupMessageHistory ¶ added in v0.9.39
CQGetGroupMessageHistory 获取群消息历史记录
func (*CQBot) CQGetGroupRootFiles ¶ added in v0.9.30
CQGetGroupRootFiles 扩展API-获取群根目录文件列表
func (*CQBot) CQGetGroupSystemMessages ¶ added in v0.9.30
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
func (*CQBot) CQGetImage ¶
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
func (*CQBot) CQGetLoginInfo ¶
CQGetLoginInfo 获取登录号信息
func (*CQBot) CQGetMessage ¶ added in v0.9.29
CQGetMessage 获取消息
func (*CQBot) CQGetOnlineClients ¶ added in v0.9.39
CQGetOnlineClients 扩展API-获取当前账号在线客户端列表
func (*CQBot) CQGetStatus ¶
CQGetStatus 获取运行状态
func (*CQBot) CQGetStrangerInfo ¶ added in v0.9.26
CQGetStrangerInfo 获取陌生人信息
func (*CQBot) CQGetVersionInfo ¶
CQGetVersionInfo 获取版本信息
func (*CQBot) CQGetVipInfo ¶ added in v0.9.24
CQGetVipInfo 扩展API-获取VIP信息
https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96vip%E4%BF%A1%E6%81%AF
func (*CQBot) CQGetWordSlices ¶ added in v0.9.27
CQGetWordSlices 隐藏API-获取中文分词
func (*CQBot) CQHandleQuickOperation ¶ added in v0.9.1
CQHandleQuickOperation 隐藏API-对事件执行快速操作
func (*CQBot) CQOcrImage ¶ added in v0.9.26
CQOcrImage 扩展API-图片OCR
func (*CQBot) CQProcessFriendRequest ¶
CQProcessFriendRequest 处理加好友请求
func (*CQBot) CQProcessGroupRequest ¶
CQProcessGroupRequest 处理加群请求/邀请
func (*CQBot) CQReloadEventFilter ¶ added in v0.9.25
CQReloadEventFilter 扩展API-重载事件过滤器
https://docs.go-cqhttp.org/api/#%E9%87%8D%E8%BD%BD%E4%BA%8B%E4%BB%B6%E8%BF%87%E6%BB%A4%E5%99%A8
func (*CQBot) CQSendGroupForwardMessage ¶ added in v0.9.4
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
func (*CQBot) CQSendGroupMessage ¶
CQSendGroupMessage 发送群消息
func (*CQBot) CQSendPrivateMessage ¶
func (bot *CQBot) CQSendPrivateMessage(userID int64, groupID int64, i interface{}, autoEscape bool) MSG
CQSendPrivateMessage 发送私聊消息
func (*CQBot) CQSetEssenceMessage ¶ added in v0.9.40
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
func (*CQBot) CQSetGroupAdmin ¶ added in v0.9.25
CQSetGroupAdmin 群组设置管理员
func (*CQBot) CQSetGroupAnonymousBan ¶ added in v0.9.36
CQSetGroupAnonymousBan 群组匿名用户禁言
func (*CQBot) CQSetGroupBan ¶
CQSetGroupBan 群组单人禁言
func (*CQBot) CQSetGroupCard ¶
CQSetGroupCard 设置群名片(群备注)
func (*CQBot) CQSetGroupKick ¶
CQSetGroupKick 群组踢人
func (*CQBot) CQSetGroupLeave ¶ added in v0.9.6
CQSetGroupLeave 退出群组
func (*CQBot) CQSetGroupMemo ¶ added in v0.9.24
CQSetGroupMemo 扩展API-发送群公告
https://docs.go-cqhttp.org/api/#%E5%8F%91%E9%80%81%E7%BE%A4%E5%85%AC%E5%91%8A
func (*CQBot) CQSetGroupName ¶
CQSetGroupName 设置群名
func (*CQBot) CQSetGroupPortrait ¶ added in v0.9.26
CQSetGroupPortrait 扩展API-设置群头像
https://docs.go-cqhttp.org/api/#%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%A4%B4%E5%83%8F
func (*CQBot) CQSetGroupSpecialTitle ¶
CQSetGroupSpecialTitle 设置群组专属头衔
func (*CQBot) CQSetGroupWholeBan ¶
CQSetGroupWholeBan 群组全员禁言
func (*CQBot) CQUploadGroupFile ¶ added in v0.9.40
CQUploadGroupFile 扩展API-上传群文件
https://docs.go-cqhttp.org/api/#%E4%B8%8A%E4%BC%A0%E7%BE%A4%E6%96%87%E4%BB%B6
func (*CQBot) ConvertObjectMessage ¶ added in v0.9.4
ConvertObjectMessage 将消息JSON对象转为消息元素数组
func (*CQBot) ConvertStringMessage ¶
func (bot *CQBot) ConvertStringMessage(s string, isGroup bool) (r []message.IMessageElement)
ConvertStringMessage 将消息字符串转为消息元素数组
func (*CQBot) GetMessage ¶ added in v0.9.29
GetMessage 获取给定消息id对应的消息
func (*CQBot) InsertGroupMessage ¶
func (bot *CQBot) InsertGroupMessage(m *message.GroupMessage) int32
InsertGroupMessage 群聊消息入数据库
func (*CQBot) InsertPrivateMessage ¶ added in v0.9.29
func (bot *CQBot) InsertPrivateMessage(m *message.PrivateMessage) int32
InsertPrivateMessage 私聊消息入数据库
func (*CQBot) InsertTempMessage ¶
func (bot *CQBot) InsertTempMessage(target int64, m *message.TempMessage) int32
InsertTempMessage 临时消息入数据库
func (*CQBot) OnEventPush ¶
OnEventPush 注册事件上报函数
func (*CQBot) SendGroupMessage ¶
func (bot *CQBot) SendGroupMessage(groupID int64, m *message.SendingMessage) int32
SendGroupMessage 发送群消息
func (*CQBot) SendPrivateMessage ¶
SendPrivateMessage 发送私聊消息
func (*CQBot) ToElement ¶
ToElement 将解码后的CQCode转换为Element.
返回 interface{} 存在三种类型
message.IMessageElement []message.IMessageElement nil
func (*CQBot) UploadLocalImageAsGroup ¶ added in v0.9.37
func (bot *CQBot) UploadLocalImageAsGroup(groupCode int64, img *LocalImageElement) (*message.GroupImageElement, error)
UploadLocalImageAsGroup 上传本地图片至群聊
func (*CQBot) UploadLocalImageAsPrivate ¶ added in v0.9.37
func (bot *CQBot) UploadLocalImageAsPrivate(userID int64, img *LocalImageElement) (*message.FriendImageElement, error)
UploadLocalImageAsPrivate 上传本地图片至私聊
func (*CQBot) UploadLocalVideo ¶ added in v0.9.38
func (bot *CQBot) UploadLocalVideo(target int64, v *LocalVideoElement) (*message.ShortVideoElement, error)
UploadLocalVideo 上传本地短视频至群聊
type GiftElement ¶ added in v0.9.27
GiftElement 礼物
func (*GiftElement) Type ¶ added in v0.9.27
func (e *GiftElement) Type() message.ElementType
Type 获取元素类型ID
type LocalImageElement ¶ added in v0.9.37
type LocalImageElement struct { message.ImageElement Stream io.ReadSeeker File string }
LocalImageElement 本地图片
type LocalVideoElement ¶ added in v0.9.38
type LocalVideoElement struct { message.ShortVideoElement File string // contains filtered or unexported fields }
LocalVideoElement 本地视频
type LocalVoiceElement ¶ added in v0.9.37
type LocalVoiceElement struct { message.VoiceElement Stream io.ReadSeeker }
LocalVoiceElement 本地语音
type MSG ¶
type MSG map[string]interface{}
MSG 消息Map
func ToArrayMessage ¶ added in v0.9.18
func ToArrayMessage(e []message.IMessageElement, id int64, isRaw ...bool) (r []MSG)
ToArrayMessage 将消息元素数组转为MSG数组以用于消息上报
type PokeElement ¶ added in v0.9.25
type PokeElement struct {
Target int64
}
PokeElement 拍一拍
func (*PokeElement) Type ¶ added in v0.9.25
func (e *PokeElement) Type() message.ElementType
Type 获取元素类型ID