coolq

package
v0.9.19-0...-75f36c2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2021 License: AGPL-3.0 Imports: 37 Imported by: 0

Documentation

Overview

Package coolq 包含CQBot实例,CQ码处理,消息发送,消息处理等的相关函数与结构体

Index

Constants

This section is empty.

Variables

View Source
var ExtraReplyData bool

ExtraReplyData 是否上报额外reply信息

View Source
var ForceFragmented = false

ForceFragmented 是否启用强制分片

GiftID 礼物ID数组

View Source
var IgnoreInvalidCQCode = false

IgnoreInvalidCQCode 是否忽略无效CQ码

View Source
var RemoveReplyAt bool

RemoveReplyAt 是否删除reply后的at

View Source
var SplitURL = false

SplitURL 是否分割URL

View Source
var Version = "unknown"

Version go-cqhttp的版本信息,在编译时使用ldflags进行覆盖

Functions

func CQCodeEscapeText

func CQCodeEscapeText(raw string) string

CQCodeEscapeText 将字符串raw中部分字符转义

& -> &

[ -> [

] -> ]

func CQCodeEscapeValue

func CQCodeEscapeValue(value string) string

CQCodeEscapeValue 将字符串value中部分字符转义

, -> ,

& -> &

[ -> [

] -> ]

func CQCodeUnescapeText

func CQCodeUnescapeText(content string) string

CQCodeUnescapeText 将字符串content中部分字符反转义

& -> &

[ -> [

] -> ]

func CQCodeUnescapeValue

func CQCodeUnescapeValue(content string) string

CQCodeUnescapeValue 将字符串content中部分字符反转义

, -> ,

& -> &

[ -> [

] -> ]

func SetMessageFormat

func SetMessageFormat(f string)

SetMessageFormat 设置消息上报格式,默认为string

func ToFormattedMessage

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 将消息元素数组转为字符串以用于消息上报

func XMLEscape

func XMLEscape(c string) string

XMLEscape 将字符串c转义为XML字符串

Types

type CQBot

type CQBot struct {
	Client *client.QQClient
	// contains filtered or unexported fields
}

CQBot CQBot结构体,存储Bot实例相关配置

func NewQQBot

func NewQQBot(cli *client.QQClient, conf *config.Config) *CQBot

NewQQBot 初始化一个QQBot实例

func (*CQBot) CQCanSendImage

func (bot *CQBot) CQCanSendImage() MSG

CQCanSendImage 检查是否可以发送图片(此处永远返回true)

https://git.io/Jtz1N

func (*CQBot) CQCanSendRecord

func (bot *CQBot) CQCanSendRecord() MSG

CQCanSendRecord 检查是否可以发送语音(此处永远返回true)

https://git.io/Jtz1x

func (*CQBot) CQCheckURLSafely

func (bot *CQBot) CQCheckURLSafely(url string) MSG

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

func (bot *CQBot) CQDeleteEssenceMessage(messageID int32) MSG

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) CQDeleteMessage

func (bot *CQBot) CQDeleteMessage(messageID int32) MSG

CQDeleteMessage 撤回消息

https:// git.io/Jtz1y

func (*CQBot) CQDownloadFile

func (bot *CQBot) CQDownloadFile(url string, headers map[string]string, threadCount int) MSG

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

func (*CQBot) CQGetAtAllRemain

func (bot *CQBot) CQGetAtAllRemain(groupID int64) MSG

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

func (*CQBot) CQGetCSRFToken

func (bot *CQBot) CQGetCSRFToken() MSG

func (*CQBot) CQGetCookies

func (bot *CQBot) CQGetCookies(domain string) MSG

func (*CQBot) CQGetCredentials

func (bot *CQBot) CQGetCredentials(domain string) MSG

func (*CQBot) CQGetEssenceMessageList

func (bot *CQBot) CQGetEssenceMessageList(groupCode int64) MSG

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

func (*CQBot) CQGetForwardMessage

func (bot *CQBot) CQGetForwardMessage(resID string) MSG

CQGetForwardMessage 获取合并转发消息

https://git.io/Jtz1F

func (*CQBot) CQGetFriendList

func (bot *CQBot) CQGetFriendList() MSG

CQGetFriendList 获取好友列表

https://git.io/Jtz1L

