tgstate

package
v0.0.0-...-493173e Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ID

type ID int
const (
	None ID = iota
	AddFriend
	RemoveFriend
	ImportFromVK
)

type Repo

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

func NewRepository

func NewRepository(db *sqlx.DB) *Repo

func (*Repo) Get

func (r *Repo) Get(telegramID int) (*State, error)

Get returns a state by telegram ID. If there is no state in the database, a new one will be created.

func (*Repo) GetAll

func (r *Repo) GetAll() ([]*State, error)

GetAll fetches all states and returns them.

func (*Repo) Save

func (r *Repo) Save(state *State) error

Save saves the given state to the database.

type Repository

type Repository interface {
	Get(telegramID int) (*State, error)
	GetAll() ([]*State, error)
	Save(state *State) error
}

type State

type State struct {
	State       ID // Conversation state
	StateBefore ID // State before handling current update

	TelegramID   int
	Username     string
	FirstName    string
	LastName     string
	LanguageCode string

	CannotReceiveMessages bool

	LastNotificationAt time.Time

	VKID int

	Friends []friendship.Friend

	NewFriend friendship.Friend
}

func (*State) Scan

func (s *State) Scan(value interface{}) error

func (*State) Value

func (s *State) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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