front

package
v0.0.0-...-871180b Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2022 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NOT_AUTHORIZED_MSG = "You are not athorized to use this bot contact with @Gulolio or @SunShiNeXS. Btw, who the hell are you?"

	//Logging Levels
	//LevelDebug debugging
	LevelDebug Level = iota
	//LevelInfo info
	LevelInfo
	//LevelWarn warning
	LevelWarn
	//LevelError error
	LevelError
	//LevelCrit critic error
	LevelCrit

	RESULT_QUEUE        = "results"
	BACKUP_RESULT_QUEUE = "results_back"

	TASK_QUEUE = "tasks"

	MAX_DOWNLOAD = 3

	SESSION_EXP = 52 * time.Minute
)
View Source
const PING_TIMEOUT = 10 * time.Second

Variables

View Source
var (
	TOKEN_API      = os.Getenv("TOKEN_TELGRAM_API")
	CLOUDINARY_URL = os.Getenv("CLOUDINARY_URL")
)
View Source
var (
	REDIS_URL      = os.Getenv("REDIS_URL")
	REDIS_PASSWORD = os.Getenv("REDIS_PASSWORD")
)
View Source
var (
	DATABASE_URL = os.Getenv("DATABASE_URL")
)

Functions

func CreateUser

func CreateUser(username string, chatid int64, repo UserRepo) error

CreateUser insert a user in DB

func InitBot

func InitBot()

InitBot initialize bot

func IsAuthorized

func IsAuthorized(user *tgbotapi.User, repo UserRepo, rds RedisUserRepo) bool

IsAuthorized check if given user is authorized

func NewPostgreRepo

func NewPostgreRepo() *postgreRepo

func NewRedisRepo

func NewRedisRepo() *redisRepo

NewRedisRepo ...

func Register

func Register(user *tgbotapi.User, chatid int64, repo UserRepo, rds RedisUserRepo)

Register register in case user s not in DB

Types

type BotLogger

type BotLogger struct {
	log.Logger
	Level Level
}

BotLogger ...

func (BotLogger) Printf

func (log BotLogger) Printf(format string, v ...interface{})

Printf ...

func (BotLogger) Println

func (log BotLogger) Println(v ...interface{})

Println ...

type DataTransfer

type DataTransfer struct {
	URL      string `json:"url"`
	ImageURL string `json:"imageurl"`
	ChatID   string `json:"chatid"`
	Path     string `json:"path"`
	HashKey  string `json:"hashkey"`
}

DataTransfer is the data passed between ZeroMQ sockets

type Level

type Level int

Level is the logging level

type RedisUserRepo

type RedisUserRepo interface {
	Get(string) string
	Set(string, string, time.Duration)
}

RedisUserRepo ...

type Repos

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

Repos repos of DBs

type RequestMD

type RequestMD struct {
	ChatID    int64
	MessageID int
	Index     int
}

type TaskWorker

type TaskWorker struct {
	URL      string
	ImageURL string
	ChatID   int64
	Title    string
	HashKey  string
}

type UserRepo

type UserRepo interface {
	Create(string, int64) error
	Find(string) error
	AddAttempts(*tgbotapi.User) error
	UpdateTimes(string) error
	UpdateSessions(string) error
}

UserRepo ...

Jump to

Keyboard shortcuts

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