Documentation ¶
Overview ¶
Package vk implements a VK adapter for the joe bot library.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrGetBotInfo = errors.New("failed to get bot info")
Functions ¶
Types ¶
type BotAdapter ¶
type BotAdapter struct {
// contains filtered or unexported fields
}
BotAdapter implements a joe.Adapter that reads and writes messages to and from VK.
func NewAdapter ¶
func NewAdapter(ctx context.Context, conf Config) (*BotAdapter, error)
NewAdapter creates a new *BotAdapter that connects to VK. Note that you will usually configure the VK adapter as joe.Module (i.e. using the Adapter function of this package).
func (*BotAdapter) Close ¶
func (b *BotAdapter) Close() error
Close disconnects the adapter from the vk API.
func (*BotAdapter) RegisterAt ¶
func (b *BotAdapter) RegisterAt(brain *joe.Brain)
RegisterAt implements the joe.Adapter interface by emitting the vk API events to the given brain.
func (*BotAdapter) Send ¶
func (b *BotAdapter) Send(text, chat string) error
Send implements joe.Adapter by sending all received text messages to the given chat.
type ChatCreateEvent ¶
type ChatCreateEvent struct { Channel string // The id of created channel. Text string // Chat title // original response (objects.MessageNewObject) Data interface{} }
ChatCreateEvent struct
type ChatPhotoUpdateEvent ¶
type ChatPhotoUpdateEvent struct { Channel string // The id of created channel. NewPhoto object.MessagesMessageActionPhoto // The object with new cover photo urls Removed bool // true if cover photo has changed, otherwise false // original response (objects.MessageNewObject) Data interface{} }
ChatPhotoUpdateEvent struct
type ChatPinUpdateEvent ¶
type ChatPinUpdateEvent struct { Channel string // The id of created channel. UserID string // A string identifying the user who changed pin MessageID string // A string identifying the changed pin message Unpinned bool // true if message has unpinned, otherwise false // original response (objects.MessageNewObject) Data interface{} }
ChatPinUpdateEvent struct
type ChatTitleUpdateEvent ¶
type ChatTitleUpdateEvent struct { Channel string // The id of created channel. NewText string // New chat title // original response (objects.MessageNewObject) Data interface{} }
ChatTitleUpdateEvent struct
type Option ¶
An Option is used to configure the vk adapter.
func WithLogger ¶
WithLogger can be used to inject a different logger for the vk adapater.
type UserEnteredChatEvent ¶
type UserEnteredChatEvent struct { Channel string // The channel over which the message was received. UserID string // A string identifying the new user in chat ByLink bool // original response (objects.MessageNewObject) Data interface{} }
UserEnteredChatEvent struct
type UserLeavedChatEvent ¶
type UserLeavedChatEvent struct { Channel string // The channel over which the message was received. UserID string // A string identifying the leaved user in chat // original response (objects.MessageNewObject) Data interface{} }
UserLeavedChatEvent struct