worker

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: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyWebhookReward = "webhook.reward"

	KeyUserNew  = "users.new"
	KeyUserInit = "users.init"

	KeyTaskStart = "tasks.start"
	KeyTaskDone  = "tasks.done"
	KeyTaskClaim = "tasks.claim"

	KeyChatCheckUser = "chats.check_user"

	KeyProductClaim = "products.claim"

	KeyFragmentSend = "fragment.send"

	KeyCheckPartnerTask = "checks.partner_task"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BotLoc

type BotLoc struct {
	WebappButton  string `yaml:"webapp_button"`
	SupportButton string `yaml:"support_button"`
	HelloText     string `yaml:"hello_text"`
}

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"`
	Ton      TonConfig      `yaml:"ton"`
	Fragment FragmentConfig `yaml:"fragment"`
	Referral ReferralConfig `yaml:"referral"`
	Workers  WorkersConfig  `yaml:"workers"`
	Bot      tgu.BotConfig  `yaml:"bot"`
	Miniapp  MiniappConfig  `yaml:"miniapp"`
}

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 FragmentConfig

type FragmentConfig struct {
	WalletSeed string  `yaml:"wallet_seed"`
	AuthCookie string  `yaml:"auth_cookie"`
	MinBalance float64 `yaml:"min_balance"`
	ChatGifts  int64   `yaml:"chatGifts"`
}

type FragmentMessage

type FragmentMessage struct {
	ProductClaimMessage
	TicketID int64 `json:"ticketID"`
}

type MiniappConfig

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

	HelloImage string `yaml:"hello_image"`

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

type NatsConfig

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

type ProductClaimMessage

type ProductClaimMessage struct {
	Product *common.Product `json:"product"`
	User    tgu.User        `json:"user"`
	ClaimAt time.Time       `json:"claimAt"`
}

type ReferralBonus

type ReferralBonus struct {
	UserID int64
	Points int64
	Level  int
}

type ReferralConfig

type ReferralConfig struct {
	TotalBonus int64   `yaml:"total_bonus"`
	Levels     []int64 `yaml:"levels"`
}

type Service

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

func NewService

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

func (*Service) OnTelegramPrivateMessage

func (s *Service) OnTelegramPrivateMessage(ctx context.Context, user tgu.User, msg *telego.Message) error

func (*Service) OnTelegramSelfMember

func (s *Service) OnTelegramSelfMember(ctx context.Context, joined bool, chat tgu.Chat) error

func (*Service) OnTelegramStarsTx

func (s *Service) OnTelegramStarsTx(ctx context.Context, txID, payload string, amount int) (ok bool, err error)

func (*Service) Start

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

type TaskMessage

type TaskMessage struct {
	Time   time.Time `json:"ts"`
	UserID int64     `json:"uid"`
	TaskID int64     `json:"tid"`
	SubID  int64     `json:"sid,omitempty"`
	Strict bool      `json:"strict,omitempty"`
}

type TonConfig

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

type UserInitMessage

type UserInitMessage struct {
	Time time.Time `json:"time"`
	User int64     `json:"user"`
}

type UserNewMessage

type UserNewMessage struct {
	tgu.User
	JoinAt     time.Time `json:"joined"`
	IPAddress  string    `json:"ip,omitempty"`
	UserAgent  string    `json:"ua,omitempty"`
	StartParam string    `json:"start,omitempty"`
}

type WebhookRewardMessage

type WebhookRewardMessage struct {
	Received time.Time `json:"received"`
	Token    string    `json:"token"`
	UserID   int64     `json:"userID"`
	TaskID   int64     `json:"taskID,omitempty"`
	SubID    int64     `json:"subID,omitempty"`
	Payout   float64   `json:"payout,omitempty"`
}

type WorkersConfig

type WorkersConfig struct {
	Webhook int `yaml:"webhook"`
	Users   int `yaml:"users"`
	Tasks   int `yaml:"tasks"`
	Chats   int `yaml:"chats"`
	Checks  int `yaml:"checks"`
}

Jump to

Keyboard shortcuts

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