func (*CQBot) CQGetGroupFileSystemInfo

func (bot *CQBot) CQGetGroupFileSystemInfo(groupID int64) MSG

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

func (*CQBot) CQGetGroupFileURL

func (bot *CQBot) CQGetGroupFileURL(groupID int64, fileID string, busID int32) MSG

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

func (*CQBot) CQGetGroupFilesByFolderID

func (bot *CQBot) CQGetGroupFilesByFolderID(groupID int64, folderID string) MSG

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

func (*CQBot) CQGetGroupHonorInfo

func (bot *CQBot) CQGetGroupHonorInfo(groupID int64, t string) MSG

CQGetGroupHonorInfo 获取群荣誉信息

https://git.io/Jtz1H

func (*CQBot) CQGetGroupInfo

func (bot *CQBot) CQGetGroupInfo(groupID int64, noCache bool) MSG

CQGetGroupInfo 获取群信息

https://git.io/Jtz1O

func (*CQBot) CQGetGroupList

func (bot *CQBot) CQGetGroupList(noCache bool) MSG

CQGetGroupList 获取群列表

https://git.io/Jtz1t

func (*CQBot) CQGetGroupMemberInfo

func (bot *CQBot) CQGetGroupMemberInfo(groupID, userID int64, noCache bool) MSG

CQGetGroupMemberInfo 获取群成员信息

https://git.io/Jtz1s

func (*CQBot) CQGetGroupMemberList

func (bot *CQBot) CQGetGroupMemberList(groupID int64, noCache bool) MSG

CQGetGroupMemberList 获取群成员列表

https://git.io/Jtz13

func (*CQBot) CQGetGroupMessageHistory

func (bot *CQBot) CQGetGroupMessageHistory(groupID int64, seq int64) MSG

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

func (*CQBot) CQGetGroupRootFiles

func (bot *CQBot) CQGetGroupRootFiles(groupID int64) MSG

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

func (*CQBot) CQGetGroupSystemMessages

func (bot *CQBot) CQGetGroupSystemMessages() MSG

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

func (bot *CQBot) CQGetImage(file string) MSG

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

func (bot *CQBot) CQGetLoginInfo() MSG

CQGetLoginInfo 获取登录号信息

https://git.io/Jtz1I

func (*CQBot) CQGetMessage

func (bot *CQBot) CQGetMessage(messageID int32) MSG

CQGetMessage 获取消息

https://git.io/Jtz1b

func (*CQBot) CQGetModelShow

func (bot *CQBot) CQGetModelShow(modelName string) MSG

CQGetModelShow 获取在线机型

https://club.vip.qq.com/onlinestatus/set

func (*CQBot) CQGetOnlineClients

func (bot *CQBot) CQGetOnlineClients(noCache bool) MSG

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

func (*CQBot) CQGetQiDianAccountInfo

func (bot *CQBot) CQGetQiDianAccountInfo() MSG

CQGetQiDianAccountInfo 获取企点账号信息

func (*CQBot) CQGetStatus

func (bot *CQBot) CQGetStatus() MSG

CQGetStatus 获取运行状态

https://git.io/JtzMe

func (*CQBot) CQGetStrangerInfo

func (bot *CQBot) CQGetStrangerInfo(userID int64) MSG

CQGetStrangerInfo 获取陌生人信息

https://git.io/Jtz17

func (*CQBot) CQGetVersionInfo

func (bot *CQBot) CQGetVersionInfo() MSG

CQGetVersionInfo 获取版本信息

https://git.io/JtwUs

func (*CQBot) CQGetVipInfo

func (bot *CQBot) CQGetVipInfo(userID int64) MSG

CQGetVipInfo 扩展API-获取VIP信息

https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96vip%E4%BF%A1%E6%81%AF

func (*CQBot) CQGetWordSlices

func (bot *CQBot) CQGetWordSlices(content string) MSG

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

func (*CQBot) CQGroupFileCreateFolder

func (bot *CQBot) CQGroupFileCreateFolder(groupID int64, parentID, name string) MSG

CQGroupFileCreateFolder 拓展API-创建群文件文件夹

func (*CQBot) CQGroupFileDeleteFile

func (bot *CQBot) CQGroupFileDeleteFile(groupID int64, parentID, id string, busID int32) MSG

