Documentation
¶
Index ¶
- Constants
- func DefaultLogger(level logrus.Level) *logrus.Logger
- func MessageBuilder() *messageBuilder
- type APIResp
- type Anonymous
- type ApiConfig
- type Bot
- func (bot *Bot) On(postType string, handler EventHandler)
- func (bot *Bot) OnGroupMessage(prefix string, fn EventHandlerFunc)
- func (bot *Bot) OnMessage(prefix string, fn EventHandlerFunc)
- func (bot *Bot) OnMeta(fn EventHandlerFunc)
- func (bot *Bot) OnNotice(fn EventHandlerFunc)
- func (bot *Bot) OnPrivateMessage(prefix string, fn EventHandlerFunc)
- func (bot *Bot) OnRequest(fn EventHandlerFunc)
- func (bot *Bot) Request(action string, requestBody interface{}) (APIResp, error)
- func (bot *Bot) SendGroupMsg(groupId int64, message ...MessageSegment) (APIResp, error)
- func (bot *Bot) SendPrivateMsg(userId int64, message ...MessageSegment) (APIResp, error)
- func (bot *Bot) Start()
- type BotConfig
- type Context
- type Event
- type EventHandler
- type EventHandlerFunc
- type HandlerMap
- type MessageSegment
- type Sender
- type ServerConfig
Constants ¶
View Source
const ( PostTypeMessage = "message" PostTypeNotice = "notice" PostTypeRequest = "request" PostTypeMeta = "meta_event" MessageTypePrivate = "private" MessageTypeGroup = "group" )
Variables ¶
This section is empty.
Functions ¶
func MessageBuilder ¶ added in v0.2.0
func MessageBuilder() *messageBuilder
Types ¶
type APIResp ¶
type APIResp struct {
Status string `json:"status"`
Retcode int `json:"retcode"`
Data interface{} `json:"data"`
}
APIResp API响应 https://github.com/botuniverse/onebot-11/blob/master/communication/http.md#%E5%93%8D%E5%BA%94
type Bot ¶
type Bot struct {
BotConfig *BotConfig
Logger *logrus.Logger
// contains filtered or unexported fields
}
func (*Bot) On ¶
func (bot *Bot) On(postType string, handler EventHandler)
func (*Bot) OnGroupMessage ¶
func (bot *Bot) OnGroupMessage(prefix string, fn EventHandlerFunc)
func (*Bot) OnMessage ¶
func (bot *Bot) OnMessage(prefix string, fn EventHandlerFunc)
func (*Bot) OnMeta ¶
func (bot *Bot) OnMeta(fn EventHandlerFunc)
func (*Bot) OnNotice ¶
func (bot *Bot) OnNotice(fn EventHandlerFunc)
func (*Bot) OnPrivateMessage ¶
func (bot *Bot) OnPrivateMessage(prefix string, fn EventHandlerFunc)
func (*Bot) OnRequest ¶
func (bot *Bot) OnRequest(fn EventHandlerFunc)
func (*Bot) SendGroupMsg ¶
func (bot *Bot) SendGroupMsg(groupId int64, message ...MessageSegment) (APIResp, error)
SendGroupMsg 发送群消息 https://github.com/botuniverse/onebot-11/blob/master/api/public.md#send_group_msg-%E5%8F%91%E9%80%81%E7%BE%A4%E6%B6%88%E6%81%AF
func (*Bot) SendPrivateMsg ¶
func (bot *Bot) SendPrivateMsg(userId int64, message ...MessageSegment) (APIResp, error)
SendPrivateMsg 发送私聊消息 https://github.com/botuniverse/onebot-11/blob/master/api/public.md#send_private_msg-%E5%8F%91%E9%80%81%E7%A7%81%E8%81%8A%E6%B6%88%E6%81%AF
type BotConfig ¶
type BotConfig struct {
SelfId int64
ApiConfig ApiConfig
ServerConfig ServerConfig
}
type Context ¶ added in v0.2.1
func (*Context) SendMessage ¶ added in v0.2.1
func (ctx *Context) SendMessage(message ...MessageSegment) (APIResp, error)
type Event ¶
type Event struct {
Time int64 `json:"time"`
SelfId int64 `json:"self_id"`
PostType string `json:"post_type"`
SubType string `json:"sub_type"`
// message
MessageType string `json:"message_type"`
MessageId int32 `json:"message_id,"`
UserId int64 `json:"user_id"`
Message []MessageSegment `json:"message"`
RawMessage string `json:"raw_message"`
Font int32 `json:"font"`
Sender Sender `json:"sender"`
// group
GroupId int64 `json:"group_id"`
Anonymous Anonymous `json:"anonymous"`
}
Event 事件 https://github.com/botuniverse/onebot-11/tree/master/event
type EventHandler ¶
type EventHandler struct {
MessagePrefix string
MessageType string
Handle EventHandlerFunc
}
type EventHandlerFunc ¶
type EventHandlerFunc func(*Context)
type HandlerMap ¶
func (*HandlerMap) GetHandlers ¶
func (hm *HandlerMap) GetHandlers(postType string) []EventHandler
type MessageSegment ¶
MessageSegment 消息段 https://github.com/botuniverse/onebot-11/blob/master/message/array.md
type ServerConfig ¶
Click to show internal directories.
Click to hide internal directories.