Documentation
¶
Index ¶
- Constants
- func DefaultLogger(level logrus.Level) *logrus.Logger
- 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, msg interface{}, autoEscape bool) (APIResp, error)
- func (bot *Bot) SendPrivateMsg(userId int64, msg interface{}, autoEscape bool) (APIResp, error)
- func (bot *Bot) Start()
- type BotConfig
- type Event
- type EventHandler
- type EventHandlerFunc
- type EventValidator
- type HandlerMap
- type MessageSegment
- type Sender
- type ServerConfig
Constants ¶
const ( PostTypeMessage = "message" PostTypeNotice = "notice" PostTypeRequest = "request" PostTypeMeta = "meta_event" MessageTypePrivate = "private" MessageTypeGroup = "group" )
Variables ¶
This section is empty.
Functions ¶
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 ¶
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
type BotConfig ¶
type BotConfig struct {
SelfId int64
ApiConfig ApiConfig
ServerConfig ServerConfig
}
type Event ¶
type Event struct {
Time int64 `json:"time" validate:"required"`
SelfId int64 `json:"self_id" validate:"required"`
PostType string `json:"post_type" validate:"oneof=message notice request meta_event"`
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 EventValidator ¶
type EventValidator struct {
// contains filtered or unexported fields
}
func DefaultEventValidator ¶
func DefaultEventValidator() *EventValidator
func (*EventValidator) Validate ¶
func (ev *EventValidator) Validate(i interface{}) error
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
func At ¶
func At(qq string) MessageSegment
At https://github.com/botuniverse/onebot/blob/master/v11/specs/message/segment.md#%E6%9F%90%E4%BA%BA
func Face ¶
func Face(id string) MessageSegment
Face https://github.com/botuniverse/onebot/blob/master/v11/specs/message/segment.md#qq-%E8%A1%A8%E6%83%85
func Image ¶
func Image(file string) MessageSegment
Image https://github.com/botuniverse/onebot/blob/master/v11/specs/message/segment.md#%E5%9B%BE%E7%89%87
func Record ¶
func Record(file string) MessageSegment
Record https://github.com/botuniverse/onebot/blob/master/v11/specs/message/segment.md#%E8%AF%AD%E9%9F%B3
func Reply ¶
func Reply(id string) MessageSegment
Reply https://github.com/botuniverse/onebot/blob/master/v11/specs/message/segment.md#%E5%9B%9E%E5%A4%8D
func Text ¶
func Text(text string) MessageSegment