bot

package
v0.0.0-...-3c8687b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OptionInDialog common.Flag = 1 << iota
	OptionInChat
)

Command options.

View Source
const Prefixes = "/!"

Prefixes are the characters with which commands must begin.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

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

Bot is vk bot.

func New

func New(vk *vkapi.Client, l *logger.Logger) *Bot

New creates new bot.

func (*Bot) ModList

func (b *Bot) ModList() []*Module

ModList returns loaded modules list.

func (*Bot) Run

func (b *Bot) Run(ctx context.Context, mods ...*Module) (err error)

Run starts bot.

type Callback

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

Callback type.

func (*Callback) API

func (c *Callback) API() *vkapi.Client

API returns vk client.

func (*Callback) Close

func (c *Callback) Close()

Close replies without action to a callback event and closes context.

func (*Callback) Conversation

func (c *Callback) Conversation() *conversation.Conversation

Conversation returns chat object for current chat.

func (*Callback) Edit

func (c *Callback) Edit(msg conversation.Message)

Edit edits a message with keyboard and closes context.

func (*Callback) Log

func (c *Callback) Log() *logger.Logger

Log returns logger for module.

func (*Callback) MessageID

func (c *Callback) MessageID() int

MessageID returns message id.

func (c *Callback) OpenLink(link string)

OpenLink replies to a callback event and closes context.

func (*Callback) Payload

func (c *Callback) Payload(i interface{}) vkapi.JSONData

Payload wraps payload.

func (*Callback) ShowSnackbar

func (c *Callback) ShowSnackbar(text string)

ShowSnackbar replies to a callback event and closes context.

func (*Callback) UserID

func (c *Callback) UserID() vkapi.UserID

UserID returns user id.

type Command

type Command struct {
	Run         func(*Context, *Message)
	Cmd         []string
	Description string
	Help        string
	Options     common.Flag
}

Command respresents conversation command.

type Context

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

Context type.

func (*Context) API

func (c *Context) API() *vkapi.Client

API returns vk client.

func (*Context) Close

func (c *Context) Close()

Close closes current context.

func (*Context) Conversation

func (c *Context) Conversation() *conversation.Conversation

Conversation returns chat object for current chat.

func (*Context) Log

func (c *Context) Log() *logger.Logger

Log returns logger for module.

func (*Context) Payload

func (c *Context) Payload(i interface{}) vkapi.JSONData

Payload wraps payload.

func (*Context) Reply

func (c *Context) Reply(msg conversation.Message)

Reply replies with a message and closes context.

func (*Context) ReplyText

func (c *Context) ReplyText(text string)

ReplyText replies to a message with a text and closes context.

type Message

type Message struct {
	vkapi.Message
	Args []string
}

Message type.

type Module

type Module struct {
	Name      string
	Init      func() error
	Terminate func()
	Callback  func(ctx *Callback, payload vkapi.JSONData)
	Commands  []*Command
	// contains filtered or unexported fields
}

Module struct.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL