joe-vk-adapter: github.com/tdakkota/joe-vk-adapter Index | Files | Directories

package vk

import "github.com/tdakkota/joe-vk-adapter"

Package vk implements a VK adapter for the joe bot library.

Index

Package Files

adapter.go events.go joe.go options.go

Variables

var ErrGetBotInfo = errors.New("failed to get bot info")

func Adapter Uses

func Adapter(token string, opts ...Option) joe.Module

Adapter returns a new vk Adapter as joe.Module.

type BotAdapter Uses

type BotAdapter struct {
    // contains filtered or unexported fields
}

BotAdapter implements a joe.Adapter that reads and writes messages to and from VK.

func NewAdapter Uses

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 Uses

func (b *BotAdapter) Close() error

Close disconnects the adapter from the vk API.

func (*BotAdapter) RegisterAt Uses

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 Uses

func (b *BotAdapter) Send(text, chat string) error

Send implements joe.Adapter by sending all received text messages to the given chat.

type ChatCreateEvent Uses

type ChatCreateEvent struct {
    Channel string // The id of created channel.
    Text    string // Chat title

    // original response (objects.MessageNewObject)
    Data interface{}
}

ChatCreateEvent struct

type ChatPhotoUpdateEvent Uses

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 Uses

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 Uses

type ChatTitleUpdateEvent struct {
    Channel string // The id of created channel.
    NewText string // New chat title

    // original response (objects.MessageNewObject)
    Data interface{}
}

ChatTitleUpdateEvent struct

type Config Uses

type Config struct {
    Token  string
    Logger *zap.Logger
}

Config contains the configuration of a BotAdapter.

type Option Uses

type Option func(*Config) error

An Option is used to configure the vk adapter.

func WithLogger Uses

func WithLogger(logger *zap.Logger) Option

WithLogger can be used to inject a different logger for the vk adapater.

type UserEnteredChatEvent Uses

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 Uses

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

Directories

PathSynopsis
example

Package vk imports 8 packages (graph) and is imported by 1 packages. Updated 2020-05-19. Refresh now. Tools for package owners.