bot

package
v0.0.0-...-e2133d7 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: Unlicense Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommandStart = "start"

	KeyboardButtonTask = "/task"

	Emails = 100
)

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

func MessageTask

func MessageTask(workouts []Workout, today, tomorrow time.Time) string

func NewDate

func NewDate(t time.Time) time.Time

Types

type Bot

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

func NewBot

func NewBot(bot Sender, db Storage, fs FinalSurge, clock Clock) *Bot

func (*Bot) Keyboard

func (b *Bot) Keyboard() tgbotapi.ReplyKeyboardMarkup

func (*Bot) ProcessUpdate

func (b *Bot) ProcessUpdate(ctx context.Context, update tgbotapi.Update) error

type Clock

type Clock interface {
	Now() time.Time
}

type Config

type Config struct {
	Debug       bool   `envconfig:"DEBUG"`
	PublicURL   string `envconfig:"PUBLIC_URL" required:"true"`
	BotAPIKey   string `envconfig:"BOT_API_KEY" required:"true"`
	Port        int    `envconfig:"PORT" required:"true"`
	DatabaseURL string `envconfig:"DATABASE_URL" required:"true"`
	RunOnCloud  bool   `envconfig:"RUN_ON_CLOUD"`
}

func NewConfig

func NewConfig() (*Config, error)

type FinalSurge

type FinalSurge interface {
	Login(ctx context.Context, email, password string) (UserToken, error)
	Workouts(ctx context.Context, userToken UserToken, startDate, endDate time.Time) ([]Workout, error)
}

type FinalSurgeAPI

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

func NewFinalSurgeAPI

func NewFinalSurgeAPI(client *http.Client) *FinalSurgeAPI

func (*FinalSurgeAPI) Login

func (f *FinalSurgeAPI) Login(ctx context.Context, email, password string) (UserToken, error)

func (*FinalSurgeAPI) Workouts

func (f *FinalSurgeAPI) Workouts(ctx context.Context, userToken UserToken, startDate, endDate time.Time,
) ([]Workout, error)

type FinalSurgeActivity

type FinalSurgeActivity struct {
	ActivityTypeName string `json:"activity_type_name"`
}

type FinalSurgeLogin

type FinalSurgeLogin struct {
	FinalSurgeStatus
	Data FinalSurgeLoginData `json:"data"`
}

type FinalSurgeLoginData

type FinalSurgeLoginData struct {
	UserKey   string `json:"user_key"`
	Token     string `json:"token"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Email     string `json:"email"`
}

type FinalSurgeLoginReq

type FinalSurgeLoginReq struct {
	Email                 string `json:"email"`
	Password              string `json:"password"`
	DeviceManufacturer    string `json:"deviceManufacturer"`
	DeviceModel           string `json:"deviceModel"`
	DeviceOperatingSystem string `json:"deviceOperatingSystem"`
}

type FinalSurgeStatus

type FinalSurgeStatus struct {
	ServerTime       string  `json:"server_time"`
	Success          bool    `json:"success"`
	ErrorNumber      *int    `json:"error_number"`
	ErrorDescription *string `json:"error_description"`
	CallID           *string `json:"call_id"`
}

type FinalSurgeWorkoutData

type FinalSurgeWorkoutData struct {
	WorkoutDate string               `json:"workout_date"`
	Description *string              `json:"description"`
	Activities  []FinalSurgeActivity `json:"activities"`
}

type FinalSurgeWorkoutList

type FinalSurgeWorkoutList struct {
	FinalSurgeStatus
	Data []FinalSurgeWorkoutData `json:"data"`
}

type Postgres

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

func NewPostgres

func NewPostgres(pool *pgxpool.Pool) *Postgres

func (*Postgres) Init

func (p *Postgres) Init(ctx context.Context) error

func (*Postgres) UpdateUserToken

func (p *Postgres) UpdateUserToken(ctx context.Context, userName string, userToken UserToken) error

func (*Postgres) UserToken

func (p *Postgres) UserToken(ctx context.Context, userName string) (UserToken, error)

type RealClock

type RealClock struct{}

func NewClock

func NewClock() *RealClock

func (*RealClock) Now

func (c *RealClock) Now() time.Time

type Sender

type Sender interface {
	Send(msg tgbotapi.Chattable) (tgbotapi.Message, error)
}

type Storage

type Storage interface {
	UserToken(ctx context.Context, userName string) (UserToken, error)
	UpdateUserToken(ctx context.Context, userName string, userToken UserToken) error
}

type UserToken

type UserToken struct {
	UserKey string
	Token   string
}

type Workout

type Workout struct {
	Date        time.Time
	Description string
}

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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