plugin

package
v0.0.0-...-8b0fe6f Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2022 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandDescription

type CommandDescription struct {
	Cmd     string
	Help    string
	Details string
}

type Help

type Help struct {
	NopPlugin
	Bot  *tgbotapi.BotAPI
	Cmds []CommandDescription
}

Help sends usage info

func (*Help) Commands

func (plg *Help) Commands() []CommandDescription

func (*Help) HandleUpdate

func (plg *Help) HandleUpdate(ctx context.Context, upd *tgbotapi.Update) (bool, error)

type LastMessage

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

LastMessage tracks last message in chat

func (*LastMessage) Close

func (plg *LastMessage) Close() (err error)

func (*LastMessage) Commands

func (plg *LastMessage) Commands() []CommandDescription

func (*LastMessage) HandleUpdate

func (plg *LastMessage) HandleUpdate(_ context.Context, upd *tgbotapi.Update) (bool, error)

func (*LastMessage) Init

func (plg *LastMessage) Init() (err error)

func (*LastMessage) LastMessageID

func (plg *LastMessage) LastMessageID(chatID int64) int

func (*LastMessage) Select

func (plg *LastMessage) Select(chatID int64, pred func(*tgbotapi.Message) bool) *tgbotapi.Message

type Monitor

type Monitor struct {
	NopPlugin
	Bot   *tgbotapi.BotAPI
	Store storm.Node
	// contains filtered or unexported fields
}

Monitor notifies subscribers on service update

func (*Monitor) Close

func (plg *Monitor) Close() error

func (*Monitor) Commands

func (plg *Monitor) Commands() []CommandDescription

func (*Monitor) HandleUpdate

func (plg *Monitor) HandleUpdate(ctx context.Context, upd *tgbotapi.Update) (bool, error)

func (*Monitor) Init

func (plg *Monitor) Init() error

type MsgChatID

type MsgChatID struct {
	MessageID int
	ChatID    int64
}

type MsgVote

type MsgVote struct {
	ID        MsgChatID `storm:"id"`
	Timestamp int64     `storm:"index"`
	Author    int
	Users     map[int]int
}

type NopPlugin

type NopPlugin struct{}

NopPlugin does nothing

func (*NopPlugin) Close

func (sapp *NopPlugin) Close() (err error)

func (*NopPlugin) Commands

func (sapp *NopPlugin) Commands() []CommandDescription

func (*NopPlugin) HandleUpdate

func (sapp *NopPlugin) HandleUpdate(_ context.Context, _ *tgbotapi.Update) (bool, error)

func (*NopPlugin) Init

func (sapp *NopPlugin) Init() (err error)

type NotifierApp

type NotifierApp struct {
	Bot    *tgbotapi.BotAPI
	Store  *NotifierStore
	AppURL string
}

func (*NotifierApp) Close

func (sapp *NotifierApp) Close() error

func (*NotifierApp) Commands

func (sapp *NotifierApp) Commands() []CommandDescription

func (*NotifierApp) HandleUpdate

func (sapp *NotifierApp) HandleUpdate(ctx context.Context, upd *tgbotapi.Update) (bool, error)

func (*NotifierApp) Init

func (sapp *NotifierApp) Init() error

func (*NotifierApp) Routes

func (sapp *NotifierApp) Routes() http.Handler

type NotifierStore

type NotifierStore struct {
	Bkt storm.Node
}

func (*NotifierStore) FindToken

func (s *NotifierStore) FindToken(token string) int64

func (*NotifierStore) RemoveTokens

func (s *NotifierStore) RemoveTokens(chatID int64, token string) (int, error)

func (*NotifierStore) SaveToken

func (s *NotifierStore) SaveToken(chatID int64, token string) error

type PlugIn

type PlugIn interface {
	Init() error
	Commands() []CommandDescription
	HandleUpdate(ctx context.Context, upd *tgbotapi.Update) (caught bool, err error)
	Close() error
}

PlugIn provides part of functionality for bot

type ShowVersion

type ShowVersion struct {
	NopPlugin
	Bot     *tgbotapi.BotAPI
	Version string
}

func (*ShowVersion) Commands

func (plg *ShowVersion) Commands() []CommandDescription

func (*ShowVersion) HandleUpdate

func (sapp *ShowVersion) HandleUpdate(ctx context.Context, upd *tgbotapi.Update) (caught bool, err error)

HandleUpdate processes event

type TimezoneConverter

type TimezoneConverter struct {
	NopPlugin
	Store *TimezoneConverterStore
	Bot   *tgbotapi.BotAPI
	// contains filtered or unexported fields
}

TimezoneConverter ...

func (*TimezoneConverter) Commands

func (tapp *TimezoneConverter) Commands() []CommandDescription

func (*TimezoneConverter) HandleUpdate

func (tapp *TimezoneConverter) HandleUpdate(ctx context.Context, upd *tgbotapi.Update) (caught bool, err error)

func (*TimezoneConverter) Init

func (tapp *TimezoneConverter) Init() (err error)

type TimezoneConverterStore

type TimezoneConverterStore struct {
	Bkt storm.Node
}

type VoteApp

type VoteApp struct {
	NopPlugin
	Bot   *tgbotapi.BotAPI
	Store *VoteStore
	Stat  *LastMessage
}

VoteApp sends vote form for particular messages in chats

func (*VoteApp) HandleUpdate

func (vapp *VoteApp) HandleUpdate(ctx context.Context, upd *tgbotapi.Update) (caught bool, err error)

HandleUpdate processes event

type VoteStore

type VoteStore struct {
	Bkt storm.Node
	// contains filtered or unexported fields
}

func NewVoteStore

func NewVoteStore(bkt storm.Node) *VoteStore

func (*VoteStore) AddVote

func (s *VoteStore) AddVote(ts time.Time, msg MsgChatID, userID int, increment int) (bool, *MsgVote, error)

func (*VoteStore) HasVote

func (s *VoteStore) HasVote(msg MsgChatID) (bool, error)

func (*VoteStore) NewVote

func (s *VoteStore) NewVote(ts time.Time, msg MsgChatID, userID int) (*MsgVote, error)

type WebApp

type WebApp interface {
	PlugIn
	Routes() http.Handler
}

WebApp is a PlugIn that shoould serve http

Jump to

Keyboard shortcuts

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