api

package
v0.0.0-...-decc4aa Latest Latest
Warning

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

Go to latest
Published: May 12, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TappAdsGetTasks

func TappAdsGetTasks(ctx context.Context, apiKey string, ip, userAgent, lang string, isPremium bool, userID int64) ([]common.TappAdsTask, error)

func TappAdsSendClick

func TappAdsSendClick(ctx context.Context, log zerolog.Logger, apiKey, ip, userAgent string, userID, subTaskID int64) error

Types

type BotLoc

type BotLoc struct {
	InviteText   string `yaml:"invite_text"`
	InviteButton string `yaml:"invite_button"`
}

func (*BotLoc) Valid

func (loc *BotLoc) Valid() error

type Config

type Config struct {
	Postgres dbx.Config    `yaml:"postgres"`
	Redis    cache.Config  `yaml:"redis"`
	Nats     NatsConfig    `yaml:"nats"`
	HTTP     HTTPConfig    `yaml:"http"`
	Bot      tgu.BotConfig `yaml:"bot"`
	Miniapp  MiniappConfig `yaml:"miniapp"`
	Ton      TonConfig     `yaml:"ton"`
}

func LoadConfig

func LoadConfig(rawConfig string) (cfg Config, err error)

func (*Config) SetDefaults

func (cfg *Config) SetDefaults()

func (*Config) Validate

func (cfg *Config) Validate() error

type HTTP

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

func NewHTTP

func NewHTTP(cfg HTTPConfig, log zerolog.Logger, svc *Service, metrics *prometheus.Registry) *HTTP

func (*HTTP) Start

func (h *HTTP) Start(ctx context.Context) error

type HTTPConfig

type HTTPConfig struct {
	PublicPort  int `yaml:"public_port"`
	PrivatePort int `yaml:"private_port"`
}

type MiniappConfig

type MiniappConfig struct {
	WebappURL  string `yaml:"webapp_url"`
	MiniappURL string `yaml:"miniapp_url"`
	SupportURL string `yaml:"support_url"`

	InviteImage string `yaml:"invite_image"`

	En *BotLoc `yaml:"en"`
	Ru *BotLoc `yaml:"ru"`
}

type NatsConfig

type NatsConfig struct {
	Addr string `yaml:"addr"`
}

type Service

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

func NewService

func NewService(cfg Config, log zerolog.Logger, db *dbx.DB, ch cache.Cache, ns *natsu.Stream, bot *tgu.Bot) *Service

func (*Service) AllProducts

func (s *Service) AllProducts() []*common.Product

func (*Service) ClaimProduct

func (s *Service) ClaimProduct(ctx context.Context, user tgu.User, productID int64) (spendPoints int64, err error)

func (*Service) DeleteProduct

func (s *Service) DeleteProduct(ctx context.Context, productID int64) error

func (*Service) DeleteTask

func (s *Service) DeleteTask(ctx context.Context, taskID int64) error

func (*Service) ForceRewardUser

func (s *Service) ForceRewardUser(ctx context.Context, userID, points int64) error

func (*Service) GetAllBotChats

func (s *Service) GetAllBotChats(ctx context.Context) ([]tgu.Chat, error)

func (*Service) GetAllProducts

func (s *Service) GetAllProducts(ctx context.Context) ([]*common.Product, error)

func (*Service) GetAllTasksWithClicks

func (s *Service) GetAllTasksWithClicks(ctx context.Context) ([]*common.FullTask, error)

func (*Service) GetInviteMessage

func (s *Service) GetInviteMessage(ctx context.Context, user tgu.User) (msgID string, err error)

func (*Service) GetTaskStarsInvoice

func (s *Service) GetTaskStarsInvoice(ctx context.Context, userID, taskID int64) (invoiceLink string, err error)

func (*Service) GetTaskTonTransaction

func (s *Service) GetTaskTonTransaction(ctx context.Context, userID, taskID int64) (*common.TonCTx, error)

func (*Service) GetTasksEvents

func (s *Service) GetTasksEvents(ctx context.Context, userID, fromTime int64) ([]common.TaskEvent, error)

func (*Service) GetUserProgress

func (s *Service) GetUserProgress(
	ctx context.Context, user tgu.User,
	startParam, userIP, userAgent string,
) (userTasks []common.UserTask, points int64, err error)

func (*Service) GetUserRefs

func (s *Service) GetUserRefs(ctx context.Context, userID int64) (refCount, refPoints int64, err error)

func (*Service) ParseUserAuth

func (s *Service) ParseUserAuth(authData string) (*tgu.Auth, error)

func (*Service) ParseUserAuth64

func (s *Service) ParseUserAuth64(authData string) (*tgu.Auth, error)

func (*Service) ProcessUserInit

func (s *Service) ProcessUserInit(ctx context.Context, userID int64) error

func (*Service) ProcessUserStart

func (s *Service) ProcessUserStart(ctx context.Context, user tgu.User, startParam, ipAddress, userAgent string) error

func (*Service) SaveProduct

func (s *Service) SaveProduct(ctx context.Context, p *common.Product) error

func (*Service) SaveTask

func (s *Service) SaveTask(ctx context.Context, t *common.FullTask) error

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

func (*Service) TaskClaim

func (s *Service) TaskClaim(ctx context.Context, userID, taskID, subID int64) error

func (*Service) TaskStart

func (s *Service) TaskStart(ctx context.Context, userID, taskID, subID int64, userIP, userAgent string) error

type TonConfig

type TonConfig struct {
	DepositWallet string `yaml:"deposit_wallet"`
	CommentPrefix string `yaml:"comment_prefix"`
}

Jump to

Keyboard shortcuts

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