telegram

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChatStateInitial = iota
	ChatStateSubnetExpectCIDR
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatState

type ChatState int

func ChatStateFromJSON

func ChatStateFromJSON(data []byte) (ChatState, error)

func (ChatState) ToJSON

func (s ChatState) ToJSON() ([]byte, error)

type DB

type DB interface {
	db.DB
	Begin(mode db.TxMode) (Tx, error)
}

type Telegram

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

func NewTelegram

func NewTelegram(db DB, token string, wgManager *manager.Manager, logger *zap.Logger) *Telegram

func (*Telegram) Close

func (t *Telegram) Close()

Close stops accepting new messages and waits handlers to finish.

func (*Telegram) Init

func (t *Telegram) Init() error

func (*Telegram) Run

func (t *Telegram) Run() error

type Tx

type Tx interface {
	db.Tx
	CreateChatState(chatID int64, chatState ChatState) (ChatState, error)
	GetChatState(chatID int64) (ChatState, error)
	UpdateChatState(chatID int64, chatState ChatState) (ChatState, error)
	DeleteChatState(chatID int64) error
	CreateChatLongRunningCommand(chatID int64, command string) (string, error)
	GetChatLongRunningCommand(chatID int64) (string, error)
	UpdateChatLongRunningCommand(chatID int64, command string) (string, error)
	DeleteChatLongRunningCommand(chatID int64) error
}

Jump to

Keyboard shortcuts

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