lib

package
v0.0.0-...-2ac21d8 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InitTelegram = initTelegram

Mock points for testing

View Source
var SendTelegramMsg = sendTelegramMsg
View Source
var StartTelegram = startTelegram
View Source
var Tg *tb.Bot = nil
View Source
var TgLoginURL string

Functions

func NewRestServer

func NewRestServer(prefix string, db *Database) (e *echo.Echo)

Types

type App

type App struct {
	DB   *Database
	Rest *echo.Echo
}

func (*App) Exit

func (a *App) Exit()

func (*App) Initialize

func (a *App) Initialize(dbParameters, token, prefix string)

func (*App) Run

func (a *App) Run(bindParameter string)

type Database

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

func NewDatabase

func NewDatabase(dbParameters string) *Database

func (*Database) Close

func (p *Database) Close()

func (*Database) CreateOrGetUserKeyByTelegramId

func (p *Database) CreateOrGetUserKeyByTelegramId(u *User) bool

func (*Database) GetTimer

func (p *Database) GetTimer(id, userid int64) *Timer

func (*Database) GetTimersJSON

func (p *Database) GetTimersJSON(userid int64) string

func (*Database) GetUserIdByKey

func (p *Database) GetUserIdByKey(key string) (id int64, err error)

User entries

func (*Database) GetUserTelegramIdById

func (p *Database) GetUserTelegramIdById(id int64) (tgid int64, err error)

func (*Database) Init

func (p *Database) Init()

func (*Database) NewTimer

func (p *Database) NewTimer() *Timer

func (*Database) ProcessExpiredTimers

func (p *Database) ProcessExpiredTimers() int

type Timer

type Timer struct {
	// Values in database
	Id       int64  `json:"timerid"`
	UserId   int64  `json:"-"`
	Name     string `json:"name" form:"name" query:"name"`
	Interval int64  `json:"interval" form:"interval" query:"interval"`
	Expiry   int64  `json:"expiry"`
	// State can be "new", "running", "expired"
	State string `json:"state"`

	// Other
	Database *Database `json:"-"`
}

func (*Timer) Create

func (t *Timer) Create() error

Timer entries

func (*Timer) Delete

func (t *Timer) Delete() (err error)

func (*Timer) Expire

func (t *Timer) Expire()

func (*Timer) Kick

func (t *Timer) Kick() error

type User

type User struct {
	Id   int64
	Name string
	TgId int64
	Key  string
}

Jump to

Keyboard shortcuts

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