Documentation ¶
Index ¶
- func AdminPermission(event *Event, state State) bool
- func CallAction(action string, params Params) gjson.Result
- func DeleteMessage(messageID int64)
- func GetForwardMessage(id int64) gjson.Result
- func GetFriendList() gjson.Result
- func GetGroupHonorInfo(groupID int64, hType string) gjson.Result
- func GetGroupList() gjson.Result
- func GetGroupMemberInfo(groupID int64, userID int64, noCache bool) gjson.Result
- func GetGroupMemberList(groupID int64) gjson.Result
- func GetGroupSystemMessage() gjson.Result
- func GetImage(file string) gjson.Result
- func GetLoginInfo() gjson.Result
- func GetRecord(file string, outFormat string) gjson.Result
- func GetStrangerInfo(userID int64, noCache bool) gjson.Result
- func GetVersionInfo() gjson.Result
- func GetWordSlices(content string) gjson.Result
- func OCRImage(file string) gjson.Result
- func OnlyGroup(event *Event, _ State) bool
- func OnlyPrivate(event *Event, _ State) bool
- func OnlyToMe(event *Event, _ State) bool
- func OwnerPermission(event *Event, state State) bool
- func RegisterPlugin(plugin IPlugin)
- func Run(op Config)
- func Send(event Event, message interface{}) int64
- func SendGroupForwardMessage(groupID int64, message message.Message) gjson.Result
- func SendGroupMessage(groupID int64, message interface{}) int64
- func SendPrivateMessage(userID int64, message interface{}) int64
- func SetFriendAddRequest(flag string, approve bool, remark string)
- func SetGroupAddRequest(flag string, subType string, approve bool, reason string)
- func SetGroupAdmin(groupID, userID int64, enable bool)
- func SetGroupAnonymous(groupID int64, enable bool)
- func SetGroupBan(groupID, userID, duration int64)
- func SetGroupCard(groupID, userID int64, card string)
- func SetGroupKick(groupID, userID int64, rejectAddRequest bool)
- func SetGroupLeave(groupID int64, isDismiss bool)
- func SetGroupName(groupID int64, groupName string)
- func SetGroupPortrait(groupID int64, file string)
- func SetGroupSpecialTitle(groupID int64, userID int64, specialTitle string)
- func SetGroupWholeBan(groupID int64, enable bool)
- func SuperUserPermission(event *Event, _ State) bool
- type APIRequest
- type APIResponse
- type Config
- type Driver
- type Event
- type File
- type FutureEvent
- type Group
- type Handler
- type Hooker
- type IPlugin
- type Matcher
- func On(mType string, rules ...Rule) *Matcher
- func OnCommand(commands string, rules ...Rule) *Matcher
- func OnCommandGroup(commands []string, rules ...Rule) *Matcher
- func OnFullMatch(src string, rules ...Rule) *Matcher
- func OnFullMatchGroup(src []string, rules ...Rule) *Matcher
- func OnKeyword(keyword string, rules ...Rule) *Matcher
- func OnKeywordGroup(keywords []string, rules ...Rule) *Matcher
- func OnMessage(rules ...Rule) *Matcher
- func OnMetaEvent(rules ...Rule) *Matcher
- func OnNotice(rules ...Rule) *Matcher
- func OnPrefix(prefix string, rules ...Rule) *Matcher
- func OnPrefixGroup(prefix []string, rules ...Rule) *Matcher
- func OnRegex(regexPattern string, rules ...Rule) *Matcher
- func OnRequest(rules ...Rule) *Matcher
- func OnSuffix(suffix string, rules ...Rule) *Matcher
- func OnSuffixGroup(suffix []string, rules ...Rule) *Matcher
- func StoreMatcher(m *Matcher) *Matcher
- func StoreTempMatcher(m *Matcher) *Matcher
- type Message
- type Optiondeprecated
- type Params
- type PluginInfo
- type Response
- type Rule
- func CheckSession(e1 *Event) Rule
- func CheckUser(userId ...int64) Rule
- func CommandRule(commands ...string) Rule
- func FullMatchRule(src ...string) Rule
- func KeywordRule(src ...string) Rule
- func PrefixRule(prefixes ...string) Rule
- func RegexRule(regexPattern string) Rule
- func ReplyRule(messageID int64) Rule
- func SuffixRule(suffixes ...string) Rule
- func Type(type_ string) Rule
- type State
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdminPermission ¶
AdminPermission only triggered by the group admins or higher permission
func CallAction ¶
CallAction 调用 cqhttp API
func DeleteMessage ¶
func DeleteMessage(messageID int64)
DeleteMessage 撤回消息 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#delete_msg-%E6%92%A4%E5%9B%9E%E6%B6%88%E6%81%AF
func GetForwardMessage ¶
GetForwardMessage 获取合并转发消息 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_forward_msg-%E8%8E%B7%E5%8F%96%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91%E6%B6%88%E6%81%AF
func GetFriendList ¶
GetFriendList 获取好友列表 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_friend_list-%E8%8E%B7%E5%8F%96%E5%A5%BD%E5%8F%8B%E5%88%97%E8%A1%A8
func GetGroupHonorInfo ¶
GetGroupHonorInfo 获取群荣誉信息 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_honor_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E8%8D%A3%E8%AA%89%E4%BF%A1%E6%81%AF
func GetGroupList ¶
GetGroupList 获取群列表 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_list-%E8%8E%B7%E5%8F%96%E7%BE%A4%E5%88%97%E8%A1%A8
func GetGroupMemberInfo ¶
GetGroupMemberInfo 获取群成员信息 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_member_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%88%90%E5%91%98%E4%BF%A1%E6%81%AF
func GetGroupMemberList ¶
GetGroupMemberList 获取群成员列表 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_member_list-%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8
func GetGroupSystemMessage ¶
GetGroupSystemMessage 获取群系统消息 https://github.com/Mrs4s/go-cqhttp/blob/master/docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%B3%BB%E7%BB%9F%E6%B6%88%E6%81%AF
func GetImage ¶
GetImage 获取图片 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_image-%E8%8E%B7%E5%8F%96%E5%9B%BE%E7%89%87
func GetLoginInfo ¶
GetLoginInfo 获取登录号信息 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_login_info-%E8%8E%B7%E5%8F%96%E7%99%BB%E5%BD%95%E5%8F%B7%E4%BF%A1%E6%81%AF
func GetRecord ¶
GetRecord 获取语音 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_record-%E8%8E%B7%E5%8F%96%E8%AF%AD%E9%9F%B3
func GetStrangerInfo ¶
GetStrangerInfo 获取陌生人信息 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_stranger_info-%E8%8E%B7%E5%8F%96%E9%99%8C%E7%94%9F%E4%BA%BA%E4%BF%A1%E6%81%AF
func GetVersionInfo ¶
GetVersionInfo 获取运行状态 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_status-%E8%8E%B7%E5%8F%96%E8%BF%90%E8%A1%8C%E7%8A%B6%E6%80%81
func GetWordSlices ¶
GetWordSlices 获取中文分词 https://github.com/Mrs4s/go-cqhttp/blob/master/docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E4%B8%AD%E6%96%87%E5%88%86%E8%AF%8D
func OCRImage ¶
OCRImage 图片OCR https://github.com/Mrs4s/go-cqhttp/blob/master/docs/cqhttp.md#%E5%9B%BE%E7%89%87ocr
func OnlyPrivate ¶
OnlyPrivate requires that the event is private message
func OwnerPermission ¶
OwnerPermission only triggered by the group owner or higher permission
func RegisterPlugin ¶
func RegisterPlugin(plugin IPlugin)
RegisterPlugin register the plugin to ZeroBot
func SendGroupForwardMessage ¶
SendGroupForwardMessage 发送合并转发(群) https://github.com/Mrs4s/go-cqhttp/blob/master/docs/cqhttp.md#%E5%9B%BE%E7%89%87ocr
func SendGroupMessage ¶
SendGroupMessage 发送群消息 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#send_group_msg-%E5%8F%91%E9%80%81%E7%BE%A4%E6%B6%88%E6%81%AF
func SendPrivateMessage ¶
SendPrivateMessage 发送私聊消息 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#send_private_msg-%E5%8F%91%E9%80%81%E7%A7%81%E8%81%8A%E6%B6%88%E6%81%AF
func SetFriendAddRequest ¶
SetFriendAddRequest 处理加好友请求 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_friend_add_request-%E5%A4%84%E7%90%86%E5%8A%A0%E5%A5%BD%E5%8F%8B%E8%AF%B7%E6%B1%82
func SetGroupAddRequest ¶
SetGroupAddRequest 处理加群请求/邀请 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_add_request-%E5%A4%84%E7%90%86%E5%8A%A0%E7%BE%A4%E8%AF%B7%E6%B1%82%E9%82%80%E8%AF%B7
func SetGroupAdmin ¶
SetGroupAdmin 群组设置管理员 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_whole_ban-%E7%BE%A4%E7%BB%84%E5%85%A8%E5%91%98%E7%A6%81%E8%A8%80
func SetGroupAnonymous ¶
SetGroupAnonymous 群组匿名 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_anonymous-%E7%BE%A4%E7%BB%84%E5%8C%BF%E5%90%8D
func SetGroupBan ¶
func SetGroupBan(groupID, userID, duration int64)
SetGroupBan 群组单人禁言 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_ban-%E7%BE%A4%E7%BB%84%E5%8D%95%E4%BA%BA%E7%A6%81%E8%A8%80
func SetGroupCard ¶
SetGroupCard 设置群名片(群备注) https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_card-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%90%8D%E7%89%87%E7%BE%A4%E5%A4%87%E6%B3%A8
func SetGroupKick ¶
SetGroupKick 群组踢人 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_kick-%E7%BE%A4%E7%BB%84%E8%B8%A2%E4%BA%BA
func SetGroupLeave ¶
SetGroupLeave 退出群组 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_leave-%E9%80%80%E5%87%BA%E7%BE%A4%E7%BB%84
func SetGroupName ¶
SetGroupName 设置群名 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_name-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%90%8D
func SetGroupPortrait ¶
SetGroupPortrait 设置群头像 https://github.com/Mrs4s/go-cqhttp/blob/master/docs/cqhttp.md#%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%A4%B4%E5%83%8F
func SetGroupSpecialTitle ¶
SetGroupSpecialTitle 设置群组专属头衔 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_special_title-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E7%BB%84%E4%B8%93%E5%B1%9E%E5%A4%B4%E8%A1%94
func SetGroupWholeBan ¶
SetGroupWholeBan 群组全员禁言 https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_whole_ban-%E7%BE%A4%E7%BB%84%E5%85%A8%E5%91%98%E7%A6%81%E8%A8%80
func SuperUserPermission ¶
SuperUserPermission only triggered by the bot's owner
Types ¶
type APIRequest ¶ added in v0.9.2
type APIRequest struct { Action string `json:"action"` Params Params `json:"params"` Echo uint64 `json:"echo"` // 该项不用填写,由Driver生成 }
APIRequest is the request sending to the cqhttp https://github.com/howmanybots/onebot/blob/master/v11/specs/communication/ws.md
type APIResponse ¶ added in v0.9.2
type APIResponse struct { Status string `json:"status"` Data gjson.Result `json:"data"` Msg string `json:"msg"` Wording string `json:"wording"` RetCode int64 `json:"retcode"` Echo uint64 `json:"echo"` }
APIResponse is the response of calling API https://github.com/howmanybots/onebot/blob/master/v11/specs/communication/ws.md
type Config ¶
type Config struct { Host string `json:"host"` //host地址 Port string `json:"port"` //端口 AccessToken string `json:"access_token"` //认证token NickName []string `json:"nickname"` //机器人名称 CommandPrefix string `json:"command_prefix"` //触发命令 SuperUsers []string `json:"super_users"` //超级用户 SelfID string `json:"self_id"` // 机器人账号 Driver Driver `json:"-"` }
Config is config of zero bot
var BotConfig Config
BotConfig 运行中bot的配置,是Run函数的参数的拷贝
type Driver ¶ added in v0.9.2
type Driver interface { Connect(url string, accessToken string) Listen(func([]byte)) Send(APIRequest) (APIResponse, error) }
Driver 与OneBot通信的驱动,使用driver.DefaultWebSocketDriver
type Event ¶
type Event struct { Time int64 `json:"time"` PostType string `json:"post_type"` DetailType string `json:"-"` MessageType string `json:"message_type"` SubType string `json:"sub_type"` MessageID int64 `json:"message_id"` GroupID int64 `json:"group_id"` UserID int64 `json:"user_id"` RawMessage string `json:"raw_message"` // raw_message is always string Anonymous interface{} `json:"anonymous"` AnonymousFlag string `json:"anonymous_flag"` // This field is deprecated and will get removed, see #11 Event string `json:"event"` NoticeType string `json:"notice_type"` // This field is deprecated and will get removed, see #11 OperatorID int64 `json:"operator_id"` // This field is used for Notice Event File *File `json:"file"` RequestType string `json:"request_type"` Flag string `json:"flag"` Comment string `json:"comment"` // This field is used for Request Event Message message.Message `json:"-"` // Message parsed Sender *User `json:"sender"` NativeMessage jsoniter.RawMessage `json:"message"` IsToMe bool `json:"-"` RawEvent gjson.Result `json:"-"` // raw event }
Event is the event emitted form cqhttp
type FutureEvent ¶
FutureEvent 是 ZeroBot 交互式的核心,用于异步获取指定事件
func NewFutureEvent ¶
func NewFutureEvent(Type string, Priority int, Block bool, rule ...Rule) *FutureEvent
NewFutureEvent 创建一个FutureEvent, 并返回其指针
func (*FutureEvent) Next ¶
func (n *FutureEvent) Next() <-chan Event
Next 返回一个 chan 用于接收下一个指定事件
该 chan 必须接收,如需手动取消监听,请使用 Repeat 方法
func (*FutureEvent) Repeat ¶
func (n *FutureEvent) Repeat() (recv <-chan Event, cancel func())
Repeat 返回一个 chan 用于接收无穷个指定事件,和一个取消监听的函数
如果没有取消监听,将不断监听指定事件
func (*FutureEvent) Take ¶
func (n *FutureEvent) Take(num int) <-chan Event
Take 基于 Repeat 封装,返回一个 chan 接收指定数量的事件
该 chan 对象必须接收,否则将有 goroutine 泄漏,如需手动取消请使用 Repeat
type Group ¶
type Group struct { ID int64 `json:"group_id"` Name string `json:"group_name"` MemberCount int64 `json:"member_count"` MaxMemberCount int64 `json:"max_member_count"` }
type IPlugin ¶
type IPlugin interface { // GetPluginInfo 获取插件信息 GetPluginInfo() PluginInfo // Start 开启工作 Start() }
IPlugin is the plugin of the ZeroBot
type Matcher ¶
type Matcher struct { // Temp 是否为临时Matcher,临时 Matcher 匹配一次后就会删除当前 Matcher Temp bool // Block 是否阻断后续 Matcher,为 true 时当前Matcher匹配成功后,后续Matcher不参与匹配 Block bool // Priority 优先级,越小优先级越高 Priority int // State 上下文 State State // Event 当前匹配到的事件 Event *Event // Type 匹配的事件类型 Type Rule // Rules 匹配规则 Rules []Rule // Handler 处理事件的函数 Handler Handler }
Matcher 是 ZeroBot 匹配和处理事件的最小单元
func OnCommandGroup ¶
OnCommandGroup 命令触发器组
func OnFullMatchGroup ¶
OnFullMatchGroup 完全匹配触发器组
func OnKeywordGroup ¶
OnKeywordGroup 关键词触发器组
func OnPrefixGroup ¶
OnPrefixGroup 前缀触发器组
func OnSuffixGroup ¶
OnSuffixGroup 后缀触发器组
func StoreMatcher ¶
StoreMatcher store a matcher to matcher list.
func StoreTempMatcher ¶
StoreTempMatcher store a matcher only triggered once.
func (*Matcher) FutureEvent ¶
func (m *Matcher) FutureEvent(Type string, rule ...Rule) *FutureEvent
FutureEvent 返回一个 FutureEvent 实例指针,用于获取满足 Rule 的 未来事件
func (*Matcher) SetPriority ¶
SetPriority 设置当前 Matcher 优先级
type Message ¶
type PluginInfo ¶
type PluginInfo struct { Author string // 作者 PluginName string // 插件名 Version string // 版本 Details string // 插件说明 }
PluginInfo is the plugin's information
type Rule ¶
Rule filter the event
func CommandRule ¶
CommandRule check if the message is a command and trim the command name
func FullMatchRule ¶
FullMatchRule check if src has the same copy of the message
func KeywordRule ¶
KeywordRule check if the message has a keyword or keywords
type User ¶
type User struct { // Private sender // https://github.com/howmanybots/onebot/blob/master/v11/specs/event/message.md#%E7%A7%81%E8%81%8A%E6%B6%88%E6%81%AF ID int64 `json:"user_id"` NickName string `json:"nickname"` Sex string `json:"sex"` // "male"、"female"、"unknown" Age int `json:"age"` Area string `json:"area"` // Group member // https://github.com/howmanybots/onebot/blob/master/v11/specs/event/message.md#%E7%BE%A4%E6%B6%88%E6%81%AF Card string `json:"card"` Title string `json:"title"` Level string `json:"level"` Role string `json:"role"` // "owner"、"admin"、"member" // Group anonymous AnonymousID int64 `json:"anonymous_id" anonymous:"id"` AnonymousName string `json:"anonymous_name" anonymous:"name"` AnonymousFlag string `json:"anonymous_flag" anonymous:"flag"` }
User is a user on QQ.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package driver provides the default driver of zerobot
|
Package driver provides the default driver of zerobot |
kv
Package kv provides a simple wrap of goleveldb for multi bucket database
|
Package kv provides a simple wrap of goleveldb for multi bucket database |
manager
Package manager provides a simple group plugin manager.
|
Package manager provides a simple group plugin manager. |
rate
Package rate provides a rate limiter hooker, this package is based on golang.org/x/time/rate
|
Package rate provides a rate limiter hooker, this package is based on golang.org/x/time/rate |
shell
Package shell provides a simple shell parser for zerobot.
|
Package shell provides a simple shell parser for zerobot. |
utils
|
|