Documentation
¶
Index ¶
- Constants
- Variables
- type Action
- type Adapter
- type Command
- type CommandEventData
- type Driver
- type Error
- type Event
- type EventType
- type Message
- type MessageEventData
- type MessageSegment
- func Audio(fileId string) MessageSegment
- func File(fileId string) MessageSegment
- func Image(fileId string) MessageSegment
- func Location(latitude, longitude float64, title string, content string) MessageSegment
- func Mention(userId string) MessageSegment
- func MentionAll() MessageSegment
- func Reply(userId, messageId string) MessageSegment
- func Text(text ...interface{}) MessageSegment
- func Url(url string) MessageSegment
- func Video(fileId string) MessageSegment
- func Voice(fileId string) MessageSegment
- type Request
- type Response
- type ResponseStatus
- type Self
- type User
Constants ¶
const ( GetLatestEventsAction = "get_latest_events" GetSupportedActionsAction = "get_supported_actions" GetStatusAction = "get_status" GetVersionAction = "get_version" SendMessageAction = "send_message" GetUserInfoAction = "get_user_info" CreateChannelAction = "create_channel" GetChannelInfoAction = "get_channel_info" GetChannelListAction = "get_channel_list" )
const ( MetaConnectEvent = "meta.connect" MetaHeartbeatEvent = "meta.heartbeat" MetaStatusUpdateEvent = "meta.status_update" MessageDirectEvent = "message.direct" MessageGroupEvent = "message.group" MessageChannelEvent = "message.channel" MessageCommandEvent = "message.command" NoticeFriendIncreaseEvent = "notice.friend_increase" NoticeFriendDecreaseEvent = "notice.friend_decrease" NoticeGroupMemberIncreaseEvent = "notice.group_member_increase" NoticeGroupMemberDecreaseEvent = "notice.group_member_decrease" NoticeChannelCreateEvent = "notice.channel_create" NoticeChannelDeleteEvent = "notice.channel_delete" )
Variables ¶
var ErrBadHandler = NewError(20001, "bad handler")
ErrBadHandler Response status not set correctly, etc.
var ErrBadParam = NewError(10003, "bad parameter")
ErrBadParam Missing parameter or wrong parameter type
var ErrBadRequest = NewError(10001, "bad request")
ErrBadRequest Formatting errors (including implementations that do not support MessagePack), missing required fields, or incorrect field types
var ErrBadSegmentData = NewError(10007, "bad segment data")
ErrBadSegmentData The Chatbot implementation does not implement the semantics of this parameter
var ErrBadSegmentType = NewError(10006, "bad segment type")
ErrBadSegmentType Missing parameter or wrong parameter type
var ErrDatabaseError = NewError(31001, "database error")
ErrDatabaseError Such as database query failure
var ErrDatabaseReadError = NewError(31002, "database read error")
ErrDatabaseReadError Such as database read failure
var ErrDatabaseWriteError = NewError(31003, "database write error")
ErrDatabaseWriteError Such as database write failure
var ErrEmitEventError = NewError(37001, "emit event error")
ErrEmitEventError Emit event error
var ErrFilesystemError = NewError(32001, "filesystem error")
ErrFilesystemError If reading or writing a file fails, etc.
var ErrFlagError = NewError(60003, "flag error")
ErrFlagError Flag error
var ErrFlagExpired = NewError(60003, "flag expired")
ErrFlagExpired Flag expired
var ErrIAmTired = NewError(36001, "i am tired")
ErrIAmTired A Chatbot realizes the decision to strike.
var ErrInternalHandler = NewError(20002, "internal handler")
ErrInternalHandler An uncaught and unexpected exception has occurred within the Chatbot implementation.
var ErrInternalServerError = NewError(10000, "internal server error")
ErrInternalServerError Internal server error
var ErrLoginError = NewError(35001, "login error")
ErrLoginError Such as trying to send a message to a non-existent user
var ErrMethodNotAllowed = NewError(10008, "invalid http method")
ErrMethodNotAllowed Invalid HTTP method
var ErrNetworkError = NewError(33001, "network error")
ErrNetworkError e.g. failed to download a file, etc.
var ErrNotAuthorized = NewError(60004, "not authorized")
ErrNotAuthorized Not authorized
var ErrNotFound = NewError(10009, "not found")
ErrNotFound not found
var ErrOAuthError = NewError(60004, "oauth error")
ErrOAuthError OAuth error
var ErrParamVerificationFailed = NewError(10031, "parameter verification failed")
ErrParamVerificationFailed Missing parameter or wrong parameter type
var ErrPlatformError = NewError(34001, "platform error")
ErrPlatformError e.g. failure to send messages due to bot platform limitations, etc.
var ErrSendMessageFailed = NewError(60002, "send message failed")
ErrSendMessageFailed Failed to send a message
var ErrShutdownError = NewError(38001, "shutdown error")
ErrShutdownError Shutdown error
var ErrTokenError = NewError(60001, "missing, invalid or expired access token")
ErrTokenError missing, invalid or expired access token
var ErrUnknownSelf = NewError(10102, "unknown self")
ErrUnknownSelf The bot account specified by the action request does not exist
var ErrUnsupported = NewError(10004, "unsupported")
ErrUnsupported The Chatbot implementation does not implement the semantics of this parameter
var ErrUnsupportedAction = NewError(10002, "unsupported action")
ErrUnsupportedAction The Chatbot implementation does not implement this action
var ErrUnsupportedSegment = NewError(10005, "unsupported segment")
ErrUnsupportedSegment The Chatbot implementation does not implement this segment type.
var ErrWhoAmI = NewError(10101, "who am i")
ErrWhoAmI Chatbot implements support for multiple bot accounts on a single Chatbot Connect connection, but the action request does not specify the account to be used
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action interface {
// GetLatestEvents get latest events, Only the HTTP communication method must be supported for polling for events.
GetLatestEvents(req Request) Response
// GetSupportedActions get supported actions
GetSupportedActions(req Request) Response
// GetStatus get status
GetStatus(req Request) Response
// GetVersion get version
GetVersion(req Request) Response
// SendMessage send message
SendMessage(req Request) Response
// GetUserInfo get user info
GetUserInfo(req Request) Response
// CreateChannel create channel
CreateChannel(req Request) Response
// GetChannelInfo get channel info
GetChannelInfo(req Request) Response
// GetChannelList get channel list
GetChannelList(req Request) Response
// RegisterChannels register channels
RegisterChannels(req Request) Response
// RegisterSlashCommands register slash commands
RegisterSlashCommands(req Request) Response
}
Action An interface for the application to actively obtain information about the Chatbot implementation or robot platform and to control the behavior of the Chatbot implementation or robot.
type Adapter ¶
Adapter Responsible for converting platform messages to chatbot event/message formats.
type Command ¶
type Command struct {
Token string `json:"token"`
TeamID string `json:"team_id"`
TeamDomain string `json:"team_domain"`
EnterpriseID string `json:"enterprise_id,omitempty"`
EnterpriseName string `json:"enterprise_name,omitempty"`
ChannelID string `json:"channel_id"`
ChannelName string `json:"channel_name"`
UserID string `json:"user_id"`
UserName string `json:"user_name"`
Command string `json:"command"`
Text string `json:"text"`
ResponseURL string `json:"response_url"`
TriggerID string `json:"trigger_id"`
APIAppID string `json:"api_app_id"`
Prefix string `json:"prefix"`
}
type CommandEventData ¶
type CommandEventData struct {
Command string `json:"command,omitempty"`
}
type Driver ¶
type Driver interface {
// HttpServer The application can actively access the Chatbot implementation.
HttpServer(ctx *fiber.Ctx) error
// HttpWebhookClient Chatbot implements active access to applications
HttpWebhookClient(message Message) error
// WebSocketClient The application can actively access the Chatbot implementation.
WebSocketClient(stop <-chan bool)
// WebSocketServer Chatbot implements active access to applications
WebSocketServer(stop <-chan bool)
}
Driver Functional implementation of the client/server responsible for receiving and sending messages (usually HTTP communication)
type Error ¶
func (Error) GetMessage ¶
type Message ¶
type Message []MessageSegment
type MessageEventData ¶
type MessageEventData struct {
Self Self `json:"self,omitempty"`
MessageId string `json:"message_id,omitempty"`
Message []MessageSegment `json:"message,omitempty"`
AltMessage string `json:"alt_message,omitempty"`
UserId string `json:"user_id,omitempty"`
TopicId string `json:"topic_id,omitempty"`
TopicType string `json:"topic_type,omitempty"`
Forwarded string `json:"forwarded,omitempty"`
Seq float64 `json:"seq,omitempty"`
Option string `json:"option,omitempty"`
}
type MessageSegment ¶
func Audio ¶
func Audio(fileId string) MessageSegment
func File ¶
func File(fileId string) MessageSegment
func Image ¶
func Image(fileId string) MessageSegment
func Location ¶
func Location(latitude, longitude float64, title string, content string) MessageSegment
func Mention ¶
func Mention(userId string) MessageSegment
func MentionAll ¶
func MentionAll() MessageSegment
func Reply ¶
func Reply(userId, messageId string) MessageSegment
func Text ¶
func Text(text ...interface{}) MessageSegment
func Url ¶
func Url(url string) MessageSegment
func Video ¶
func Video(fileId string) MessageSegment
func Voice ¶
func Voice(fileId string) MessageSegment
func (MessageSegment) String ¶
func (s MessageSegment) String() string
String impls the interface Stringer
type Response ¶
type Response struct {
// Execution status (success or failure), must be one of ok and failed,
// indicating successful and unsuccessful execution, respectively.
Status ResponseStatus `json:"status"`
// The return code, which must conform to the return code rules defined later on this page
RetCode int64 `json:"retcode,omitempty"`
// Response data
Data any `json:"data,omitempty"`
// Error message, it is recommended to fill in a human-readable error message when the action fails to execute,
// or an empty string when it succeeds.
Message string `json:"message,omitempty"`
}
func NewFailedResponse ¶
func NewSuccessResponse ¶
type ResponseStatus ¶
type ResponseStatus string
const ( Success ResponseStatus = "ok" Failed ResponseStatus = "failed" SuccessCode = int64(0) )
type User ¶
type User struct {
RawData types.KV `json:"raw_data"`
Email string `json:"email"`
Name string `json:"name"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
NickName string `json:"nick_name"`
Description string `json:"description"`
UserID string `json:"user_id"`
AvatarURL string `json:"avatar_url"`
Location string `json:"location"`
Platform string `json:"platform"`
IsBot bool `json:"is_bot"`
}