scheduledevents2

package
v1.31.10 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: MIT Imports: 23 Imported by: 0

README

The sucessor of the original scheduled events system for yagpdb that was running on redis, this one however is running on postgres.

The old system did not support things like clustering and was overall a bit messy and unstructured.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DBSchemas = []string{`
CREATE TABLE IF NOT EXISTS scheduled_events (
	id BIGSERIAL PRIMARY KEY,

	created_at TIMESTAMP WITH TIME ZONE NOT NULL,
	triggers_at TIMESTAMP WITH TIME ZONE NOT NULL,

	retry_on_error BOOLEAN NOT NULL,

	guild_id BIGINT NOT NULL,
	event_name TEXT NOT NULL,
	data JSONB NOT NULL,

	processed BOOL not null
);
`, `
CREATE INDEX IF NOT EXISTS scheduled_events_triggers_at_idx ON scheduled_events(triggers_at);
`, `
ALTER TABLE scheduled_events ADD COLUMN IF NOT EXISTS  error TEXT
`,
}
View Source
var ErrBadPairLength = errors.NewPlain("ID - GuildID pair corrupted")

Functions

func CancelAddRole added in v1.31.10

func CancelAddRole(ctx context.Context, guildID, userID, roleID int64) error

func CancelRemoveRole added in v1.16.0

func CancelRemoveRole(ctx context.Context, guildID, userID, roleID int64) error

func CheckDiscordErrRetry added in v1.11.0

func CheckDiscordErrRetry(err error) bool

func RegisterHandler

func RegisterHandler(eventName string, dataFormat interface{}, handler HandlerFunc)

RegisterHandler registers a handler for the scpecified event name dataFormat is optional and should not be a pointer, it should match the type you're passing into ScheduleEvent

func RegisterLegacyMigrater added in v1.11.0

func RegisterLegacyMigrater(eventName string, migrationHandler func(t time.Time, data string) error)

RegisterHandler registers a handler for the scpecified event name dataFormat is optional and should not be a pointer, it should match the type you're passing into ScheduleEvent

func RegisterPlugin

func RegisterPlugin()

func ScheduleAddRole added in v1.31.10

func ScheduleAddRole(ctx context.Context, guildID, userID, roleID int64, when time.Time) error

func ScheduleDeleteMessages added in v1.13.0

func ScheduleDeleteMessages(guildID, channelID int64, when time.Time, messages ...int64) error

func ScheduleEvent added in v1.11.0

func ScheduleEvent(evtName string, guildID int64, runAt time.Time, data interface{}) error

func ScheduleRemoveRole added in v1.16.0

func ScheduleRemoveRole(ctx context.Context, guildID, userID, roleID int64, when time.Time) error

func UpdateFlushedEvent added in v1.31.10

func UpdateFlushedEvent(t time.Time, c radix.Client, evt *models.ScheduledEvent) error

UpdateFlushedEvent updates a already flushed event by either removing it if its above the treshold, or updating the score

Types

type AddRoleData added in v1.31.10

type AddRoleData struct {
	UserID int64 `json:"user_id"`
	RoleID int64 `json:"role_id"`
}

type DeleteMessagesEvent added in v1.13.0

type DeleteMessagesEvent struct {
	GuildID   int64
	ChannelID int64
	Messages  []int64
}

type HandlerFunc

type HandlerFunc func(evt *models.ScheduledEvent, data interface{}) (retry bool, err error)

type RegisteredHandler

type RegisteredHandler struct {
	EvtName    string
	DataFormat interface{}
	Handler    HandlerFunc
}

type RmoveRoleData added in v1.16.0

type RmoveRoleData struct {
	GuildID int64 `json:"guild_id"`
	UserID  int64 `json:"user_id"`
	RoleID  int64 `json:"role_id"`
}

type ScheduledEvents

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

func (*ScheduledEvents) LateBotInit added in v1.11.5

func (se *ScheduledEvents) LateBotInit()

func (*ScheduledEvents) MigrateLegacyEvents added in v1.11.0

func (se *ScheduledEvents) MigrateLegacyEvents()

func (*ScheduledEvents) PluginInfo added in v1.17.0

func (p *ScheduledEvents) PluginInfo() *common.PluginInfo

func (*ScheduledEvents) RunBackgroundWorker added in v1.11.0

func (p *ScheduledEvents) RunBackgroundWorker()

func (*ScheduledEvents) SecondaryCleaner added in v1.31.10

func (p *ScheduledEvents) SecondaryCleaner()

func (*ScheduledEvents) StopBackgroundWorker added in v1.11.0

func (p *ScheduledEvents) StopBackgroundWorker(wg *sync.WaitGroup)

func (*ScheduledEvents) StopBot added in v1.11.0

func (se *ScheduledEvents) StopBot(wg *sync.WaitGroup)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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