Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BotCommand ¶
type BotCommand interface {
Usage() string
Definition() *CommandDefinition
Match(text string) (*proper.Properties, bool)
Execute(request Request, response ResponseWriter)
}
BotCommand interface
func NewBotCommand ¶
func NewBotCommand(usage string, definition *CommandDefinition) BotCommand
NewBotCommand creates a new bot command object
type ClientOption ¶
type ClientOption func(*Keybaser)
ClientOption is option client initialize
func SetMiddlewareFunc ¶
func SetMiddlewareFunc(middlewareFunc func(next HandlerFunc) HandlerFunc) ClientOption
SetMiddlewareFunc is option for set custom middleware
func SetResponseConstructor ¶
func SetResponseConstructor(constructor ResponseConstructor) ClientOption
SetResponseConstructor is option for set custom response constructor
func SetSubscriber ¶
func SetSubscriber(subscriber Subscriber) ClientOption
SetSubscriber is option for set custom subscriber
func WithLogger ¶
func WithLogger(logger logrus.FieldLogger) ClientOption
WithLogger is option for set custom logger
type CommandDefinition ¶
type CommandDefinition struct {
Description string
Example string
AuthorizationFunc func(request Request) bool
Handler func(request Request, response ResponseWriter)
}
CommandDefinition structure contains definition of the bot command
type HandlerFunc ¶
type HandlerFunc func(ctx context.Context, message *kbchat.SubscriptionMessage)
HandlerFunc .
type KeybaseChatAPIClient ¶
type KeybaseChatAPIClient interface {
ListenForNewTextMessages() (kbchat.NewSubscription, error)
SendMessage(channel chat1.ChatChannel, body string, args ...interface{}) (kbchat.SendResponse, error)
GetUsername() string
}
KeybaseChatAPIClient .
type Keybaser ¶
type Keybaser struct {
// contains filtered or unexported fields
}
Keybaser contains the Keybase API
func New ¶
func New(kc KeybaseChatAPIClient, opts ...ClientOption) (*Keybaser, error)
New creates a new client using the Keybase API
func (*Keybaser) Client ¶
func (k *Keybaser) Client() KeybaseChatAPIClient
Client returns the internal keybase chat API
func (*Keybaser) Command ¶
func (k *Keybaser) Command(usage string, definition *CommandDefinition)
Command define a new command and append it to the list of existing commands
type NewSubscription ¶
type NewSubscription interface {
Read() (kbchat.SubscriptionMessage, error)
}
NewSubscription .
type Request ¶
type Request interface {
Param(key string) string
StringParam(key string, defaultValue string) string
BooleanParam(key string, defaultValue bool) bool
IntegerParam(key string, defaultValue int) int
FloatParam(key string, defaultValue float64) float64
Context() context.Context
Message() *kbchat.SubscriptionMessage
Properties() *proper.Properties
}
Request interface that contains the Event received and parameters
func NewRequest ¶
func NewRequest(ctx context.Context, message *kbchat.SubscriptionMessage, properties *proper.Properties) Request
NewRequest creates a new Request structure
type ResponseConstructor ¶
type ResponseConstructor func(channel chat1.ChatChannel, client KeybaseChatAPIClient) ResponseWriter
ResponseConstructor .
type ResponseWriter ¶
type ResponseWriter interface {
Reply(text string)
ReportError(err error)
Client() KeybaseChatAPIClient
}
A ResponseWriter interface is used to respond to an event
func NewResponse ¶
func NewResponse(channel chat1.ChatChannel, client KeybaseChatAPIClient) ResponseWriter
NewResponse creates a new response structure