zero

package module
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: GPL-3.0 Imports: 15 Imported by: 505

README

ZeroBot

Go Report Card golangci-lint Badge Badge

文档正在咕咕中, 具体使用可以参考example文件夹, 交流群: 892659456

⚡️ 快速使用

package main

import (
	zero "github.com/wdvxdr1123/ZeroBot"
	"github.com/wdvxdr1123/ZeroBot/driver"
)

func main() {
	zero.OnCommand("hello").
            Handle(func(ctx *zero.Ctx) {
                ctx.Send("world")
            })
	
	zero.Run(zero.Config{
		NickName:      []string{"bot"},
		CommandPrefix: "/",
		SuperUsers:    []string{"123456"},
		Driver: []zero.Driver{
			driver.NewWebSocketClient("ws://127.0.0.1:6700", "access_token"),
		},
	})
	select {}
}

🎯 特性

  • 可通过 init 函数实现插件式
  • 底层与 Onebot 通信驱动可换,目前支持正向WS
  • 多Q机器人开发支持
特别感谢

nonebot/nonebot2

catsworld/qq-bot-api

License

FOSSA Status

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APICallers callerMap

APICallers 所有的APICaller列表, 通过self-ID映射

Functions

func AdminPermission

func AdminPermission(ctx *Ctx) bool

AdminPermission only triggered by the group admins or higher permission

func OnlyGroup

func OnlyGroup(ctx *Ctx) bool

OnlyGroup requires that the ctx.Event is public/group message

func OnlyPrivate

func OnlyPrivate(ctx *Ctx) bool

OnlyPrivate requires that the ctx.Event is private message

func OnlyToMe

func OnlyToMe(ctx *Ctx) bool

OnlyToMe only triggered in conditions of @bot or begin with the nicknames

func OwnerPermission

func OwnerPermission(ctx *Ctx) bool

OwnerPermission only triggered by the group owner or higher permission

func RangeBot added in v1.0.0

func RangeBot(iter func(id int64, ctx *Ctx) bool)

RangeBot 遍历所有bot (Ctx)实例

单次操作返回 true 则继续遍历,否则退出

func Run

func Run(op Config)

Run 主函数初始化

func SuperUserPermission

func SuperUserPermission(ctx *Ctx) bool

SuperUserPermission only triggered by the bot's owner

Types

type APICaller added in v1.0.0

type APICaller interface {
	CallApi(request APIRequest) (APIResponse, error)
}

