Documentation ¶
Index ¶
- Constants
- Variables
- func RequestSessionTicket(to string) (string, error)
- type AuthResponse
- type BotX
- func (b *BotX) AddCommand(command *Command) error
- func (b *BotX) HandleChatMessage(h func(m *messages.GlideMessage, cm *messages.ChatMessage))
- func (b *BotX) Reply(originMessage *ResolvedChatMessage, messageType int32, content interface{}) error
- func (b *BotX) RunAndLogin(email, password string, h func(m *messages.GlideMessage)) error
- func (b *BotX) Send(to string, action messages.Action, data interface{}) error
- type Command
- type CommandHandler
- type Credential
- type Data
- type MessageHandler
- type MessageInterceptor
- type Options
- type Perm
- type ProxyRobot
- type ResolvedChatMessage
- type Response
- type Robot
- type RobotConnection
- type RobotOptions
- type Role
- type RoleControllerInterface
- type TicketResponse
- type UserId
Constants ¶
View Source
const ( ActionHello messages.Action = "hello" ActionHeartbeat messages.Action = "heartbeat" ActionNotifyUnknownAction messages.Action = "notify.unknown.action" ActionChatMessage messages.Action = "message.chat" ActionChatMessageResend messages.Action = "message.chat.resend" ActionGroupMessage messages.Action = "message.group" ActionMessageFailed messages.Action = "message.failed.send" ActionNotifyNeedAuth messages.Action = "notify.auth" ActionNotifyKickOut messages.Action = "notify.kickout" ActionNotifyNewContact messages.Action = "notify.contact" ActionNotifyGroup messages.Action = "notify.group" ActionNotifyAccountLogin messages.Action = "notify.login" ActionNotifyAccountLogout messages.Action = "notify.logout" ActionNotifyError messages.Action = "notify.error" ActionAckRequest messages.Action = "ack.request" ActionAckGroupMsg messages.Action = "ack.group.msg" ActionAckMessage messages.Action = "ack.message" ActionAckNotify messages.Action = "ack.notify" ActionApiAuth messages.Action = "api.auth" ActionApiFailed messages.Action = "api.failed" ActionApiSuccess messages.Action = "api.success" ActionClientCustom messages.Action = "message.cli" NotifyKickOut messages.Action = "notify.kickout" AckOffline messages.Action = "ack.offline" )
View Source
const ( CommandPrefix = "#" CommandMaxLength = 10 )
Variables ¶
View Source
var ApiBaseUrl string
View Source
var RoleController = &roleController{ defaultRole: 1, userRole: map[UserId]Role{}, }
Functions ¶
func RequestSessionTicket ¶ added in v1.2.2
Types ¶
type AuthResponse ¶ added in v1.2.1
type AuthResponse struct { Token string `json:"token"` Servers []string `json:"servers"` NickName string `json:"nick_name"` Uid int64 `json:"uid"` Status int `json:"status"` Credential *Credential `json:"credential"` }
func Login ¶ added in v1.2.1
func Login(account, password string) (*AuthResponse, error)
type BotX ¶
func (*BotX) AddCommand ¶ added in v1.1.0
func (*BotX) HandleChatMessage ¶
func (b *BotX) HandleChatMessage(h func(m *messages.GlideMessage, cm *messages.ChatMessage))
func (*BotX) Reply ¶ added in v1.2.0
func (b *BotX) Reply(originMessage *ResolvedChatMessage, messageType int32, content interface{}) error
func (*BotX) RunAndLogin ¶ added in v1.2.1
func (b *BotX) RunAndLogin(email, password string, h func(m *messages.GlideMessage)) error
type Command ¶ added in v1.1.0
type Command struct { Role Role Name string Desc string Handle CommandHandler // contains filtered or unexported fields }
func CommandHelp ¶ added in v1.2.0
func CommandPing ¶ added in v1.2.0
func NewCommand ¶ added in v1.1.0
func NewCommand(role Role, name string, handle CommandHandler) (*Command, error)
func NewCommand2 ¶ added in v1.2.0
type CommandHandler ¶ added in v1.1.0
type CommandHandler func(message *ResolvedChatMessage, value string) error
type Credential ¶ added in v1.2.1
type Data ¶ added in v1.2.1
type Data struct {
// contains filtered or unexported fields
}
func (*Data) UnmarshalJSON ¶ added in v1.2.1
type MessageHandler ¶
type MessageHandler func(g gate.Gateway, m *messages.GlideMessage)
MessageHandler used to handle the message that robot received.
type MessageInterceptor ¶
type MessageInterceptor interface {
// contains filtered or unexported methods
}
type ProxyRobot ¶
type ProxyRobot struct { }
func (*ProxyRobot) EnqueueMessage ¶
func (p *ProxyRobot) EnqueueMessage(message *messages.GlideMessage) error
func (*ProxyRobot) Exit ¶
func (p *ProxyRobot) Exit()
func (*ProxyRobot) GetInfo ¶
func (p *ProxyRobot) GetInfo() gate.Info
func (*ProxyRobot) IsRunning ¶
func (p *ProxyRobot) IsRunning() bool
func (*ProxyRobot) Run ¶
func (p *ProxyRobot) Run()
func (*ProxyRobot) SetID ¶
func (p *ProxyRobot) SetID(id gate.ID)
type ResolvedChatMessage ¶ added in v1.2.0
type ResolvedChatMessage struct { Origin *messages.GlideMessage ChatMessage *messages.ChatMessage }
type Robot ¶
type Robot struct { Rec chan *messages.GlideMessage // contains filtered or unexported fields }
type RobotConnection ¶
type RobotConnection struct {
// contains filtered or unexported fields
}
RobotConnection .
func NewRobotConnection ¶
func NewRobotConnection(g gate.Gateway, handler MessageHandler, opts *Options) (*RobotConnection, error)
func (*RobotConnection) EnqueueMessage ¶
func (r *RobotConnection) EnqueueMessage(m *messages.GlideMessage) error
func (*RobotConnection) Exit ¶
func (r *RobotConnection) Exit()
func (*RobotConnection) GetInfo ¶
func (r *RobotConnection) GetInfo() gate.Info
func (*RobotConnection) IsRunning ¶
func (r *RobotConnection) IsRunning() bool
func (*RobotConnection) Run ¶
func (r *RobotConnection) Run()
func (*RobotConnection) SetID ¶
func (r *RobotConnection) SetID(id gate.ID)
type RobotOptions ¶
type RobotOptions struct { }
type Role ¶ added in v1.2.0
type Role int64
func GetUserRoleFromMessage ¶ added in v1.2.0
func GetUserRoleFromMessage(message *messages.ChatMessage) Role
type RoleControllerInterface ¶ added in v1.2.0
type TicketResponse ¶ added in v1.2.2
type TicketResponse struct {
Ticket string `json:"ticket"`
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.