loyalty

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const ConfigKey = "loyalty/config"
View Source
const CreateRedeemRPC = "loyalty/@create-redeem"
View Source
const GoalsKey = "loyalty/goals"
View Source
const KVExLoyaltyContribute = "stulbe/loyalty/@contribute-rpc"
View Source
const KVExLoyaltyRedeem = "stulbe/loyalty/@redeem-rpc"
View Source
const OldPointsKey = "loyalty/users"
View Source
const PointsPrefix = "loyalty/points/"
View Source
const QueueKey = "loyalty/redeem-queue"
View Source
const RedeemEvent = "loyalty/ev/new-redeem"
View Source
const RemoveRedeemRPC = "loyalty/@remove-redeem"
View Source
const RewardsKey = "loyalty/rewards"

Variables

View Source
var (
	ErrRedeemInCooldown   = errors.New("redeem is on cooldown")
	ErrGoalNotFound       = errors.New("goal not found")
	ErrGoalAlreadyReached = errors.New("goal already reached")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Currency string `json:"currency"`
	Points   struct {
		Interval      int64 `json:"interval"` // in seconds!
		Amount        int64 `json:"amount"`
		ActivityBonus int64 `json:"activity_bonus"`
	} `json:"points"`
	BanList []string `json:"banlist"`
}

type ExLoyaltyContribute added in v1.7.0

type ExLoyaltyContribute struct {
	Username    string `json:"username"`
	DisplayName string `json:"display_name"`
	Channel     string `json:"channel"`
	GoalID      string `json:"goal_id"`
	Amount      int64  `json:"amount"`
}

type ExLoyaltyRedeem added in v1.7.0

type ExLoyaltyRedeem struct {
	Username    string `json:"username"`
	DisplayName string `json:"display_name"`
	Channel     string `json:"channel"`
	RewardID    string `json:"reward_id"`
	RequestText string `json:"request_text"`
}

type Goal

type Goal struct {
	Enabled      bool             `json:"enabled"`
	ID           string           `json:"id"`
	Name         string           `json:"name"`
	Description  string           `json:"description"`
	Image        string           `json:"image"`
	TotalGoal    int64            `json:"total"`
	Contributed  int64            `json:"contributed"`
	Contributors map[string]int64 `json:"contributors"`
}

type GoalStorage

type GoalStorage []Goal

type Manager

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

func NewManager

func NewManager(manager *modules.Manager) (*Manager, error)

func (*Manager) AddRedeem

func (m *Manager) AddRedeem(redeem Redeem) error

func (*Manager) Close added in v1.6.1

func (m *Manager) Close() error

func (*Manager) Config

func (m *Manager) Config() Config

func (*Manager) ContributeGoal added in v1.1.0

func (m *Manager) ContributeGoal(goal Goal, user string, points int64) error

func (*Manager) GetGoal added in v1.4.0

func (m *Manager) GetGoal(id string) Goal

func (*Manager) GetPoints added in v1.1.0

func (m *Manager) GetPoints(user string) int64

func (*Manager) GetReward added in v1.4.0

func (m *Manager) GetReward(id string) Reward

func (*Manager) GetRewardCooldown added in v1.5.0

func (m *Manager) GetRewardCooldown(rewardID string) time.Time

func (*Manager) GivePoints

func (m *Manager) GivePoints(pointsToGive map[string]int64) error

func (*Manager) Goals

func (m *Manager) Goals() []Goal

func (*Manager) PerformContribution added in v1.4.0

func (m *Manager) PerformContribution(goal Goal, user string, points int64) error

func (*Manager) PerformRedeem added in v1.4.0

func (m *Manager) PerformRedeem(redeem Redeem) error

func (*Manager) RemoveRedeem

func (m *Manager) RemoveRedeem(redeem Redeem) error

func (*Manager) Rewards

func (m *Manager) Rewards() []Reward

func (*Manager) SaveGoals added in v1.1.0

func (m *Manager) SaveGoals() error

func (*Manager) TakePoints

func (m *Manager) TakePoints(pointsToTake map[string]int64) error

type OldPointStorage added in v1.3.0

type OldPointStorage map[string]int64

type PointsEntry added in v1.3.0

type PointsEntry struct {
	Points int64 `json:"points"`
}

type Redeem

type Redeem struct {
	Username    string    `json:"username"`
	DisplayName string    `json:"display_name"`
	Reward      Reward    `json:"reward"`
	When        time.Time `json:"when"`
	RequestText string    `json:"request_text"`
}

type RedeemQueueStorage

type RedeemQueueStorage []Redeem

type Reward

type Reward struct {
	Enabled       bool   `json:"enabled"`
	ID            string `json:"id"`
	Name          string `json:"name"`
	Description   string `json:"description"`
	Image         string `json:"image"`
	Price         int64  `json:"price"`
	CustomRequest string `json:"required_info,omitempty"`
	Cooldown      int64  `json:"cooldown"`
}

type RewardStorage

type RewardStorage []Reward

Jump to

Keyboard shortcuts

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