CQGroupFileDeleteFile 拓展API-删除群文件

func (*CQBot) CQGroupFileDeleteFolder

func (bot *CQBot) CQGroupFileDeleteFolder(groupID int64, id string) MSG

CQGroupFileDeleteFolder 拓展API-删除群文件文件夹

func (*CQBot) CQHandleQuickOperation

func (bot *CQBot) CQHandleQuickOperation(context, operation gjson.Result) MSG

CQHandleQuickOperation 隐藏API-对事件执行快速操作

https://git.io/Jtz15

func (*CQBot) CQOcrImage

func (bot *CQBot) CQOcrImage(imageID string) MSG

CQOcrImage 扩展API-图片OCR

https://docs.go-cqhttp.org/api/#%E5%9B%BE%E7%89%87-ocr

func (*CQBot) CQProcessFriendRequest

func (bot *CQBot) CQProcessFriendRequest(flag string, approve bool) MSG

CQProcessFriendRequest 处理加好友请求

https://git.io/Jtz11

func (*CQBot) CQProcessGroupRequest

func (bot *CQBot) CQProcessGroupRequest(flag, subType, reason string, approve bool) MSG

CQProcessGroupRequest 处理加群请求/邀请

https://git.io/Jtz1D

func (*CQBot) CQSendGroupForwardMessage

func (bot *CQBot) CQSendGroupForwardMessage(groupID int64, m gjson.Result) MSG

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

func (bot *CQBot) CQSendGroupMessage(groupID int64, i interface{}, autoEscape bool) MSG

CQSendGroupMessage 发送群消息

https://git.io/Jtz1c

func (*CQBot) CQSendPrivateMessage

func (bot *CQBot) CQSendPrivateMessage(userID int64, groupID int64, i interface{}, autoEscape bool) MSG

CQSendPrivateMessage 发送私聊消息

https://git.io/Jtz1l

func (*CQBot) CQSetEssenceMessage

func (bot *CQBot) CQSetEssenceMessage(messageID int32) MSG

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

func (bot *CQBot) CQSetGroupAdmin(groupID, userID int64, enable bool) MSG

CQSetGroupAdmin 群组设置管理员

https://git.io/Jtz1S

func (*CQBot) CQSetGroupAnonymousBan

func (bot *CQBot) CQSetGroupAnonymousBan(groupID int64, flag string, duration int32) MSG

CQSetGroupAnonymousBan 群组匿名用户禁言

https://git.io/Jtz1p

func (*CQBot) CQSetGroupBan

func (bot *CQBot) CQSetGroupBan(groupID, userID int64, duration uint32) MSG

CQSetGroupBan 群组单人禁言

https://git.io/Jtz1w

func (*CQBot) CQSetGroupCard

func (bot *CQBot) CQSetGroupCard(groupID, userID int64, card string) MSG

CQSetGroupCard 设置群名片(群备注)

https://git.io/Jtz1B

func (*CQBot) CQSetGroupKick

func (bot *CQBot) CQSetGroupKick(groupID, userID int64, msg string, block bool) MSG

CQSetGroupKick 群组踢人

https://git.io/Jtz1V

func (*CQBot) CQSetGroupLeave

func (bot *CQBot) CQSetGroupLeave(groupID int64) MSG

CQSetGroupLeave 退出群组

https://git.io/Jtz1K

func (*CQBot) CQSetGroupMemo

func (bot *CQBot) CQSetGroupMemo(groupID int64, msg string, img string) MSG

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

func (bot *CQBot) CQSetGroupName(groupID int64, name string) MSG

CQSetGroupName 设置群名

https://git.io/Jtz12

func (*CQBot) CQSetGroupPortrait

func (bot *CQBot) CQSetGroupPortrait(groupID int64, file, cache string) MSG

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

func (bot *CQBot) CQSetGroupSpecialTitle(groupID, userID int64, title string) MSG

CQSetGroupSpecialTitle 设置群组专属头衔

https://git.io/Jtz10

func (*CQBot) CQSetGroupWholeBan

func (bot *CQBot) CQSetGroupWholeBan(groupID int64, enable bool) MSG

CQSetGroupWholeBan 群组全员禁言

https://git.io/Jtz1o

func (*CQBot) CQSetModelShow

