coolq

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ActionSendPrivateMsg 发送私聊消息
	ActionSendPrivateMsg = "send_private_msg" // DONE: websocket
	// ActionSendGroupMsg 发送群消息
	ActionSendGroupMsg = "send_group_msg" // DONE: websocket
	// ActionSetGroupKick 群组踢人
	ActionSetGroupKick = "set_group_kick" // DONE: websocket
	// ActionSetGroupBan 群组单人禁言
	ActionSetGroupBan = "set_group_ban" // DONE: websocket
	// ActionSetGroupWholeBan 群组全员禁言
	ActionSetGroupWholeBan = "set_group_whole_ban" // DONE: websocket
	// ActionGetStatus 获取插件运行状态
	ActionGetStatus = "get_status" // DONE: http
)

文档: https://cqhttp.cc/docs/4.4/#/API?id=api-列表 大致先做这些...

Variables

View Source
var Client = &cqclient{
	apiConn:       new(clients.WSClient),
	eventConn:     new(clients.WSClient),
	pluginEntries: make(map[string]pluginEntry),
}

Client 唯一的酷q机器人实体

Functions

func Escape

func Escape(txt string) string

Escape cq码转义 & -> & [ -> [ ] -> ] , -> ,

func Marshal

func Marshal(msg Message) []byte

Marshal 序列化成一个包含cq码的信息

func PluginRegister

func PluginRegister(plugins ...pluginInterface)

PluginRegister 插件注册

func Unmarshal

func Unmarshal(raw []byte, msg *Message) error

Unmarshal 反序列化bytes为一个msg

Types

type CQEvent

type CQEvent struct {
	Anonymous   QAnonymous `json:"anonymous"`
	Font        int64      `json:"font"`
	GroupID     int64      `json:"group_id"`
	Message     string     `json:"message"`
	MessageID   int64      `json:"message_id"`
	MessageType string     `json:"message_type"`
	PostType    string     `json:"post_type"`
	RawMessage  string     `json:"raw_message"`
	SelfID      int64      `json:"self_id"`
	SubType     string     `json:"sub_type"`
	Time        int64      `json:"time"`
	UserID      int64      `json:"user_id"`
}

CQEvent coolq事件上报格式

type CQResponse

type CQResponse struct {
	Status  string      `json:"status"`
	RetCode int         `json:"retcode"`
	Data    interface{} `json:"data"`
	Echo    int64       `json:"echo"`
}

CQResponse coolq ws响应类型

type CQTypeGetStatus

type CQTypeGetStatus struct {
	AppInitialized bool `json:"app_initialized"`
	AppEnabled     bool `json:"app_enabled"`
	PluginsGood    bool `json:"plugins_good"`
	AppGood        bool `json:"app_good"`
	Online         bool `json:"online"`
	Good           bool `json:"good"`
}

CQTypeGetStatus ActionGetStatus的响应数据格式

type CQTypeSendGroupMsg

type CQTypeSendGroupMsg struct {
	GroupID    int64  `json:"group_id"`
	Message    string `json:"message"`
	AutoEscape bool   `json:"auto_escape"`
}

CQTypeSendGroupMsg SendGroupMsg动作的数据格式

type CQTypeSendPrivateMsg added in v0.0.3

type CQTypeSendPrivateMsg struct {
	UserID     int64  `json:"user_id"`
	Message    string `json:"message"`
	AutoEscape bool   `json:"auto_escape"`
}

CQTypeSendPrivateMsg ActionSendPrivateMsg动作的数据格式

type CQTypeSetGroupBan added in v0.0.3

type CQTypeSetGroupBan struct {
	GroupID  int64 `json:"group_id"`
	UserID   int64 `json:"user_id"`
	Duration int64 `json:"duration"`
}

CQTypeSetGroupBan ActionSetGroupBan动作数据格式

type CQTypeSetGroupKick added in v0.0.3

type CQTypeSetGroupKick struct {
	GroupID          int64 `json:"group_id"`
	UserID           int64 `json:"user_id"`
	RejectAddRequest bool  `json:"reject_add_request"`
}

CQTypeSetGroupKick AActionSetGroupKick动作数据格式

type CQTypeSetGroupWholeBan added in v0.0.3

type CQTypeSetGroupWholeBan struct {
	GroupID int64 `json:"group_id"`
	Enable  bool  `json:"enable"`
}

CQTypeSetGroupWholeBan ActionSetGroupWholeBan动作数据格式

type CQWSMessage

type CQWSMessage struct {
	Action string      `json:"action"`
	Params interface{} `json:"params"`
	Echo   int64       `json:"echo"`
}

CQWSMessage coolq ws基本消息类型

type Filter

type Filter func(*CQEvent) bool

Filter 过滤函数

type Handler

type Handler func(*CQEvent)

Handler 处理函数

type Message

type Message []Section

Message 酷q消息

func AddSection

func AddSection(msg Message, sections ...Section) Message

AddSection 向一个消息添加新的段落

func NewMessage

func NewMessage() Message

NewMessage 创建一个新的消息

type Number

type Number int64

Number number

type Plugin

type Plugin struct {
}

Plugin 插件基础原型

func (Plugin) Filters

func (_plugin Plugin) Filters() map[string]Filter

Filters 插件过滤器

func (Plugin) Handlers

func (_plugin Plugin) Handlers() map[string]Handler

Handlers 插件过滤器

func (Plugin) Load

func (_plugin Plugin) Load() error

Load 插件加载

func (Plugin) Loaded

func (_plugin Plugin) Loaded()

Loaded 加载完成的事件

func (Plugin) Name

func (_plugin Plugin) Name() string

Name 获取插件名字

type QAnonymous

type QAnonymous struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
	Flag string `json:"flag"`
}

QAnonymous QQ匿名消息格式

type Section

type Section struct {
	Type string            `json:"type"`
	Data map[string]string `json:"data"`
}

Section 消息段落 https://cqhttp.cc/docs/4.4/#/Message

func NewImageSection

func NewImageSection(src string) Section

NewImageSection 创建一个新的图片段落

func NewSection

func NewSection(t string, d map[string]string) Section

NewSection 创建一个新的段落

func NewTextSection

func NewTextSection(text string) Section

NewTextSection 创建一个新的文本段落

type String

type String string

String string

Jump to

Keyboard shortcuts

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