APICaller is the interface of CallApi

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 {
	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 Ctx added in v1.0.0

type Ctx struct {
	Event *Event
	State State
	// contains filtered or unexported fields
}

Ctx represents the Context which hold the event. 代表上下文

func GetBot added in v1.0.0

func GetBot(id int64) *Ctx

GetBot 获取指定的bot (Ctx)实例

func (*Ctx) Block added in v1.2.4

func (ctx *Ctx) Block()

Block 阻止后续触发

func (*Ctx) CallAction added in v1.0.0

func (ctx *Ctx) CallAction(action string, params Params) APIResponse

CallAction 调用 cqhttp API

func (*Ctx) CheckSession added in v1.0.0

func (ctx *Ctx) CheckSession() Rule

CheckSession 判断会话连续性

func (*Ctx) DeleteMessage added in v1.0.0

func (ctx *Ctx) 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 (*Ctx) ExtractPlainText added in v1.2.3

func (ctx *Ctx) ExtractPlainText() string

ExtractPlainText 提取消息中的纯文本

func (*Ctx) FutureEvent added in v1.0.0

func (ctx *Ctx) FutureEvent(Type string, rule ...Rule) *FutureEvent

FutureEvent ...

func (*Ctx) Get added in v1.0.0

func (ctx *Ctx) Get(prompt string) string

Get ..

func (*Ctx) GetGroupSystemMessage added in v1.0.0

func (ctx *Ctx) GetGroupSystemMessage() gjson.Result

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 (*Ctx) GetMatcher added in v1.0.0

func (ctx *Ctx) GetMatcher() *Matcher

GetMatcher ...

func (*Ctx) GetWordSlices added in v1.0.0

func (ctx *Ctx) GetWordSlices(content string) gjson.Result

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 (*Ctx) OCRImage added in v1.0.0

func (ctx *Ctx) OCRImage(file string) gjson.Result

OCRImage 图片OCR https://github.com/Mrs4s/go-cqhttp/blob/master/docs/cqhttp.md#%E5%9B%BE%E7%89%87ocr

func (*Ctx) Parse added in v1.0.0

func (ctx *Ctx) Parse(model interface{}) (err error)

Parse 将 Ctx.State 映射到结构体

func (*Ctx) Send added in v1.0.0

func (ctx *Ctx) Send(message interface{}) int64

Send 快捷发送消息

func (*Ctx) SendChain added in v1.1.0

func (ctx *Ctx) SendChain(message ...message.MessageSegment) int64

SendChain 快捷发送消息-消息链

func (*Ctx) SendGroupForwardMessage added in v1.0.0

func (ctx *Ctx) SendGroupForwardMessage(groupID int64, message message.Message) gjson.Result

SendGroupForwardMessage 发送合并转发(群) https://github.com/Mrs4s/go-cqhttp/blob/master/docs/cqhttp.md#%E5%9B%BE%E7%89%87ocr

func (*Ctx) SendGroupMessage added in v1.0.0

func (ctx *Ctx) SendGroupMessage(groupID int64, message interface{}) int64

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 (*Ctx) SendPrivateMessage added in v1.0.0

func (ctx *Ctx) SendPrivateMessage(userID int64, message interface{}) int64

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 (*Ctx) SetGroupAddRequest added in v1.0.0

func (ctx *Ctx) SetGroupAddRequest(flag string, subType string, approve bool, reason string)

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 (*Ctx) SetGroupAdmin added in v1.0.0

func (ctx *Ctx) SetGroupAdmin(groupID, userID int64, enable bool)

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 (*Ctx) SetGroupAnonymous added in v1.0.0

func (ctx *Ctx) SetGroupAnonymous(groupID int64, enable bool)

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 (*Ctx) SetGroupBan added in v1.0.0

func (ctx *Ctx) 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 (*Ctx) SetGroupCard added in v1.0.0

func (ctx *Ctx) SetGroupCard(groupID, userID int64, card string)

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 (*Ctx) SetGroupKick added in v1.0.0

func (ctx *Ctx) SetGroupKick(groupID, userID int64, rejectAddRequest bool)

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 (*Ctx) SetGroupLeave added in v1.0.0

func (ctx *Ctx) SetGroupLeave(groupID int64, isDismiss bool)

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 (*Ctx) SetGroupName added in v1.0.0

func (ctx *Ctx) SetGroupName(groupID int64, groupName string)

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 (*Ctx) SetGroupPortrait added in v1.0.0

func (ctx *Ctx) SetGroupPortrait(groupID int64, file string)

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 (*Ctx) SetGroupSpecialTitle added in v1.0.0

func (ctx *Ctx) SetGroupSpecialTitle(groupID int64, userID int64, specialTitle string)

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

type Driver added in v0.9.2

type Driver interface {
	Connect()
	Listen(func([]byte, APICaller))
}

Driver 与OneBot通信的驱动,使用driver.DefaultWebSocketDriver

type Engine added in v1.0.0

type Engine struct {
	// contains filtered or unexported fields
}

Engine is the pre_handler, post_handler manager

func New added in v1.0.0

func New() *Engine

New 生成空引擎

func (*Engine) On added in v1.0.0

func (e *Engine) On(typ string, rules ...Rule) *Matcher

On 添加新的指定消息类型的匹配器

func (*Engine) OnCommand added in v1.0.0

func (e *Engine) OnCommand(commands string, rules ...Rule) *Matcher

OnCommand 命令触发器

func (*Engine) OnCommandGroup added in v1.0.0

func (e *Engine) OnCommandGroup(commands []string, rules ...Rule) *Matcher

OnCommandGroup 命令触发器组

func (*Engine) OnFullMatch added in v1.0.0

func (e *Engine) OnFullMatch(src string, rules ...Rule) *Matcher

OnFullMatch 完全匹配触发器

func (*Engine) OnFullMatchGroup added in v1.0.0

func (e *Engine) OnFullMatchGroup(src []string, rules ...Rule) *Matcher

OnFullMatchGroup 完全匹配触发器组

func (*Engine) OnKeyword added in v1.0.0

func (e *Engine) OnKeyword(keyword string, rules ...Rule) *Matcher

OnKeyword 关键词触发器

func (*Engine) OnKeywordGroup added in v1.0.0

func (e *Engine) OnKeywordGroup(keywords []string, rules ...Rule) *Matcher

OnKeywordGroup 关键词触发器组

func (*Engine) OnMessage added in v1.0.0

func (e *Engine) OnMessage(rules ...Rule) *Matcher

OnMessage 消息触发器

func (*Engine) OnMetaEvent added in v1.0.0

func (e *Engine) OnMetaEvent(rules ...Rule) *Matcher

OnMetaEvent 元事件触发器

func (*Engine) OnNotice added in v1.0.0

func (e *Engine) OnNotice(rules ...Rule) *Matcher

OnNotice 系统提示触发器

func (*Engine) OnPrefix added in v1.0.0

func (e *Engine) OnPrefix(prefix string, rules ...Rule) *Matcher

OnPrefix 前缀触发器

func (*Engine) OnPrefixGroup added in v1.0.0

func (e *Engine) OnPrefixGroup(prefix []string, rules ...Rule) *Matcher

OnPrefixGroup 前缀触发器组

func (*Engine) OnRegex added in v1.0.0

func (e *Engine) OnRegex(regexPattern string, rules ...Rule) *Matcher

OnRegex 正则触发器

func (*Engine) OnRequest added in v1.0.0

func (e *Engine) OnRequest(rules ...Rule) *Matcher

OnRequest 请求消息触发器

func (*Engine) OnSuffix added in v1.0.0

func (e *Engine) OnSuffix(suffix string, rules ...Rule) *Matcher

OnSuffix 后缀触发器

func (*Engine) OnSuffixGroup added in v1.0.0

func (e *Engine) OnSuffixGroup(suffix []string, rules ...Rule) *Matcher

OnSuffixGroup 后缀触发器组

func (*Engine) SetBlock added in v1.2.4

func (e *Engine) SetBlock(block bool) *Engine

func (*Engine) UsePostHandler added in v1.0.0

func (e *Engine) UsePostHandler(handler ...Handler)

UsePostHandler 向该 Engine 添加新 PostHandler(Rule), 会在 Matcher 触发后触发,如果 PostHandler 返回 false, 则后续的 post handler 不会触发

不知道有啥用...(先留一个

func (*Engine) UsePreHandler added in v1.0.0

func (e *Engine) UsePreHandler(rules ...Rule)

UsePreHandler 向该 Engine 添加新 PreHandler(Rule), 会在 Rule 判断后, Matcher 触发前触发,如果 preHandler 没有通过,则 Matcher 不会触发

可用于速率限制,分群组管理插件等

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"`
	TargetID      int64               `json:"target_id"`
	SelfID        int64               `json:"self_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 File

type File struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Size  int64  `json:"size"`
	BusID int64  `json:"busid"`
}

File 文件

type FutureEvent

type FutureEvent struct {
	Type     string
	Priority int
	Rule     []Rule
	Block    bool
}

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"`
}

Group 群

type H added in v1.0.0

type H = Params

H 是 Params 的简称

type Handler

type Handler func(ctx *Ctx)

Handler 事件处理函数

type Matcher

type Matcher struct {
	// Temp 是否为临时Matcher,临时 Matcher 匹配一次后就会删除当前 Matcher
	Temp bool
	// Block 是否阻断后续 Matcher,为 true 时当前Matcher匹配成功后,后续Matcher不参与匹配
	Block bool
	// Priority 优先级,越小优先级越高
	Priority int
	// Event 当前匹配到的事件
	Event *Event
	// Type 匹配的事件类型
	Type Rule
	// Rules 匹配规则
	Rules []Rule
	// Handler 处理事件的函数
	Handler Handler
	// Engine 注册 Matcher 的 Engine,Engine可为一系列 Matcher 添加通用 Rule 和 其他钩子
	Engine *Engine
}

Matcher 是 ZeroBot 匹配和处理事件的最小单元

func On

func On(typ string, rules ...Rule) *Matcher

On 添加新的指定消息类型的匹配器(默认Engine)

func OnCommand

func OnCommand(commands string, rules ...Rule) *Matcher

OnCommand 命令触发器

func OnCommandGroup

func OnCommandGroup(commands []string, rules ...Rule) *Matcher

OnCommandGroup 命令触发器组

func OnFullMatch

func OnFullMatch(src string, rules ...Rule) *Matcher

OnFullMatch 完全匹配触发器

func OnFullMatchGroup

func OnFullMatchGroup(src []string, rules ...Rule) *Matcher

OnFullMatchGroup 完全匹配触发器组

func OnKeyword

func OnKeyword(keyword string, rules ...Rule) *Matcher

OnKeyword 关键词触发器

func OnKeywordGroup

func OnKeywordGroup(keywords []string, rules ...Rule) *Matcher

OnKeywordGroup 关键词触发器组

func OnMessage

func OnMessage(rules ...Rule) *Matcher

OnMessage 消息触发器

func OnMetaEvent

func OnMetaEvent(rules ...Rule) *Matcher

OnMetaEvent 元事件触发器

func OnNotice

func OnNotice(rules ...Rule) *Matcher

OnNotice 系统提示触发器

func OnPrefix

func OnPrefix(prefix string, rules ...Rule) *Matcher

OnPrefix 前缀触发器

func OnPrefixGroup

func OnPrefixGroup(prefix []string, rules ...Rule) *Matcher

OnPrefixGroup 前缀触发器组

func OnRegex

func OnRegex(regexPattern string, rules ...Rule) *Matcher

OnRegex 正则触发器

func OnRequest

func OnRequest(rules ...Rule) *Matcher

OnRequest 请求消息触发器

func OnSuffix

func OnSuffix(suffix string, rules ...Rule) *Matcher

OnSuffix 后缀触发器

func OnSuffixGroup

func OnSuffixGroup(suffix []string, rules ...Rule) *Matcher

OnSuffixGroup 后缀触发器组

func StoreMatcher

func StoreMatcher(m *Matcher) *Matcher

StoreMatcher store a matcher to matcher list.

func StoreTempMatcher

func StoreTempMatcher(m *Matcher) *Matcher

StoreTempMatcher store a matcher only triggered once.

func (*Matcher) BindEngine added in v1.2.0

func (m *Matcher) BindEngine(e *Engine) *Matcher

BindEngine bind the matcher to a engine

func (*Matcher) Delete

func (m *Matcher) Delete()

Delete remove the matcher from list

func (*Matcher) FirstPriority added in v1.1.0

func (m *Matcher) FirstPriority() *Matcher

FirstPriority 设置当前 Matcher 优先级 - 0

func (*Matcher) FutureEvent

func (m *Matcher) FutureEvent(Type string, rule ...Rule) *FutureEvent

FutureEvent 返回一个 FutureEvent 实例指针,用于获取满足 Rule 的 未来事件

func (*Matcher) Handle

func (m *Matcher) Handle(handler Handler) *Matcher

Handle 直接处理事件

func (*Matcher) SecondPriority added in v1.1.0

func (m *Matcher) SecondPriority() *Matcher

SecondPriority 设置当前 Matcher 优先级 - 1

func (*Matcher) SetBlock

func (m *Matcher) SetBlock(block bool) *Matcher

SetBlock 设置是否阻断后面的 Matcher 触发

func (*Matcher) SetPriority

func (m *Matcher) SetPriority(priority int) *Matcher

SetPriority 设置当前 Matcher 优先级

func (*Matcher) ThirdPriority added in v1.1.0

func (m *Matcher) ThirdPriority() *Matcher

ThirdPriority 设置当前 Matcher 优先级 - 2

type Message

type Message struct {
	Elements    message.Message
	MessageId   int64
	Sender      *User
	MessageType string
}

Message 消息

type Params

type Params map[string]interface{}

Params is the params of call api

type Rule

type Rule func(ctx *Ctx) bool

Rule filter the event

func CheckUser

func CheckUser(userId ...int64) Rule

CheckUser only triggered by specific person

func CommandRule

func CommandRule(commands ...string) Rule

CommandRule check if the message is a command and trim the command name

func FullMatchRule

func FullMatchRule(src ...string) Rule

FullMatchRule check if src has the same copy of the message

func KeywordRule

func KeywordRule(src ...string) Rule

KeywordRule check if the message has a keyword or keywords

func PrefixRule

func PrefixRule(prefixes ...string) Rule

PrefixRule check if the message has the prefix and trim the prefix

检查消息前缀

func RegexRule

func RegexRule(regexPattern string) Rule

RegexRule check if the message can be matched by the regex pattern

func ReplyRule

func ReplyRule(messageID int64) Rule

ReplyRule check if the message is replying some message

func SuffixRule

func SuffixRule(suffixes ...string) Rule

SuffixRule check if the message has the suffix and trim the suffix

检查消息后缀

func Type

func Type(type_ string) Rule

Type check the ctx.Event's type

type State

type State map[string]interface{}

State store the context of a matcher.

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.

func (*User) Name

func (u *User) Name() string

Name displays a simple text version of a user.

func (*User) String

func (u *User) String() string

String displays a simple text version of a user. It is normally a user's card, but falls back to a nickname as available.

Directories

Path Synopsis
Package driver provides the default driver of zerobot
Package driver provides the default driver of zerobot
manager
Package manager provides a simple group plugin Manager.
Package manager provides a simple group plugin Manager.
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
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
ttl
Package ttl provides a synchronised map that auto-expire This package is simply to provide a storage for session.
Package ttl provides a synchronised map that auto-expire This package is simply to provide a storage for session.
utils

Jump to

Keyboard shortcuts

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