func (bot *CQBot) CQSetModelShow(modelName string, modelShow string) MSG

CQSetModelShow 设置在线机型

https://club.vip.qq.com/onlinestatus/set

func (*CQBot) CQUploadGroupFile

func (bot *CQBot) CQUploadGroupFile(groupID int64, file, name, folder string) MSG

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

func (bot *CQBot) ConvertObjectMessage(m gjson.Result, isGroup bool) (r []message.IMessageElement)

ConvertObjectMessage 将消息JSON对象转为消息元素数组

func (*CQBot) ConvertStringMessage

func (bot *CQBot) ConvertStringMessage(raw string, isGroup bool) (r []message.IMessageElement)

ConvertStringMessage 将消息字符串转为消息元素数组

func (*CQBot) GetMessage

func (bot *CQBot) GetMessage(mid int32) MSG

GetMessage 获取给定消息id对应的消息

func (*CQBot) InsertGroupMessage

func (bot *CQBot) InsertGroupMessage(m *message.GroupMessage) int32

InsertGroupMessage 群聊消息入数据库

func (*CQBot) InsertPrivateMessage

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

func (bot *CQBot) OnEventPush(f func(buf *bytes.Buffer))

OnEventPush 注册事件上报函数

func (*CQBot) Release

func (bot *CQBot) Release()

Release 释放Bot实例

func (*CQBot) SendGroupMessage

func (bot *CQBot) SendGroupMessage(groupID int64, m *message.SendingMessage) int32

SendGroupMessage 发送群消息

func (*CQBot) SendPrivateMessage

func (bot *CQBot) SendPrivateMessage(target int64, groupID int64, m *message.SendingMessage) int32

SendPrivateMessage 发送私聊消息

func (*CQBot) ToElement

func (bot *CQBot) ToElement(t string, d map[string]string, isGroup bool) (m interface{}, err error)

ToElement 将解码后的CQCode转换为Element.

返回 interface{} 存在三种类型

message.IMessageElement []message.IMessageElement nil

func (*CQBot) UploadLocalImageAsGroup

func (bot *CQBot) UploadLocalImageAsGroup(groupCode int64, img *LocalImageElement) (*message.GroupImageElement, error)

UploadLocalImageAsGroup 上传本地图片至群聊

func (*CQBot) UploadLocalImageAsPrivate

func (bot *CQBot) UploadLocalImageAsPrivate(userID int64, img *LocalImageElement) (*message.FriendImageElement, error)

UploadLocalImageAsPrivate 上传本地图片至私聊

func (*CQBot) UploadLocalVideo

func (bot *CQBot) UploadLocalVideo(target int64, v *LocalVideoElement) (*message.ShortVideoElement, error)

UploadLocalVideo 上传本地短视频至群聊

type GiftElement

type GiftElement struct {
	Target int64
	GiftID message.GroupGift
}

GiftElement 礼物

func (*GiftElement) Type

func (e *GiftElement) Type() message.ElementType

Type 获取元素类型ID

type LocalImageElement

type LocalImageElement struct {
	message.ImageElement
	Stream io.ReadSeeker
	File   string
}

LocalImageElement 本地图片

type LocalVideoElement

type LocalVideoElement struct {
	message.ShortVideoElement
	File string
	// contains filtered or unexported fields
}

LocalVideoElement 本地视频

type LocalVoiceElement

type LocalVoiceElement struct {
	message.VoiceElement
	Stream io.ReadSeeker
}

LocalVoiceElement 本地语音

type MSG

type MSG map[string]interface{}

MSG 消息Map

func Failed

func Failed(code int, msg ...string) MSG

Failed 生成失败返回值

func OK

func OK(data interface{}) MSG

OK 生成成功返回值

func ToArrayMessage

func ToArrayMessage(e []message.IMessageElement, id int64, isRaw ...bool) (r []MSG)

ToArrayMessage 将消息元素数组转为MSG数组以用于消息上报

func (MSG) ToJSON

func (m MSG) ToJSON() string

ToJSON 生成JSON字符串

type PokeElement

type PokeElement struct {
	Target int64
}

PokeElement 拍一拍

func (*PokeElement) Type

func (e *PokeElement) Type() message.ElementType

Type 获取元素类型ID

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL