events

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CurrentChampionship           *structs.Championship
	AssignChampionshipWithDefault = func(utils types.Utils) {
		CurrentChampionship = structs.CreateChampionship("Clocky Championship", FirstWeekdayFrom(time.Now(), time.Sunday), 336*time.Hour)
	}
)
View Source
var (
	PinnedResetMessage      EventsResetPinnedMessage
	HintRewardedUsers       = make(map[string][]DailyRewardedUser)
	Events                  *EventsData
	AssignEventsWithDefault = func(utils types.Utils) {
		Events = NewEventsData(true, utils)
	}
)
View Source
var (
	SetsFunctions = FuncMap{

		"Short Equal":      shortEqual,
		"Repeat":           repeat,
		"Mirror":           mirror,
		"Rise":             rise,
		"Short Rise":       shortRise,
		"Short Fall":       shortFall,
		"Rapid Rise":       rapidRise,
		"Short Rapid Rise": shortRapidRise,
		"Short Rapid Fall": shortRapidFall,
		"Double":           double,
		"Short Triple":     shortTriple,
		"Perfect Square":   perfectSquare,
		"Equal Twins":      equalTwins,
	}
	Sets = SetSlice{

		{"Short Equal", "?a:aa", "static", false, shortEqual},
		{"Repeat", "ab:ab", "static", false, repeat},
		{"Mirror", "ab:ba", "static", false, mirror},
		{"Rise", "ab:cd", "static", false, rise},
		{"Short Rise", "?a:bc", "static", false, shortRise},
		{"Short Fall", "?c:ba", "static", false, shortFall},
		{"Rapid Rise", "ac:eg", "static", false, rapidRise},
		{"Short Rapid Rise", "?a:ce", "static", false, shortRapidRise},
		{"shortRapidFall", "?e:ca", "static", false, shortRapidFall},
		{"double", "n:2*n", "static", false, double},
		{"shortTriple", "[unnamed]", "static", false, shortTriple},
		{"Perfect Square", "[unnamed]", "static", false, perfectSquare},
		{"Equal Twins", "aa:bb", "static", false, equalTwins},
	}
	SetsJson = SetJsonSlice{}

	AssignSetsFromSetsJson = func(utils types.Utils) {
		Sets = SetsJson.ToSlice()
	}
	AssignSetsWithDefault = func(utils types.Utils) {
		Sets = SetSlice{

			{"Short Equal", "?a:aa", "static", false, shortEqual},
			{"Repeat", "ab:ab", "static", false, repeat},
			{"Mirror", "ab:ba", "static", false, mirror},
			{"Rise", "ab:cd", "static", false, rise},
			{"Short Rise", "?a:bc", "static", false, shortRise},
			{"Short Fall", "?c:ba", "static", false, shortFall},
			{"Rapid Rise", "ac:eg", "static", false, rapidRise},
			{"Short Rapid Rise", "?a:ce", "static", false, shortRapidRise},
			{"Short Rapid Fall", "?e:ca", "static", false, shortRapidFall},
			{"Double", "n:2*n", "static", false, double},
			{"Short Triple", "[unnamed]", "static", false, shortTriple},
			{"Perfect Square", "[unnamed]", "static", false, perfectSquare},
			{"Equal Twins", "aa:bb", "static", false, equalTwins},
		}
	}
)

Functions

func CalculateStatus added in v0.2.4

func CalculateStatus(time time.Time) (bool, int)

func CalculateValid added in v0.2.4

func CalculateValid(time time.Time) bool

func FirstWeekdayFrom added in v0.4.1

func FirstWeekdayFrom(start time.Time, weekday time.Weekday) time.Time

func RemoveValue added in v0.2.4

func RemoveValue(s []string, value string) []string

func SplitTime added in v0.2.4

func SplitTime(time time.Time) (int, int, int, int)

func UpdatePinnedMessage added in v0.2.5

func UpdatePinnedMessage(writeMsgData *types.WriteMessageData, utils types.Utils, msgToPin tgbotapi.Message)

Types

type DailyRewardedUser added in v0.4.1

type DailyRewardedUser struct {
	User *structs.UserMinimal
	Sets []string
}

type EffectPresence added in v0.4.2

type EffectPresence struct {
	Name   string
	Amount int
}

type Event added in v0.2.4

type Event struct {
	Time           time.Time
	Name           string
	Points         int
	Enabled        bool
	Effects        []*structs.Effect
	Activation     *EventActivation
	Partecipations map[int64]*EventPartecipation
}

func EventsOf added in v0.2.5

func EventsOf(setFunc func(int, int, int, int) bool) []*Event

func NewEvent added in v0.2.4

func NewEvent(eventTime time.Time) *Event

func (*Event) Activate added in v0.2.4

func (e *Event) Activate(by *structs.User, at, telegramAt time.Time, points int)

func (*Event) AddEffect added in v0.2.4

func (e *Event) AddEffect(effect *structs.Effect)

func (*Event) HasPartecipated added in v0.2.4

func (e *Event) HasPartecipated(userID int64) bool

func (*Event) Partecipate added in v0.2.4

func (e *Event) Partecipate(by *structs.User, at time.Time)

func (*Event) Reset added in v0.2.4

func (e *Event) Reset()

func (*Event) StringifyEffects added in v0.2.5

func (e *Event) StringifyEffects() string

type EventActivation added in v0.2.4

type EventActivation struct {
	ActivatedBy  *structs.User
	ActivatedAt  time.Time
	ArrivedAt    time.Time
	EarnedPoints int
}

type EventPartecipation added in v0.2.4

type EventPartecipation struct {
	PartecipatedBy *structs.User
	PartecipatedAt time.Time
}

type EventsData added in v0.2.4

type EventsData struct {
	Map   EventsMap
	Keys  EventsKeys
	Stats EventsStats
}

func NewEventsData added in v0.2.4

func NewEventsData(newEffects bool, utils types.Utils) *EventsData

func (*EventsData) AssignRandomEffects added in v0.2.4

func (ed *EventsData) AssignRandomEffects(utils types.Utils, effects ...structs.EffectPresence)

func (*EventsData) EnabledRandomSets added in v0.2.4

func (ed *EventsData) EnabledRandomSets(percentage types.Interval, utils types.Utils) error

func (*EventsData) Reset added in v0.2.4

func (ed *EventsData) Reset(newEffects bool, writeMsgData *types.WriteMessageData, utils types.Utils)

func (*EventsData) SaveOnFile added in v0.2.4

func (ed *EventsData) SaveOnFile(utils types.Utils)

func (*EventsData) WriteResetMessage added in v0.2.4

func (ed *EventsData) WriteResetMessage(writeMsgData *types.WriteMessageData, utils types.Utils)

type EventsKeys added in v0.2.0

type EventsKeys []string

type EventsMap

type EventsMap map[string]*Event

type EventsResetPinnedMessage added in v0.4.1

type EventsResetPinnedMessage struct {
	Exist     bool
	ChatID    int64
	MessageID int
}

type EventsStats added in v0.2.4

type EventsStats struct {
	TotalSetsNum      int
	EnabledSetsNum    int
	EnabledSets       []string
	TotalEventsNum    int
	EnabledEventsNum  int
	EnabledPointsSum  int
	EnabledEffectsNum int
	EnabledEffects    map[string]int
}

type FuncMap added in v0.2.4

type FuncMap map[string]func(h1, h2, m1, m2 int) bool

type Set added in v0.2.4

type Set struct {
	Name     string
	Pattern  string
	Typology string
	Enabled  bool
	Verify   func(h1, h2, m1, m2 int) bool
}

type SetJson added in v0.2.4

type SetJson struct {
	Name     string
	Pattern  string
	Typology string
	Enabled  bool
}

type SetJsonSlice added in v0.2.4

type SetJsonSlice []*SetJson

func (SetJsonSlice) ToSlice added in v0.2.4

func (sj SetJsonSlice) ToSlice() SetSlice

type SetSlice added in v0.2.4

type SetSlice []*Set

func (SetSlice) ToJsonSlice added in v0.2.4

func (s SetSlice) ToJsonSlice() SetJsonSlice

Jump to

Keyboard shortcuts

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