bot

package
v0.0.0-...-6eaff4a Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithApp

func ContextWithApp(ctx context.Context, app *App) context.Context

func FS

func FS() fs.FS

func OnStart

func OnStart(name string, fn HookFunc)

func WaitExitSignal

func WaitExitSignal() os.Signal

Types

type AllowedAdmin

type AllowedAdmin struct {
	bun.BaseModel  `bun:"allowed_admin"`
	DiscordGuildID uint64 `bun:",pk,notnull"`
	DiscordRoleID  uint64 `bun:",pk,notnull"`
}

type AllowedMod

type AllowedMod struct {
	bun.BaseModel  `bun:"allowed_mod"`
	DiscordGuildID uint64 `bun:",pk,notnull"`
	DiscordRoleID  uint64 `bun:",pk,notnull"`
}

type App

type App struct {
	Discord *discordgo.Session
	// contains filtered or unexported fields
}

func AppFromContext

func AppFromContext(ctx context.Context) *App

func New

func New(ctx context.Context, cfg *AppConfig) *App

func Start

func Start(ctx context.Context, service, envName, token, guild string) (context.Context, *App, error)

func StartCLI

func StartCLI(c *cli.Context) (context.Context, *App, error)

func StartConfig

func StartConfig(ctx context.Context, cfg *AppConfig) (context.Context, *App, error)

func (*App) Config

func (app *App) Config() *AppConfig

func (*App) Context

func (app *App) Context() context.Context

func (*App) DB

func (app *App) DB() *bun.DB

func (*App) IsDebug

func (app *App) IsDebug() bool

func (*App) OnAfterStop

func (app *App) OnAfterStop(name string, fn HookFunc)

func (*App) OnStop

func (app *App) OnStop(name string, fn HookFunc)

func (*App) Running

func (app *App) Running() bool

func (*App) Stop

func (app *App) Stop()

func (*App) Stopping

func (app *App) Stopping() bool

type AppConfig

type AppConfig struct {
	Guild         string
	CleanUpOnExit bool
	BotToken      string
	Env           string
	Debug         bool `yaml:"debug"`

	Service string

	DB struct {
		DSN string `yaml:"dsn"`
	} `yaml:"db"`
}

func ReadConfig

func ReadConfig(fsys fs.FS, env, service, token, guild string) (*AppConfig, error)

type HookFunc

type HookFunc func(ctx context.Context, app *App) error

type League

type League struct {
	bun.BaseModel  `bun:"league"`
	DiscordGuildID uint64  `bun:",pk,notnull"`
	LeagueID       uint32  `bun:",pk,nullzero,notnull,default:'unknown'"`
	FriendlyName   string  `bun:",notnull"`
	Team           []*Team `bun:"rel:has-many,join:discord_guild_id=discord_guild_id,league_id=league_id"`
}

type LedgerEntry

type LedgerEntry struct {
	bun.BaseModel     `bun:"ledger_entry"`
	DiscordGuildID    uint64    `bun:",pk,notnull"`
	LedgerEntryID     uint64    `bun:",pk,nullzero,notnull,default:'unknown'"`
	EffectiveDatetime time.Time `bun:",notnull,default:current_timestamp"`
	DiscordUserID     uint64    `bun:",nullzero"`
	TeamID            uint32    `bun:",nullzero"`
	Team              *Team     `bun:"rel:belongs-to,join:discord_guild_id=discord_guild_id,team_id=team_id"`
	TaskID            uint64    `bun:",notnull"`
	Task              *Task     `bun:"rel:belongs-to,join:discord_guild_id=discord_guild_id,task_id=task_id"`
	DiffPointBase     int32     `bun:",notnull"`
	DiffPointBonus    int32     `bun:",notnull"`
}

type ParticipantPointTotal

type ParticipantPointTotal struct {
	bun.BaseModel  `bun:"participant_point_total"`
	DiscordGuildID uint64 `bun:",notnull"`
	DiscordUserID  uint64 `bun:",notnull"`
	PointTotal     int64  `bun:",notnull"`
}

type Season

type Season struct {
	bun.BaseModel  `bun:"season"`
	DiscordGuildID uint64 `bun:",pk,notnull"`
	SeasonID       uint32 `bun:",pk,nullzero,notnull,default:'unknown'"`
	FriendlyName   string `bun:",notnull"`
	DatetimeRange  string `bun:",notnull"`
}

type Task

type Task struct {
	bun.BaseModel              `bun:"task"`
	DiscordGuildID             uint64                        `bun:",pk,notnull"`
	TaskID                     uint64                        `bun:",pk,nullzero,notnull,default:'unknown'"`
	FriendlyName               string                        `bun:",notnull"`
	PointBase                  uint32                        `bun:",notnull"`
	PointBonus                 uint32                        `bun:",notnull"`
	OpenDatetime               time.Time                     `bun:",nullzero,notnull,default:current_timestamp"`
	CloseDatetime              time.Time                     `bun:",nullzero"`
	PerParticipantLimit        uint16                        `bun:",nullzero"`
	TaskTypeID                 uint64                        `bun:",nullzero"`
	TaskType                   *TaskType                     `bun:"rel:belongs-to,join:discord_guild_id=discord_guild_id,task_type_id=task_type_id"`
	TaskCollectionID           uint64                        `bun:",nullzero"`
	TaskCollection             *TaskCollection               `bun:"rel:belongs-to,join:discord_guild_id=discord_guild_id,task_collection_id=task_collection_id"`
	AdditionalInfo             map[string]interface{}        `bun:",nullzero"`
	LedgerEntry                []*LedgerEntry                `bun:"rel:has-many,join:discord_guild_id=discord_guild_id,task_id=task_id"`
	TaskParticipantRestriction []*TaskParticipantRestriction `bun:"rel:has-many,join:discord_guild_id=discord_guild_id,task_participant_restriction_id=task_participant_restriction_id"`
}

type TaskCollection

type TaskCollection struct {
	bun.BaseModel    `bun:"task_collection"`
	DiscordGuildID   uint64  `bun:",pk,notnull"`
	TaskCollectionID uint32  `bun:",pk,nullzero,notnull,default:'unknown'"`
	FriendlyName     string  `bun:",notnull"`
	Task             []*Task `bun:"rel:has-many,join:discord_guild_id=discord_guild_id,task_id=task_id"`
}

type TaskParticipantRestriction

type TaskParticipantRestriction struct {
	bun.BaseModel                `bun:"task_participant_restriction"`
	DiscordGuildID               uint64    `bun:",pk,notnull"`
	TaskParticipantRestrictionID uint32    `bun:",pk,nullzero,notnull,default:'unknown'"`
	TaskID                       uint64    `bun:",notnull"`
	Task                         *Task     `bun:"rel:belongs-to,join:discord_guild_id=discord_guild_id,task_id=task_id"`
	DiscordUserID                uint64    `bun:",notnull"`
	ExpirationDatetime           time.Time `bun:",nullzero"`
}

type TaskType

type TaskType struct {
	bun.BaseModel    `bun:"task_type"`
	DiscordGuildID   uint64    `bun:",pk,notnull"`
	TaskTypeID       uint32    `bun:",pk,nullzero,notnull,default:'unknown'"`
	FriendlyName     string    `bun:",notnull"`
	ParentTaskTypeID uint64    `bun:",nullzero"`
	ParentTaskType   *TaskType `bun:"rel:belongs-to,join:discord_guild_id=discord_guild_id,parent_task_type_id=task_type_id"`
	Task             []*Task   `bun:"rel:has-many,join:discord_guild_id=discord_guild-id,task_id=task_id"`
}

type Team

type Team struct {
	bun.BaseModel  `bun:"team"`
	DiscordGuildID uint64         `bun:",pk,notnull"`
	TeamID         uint32         `bun:",pk,nullzero,notnull"`
	DiscordRoleID  uint64         `bun:",notnull"`
	LeagueID       uint32         `bun:",nullzero"`
	League         *League        `bun:"rel:belongs-to,join:discord_guild_id=discord_guild_id,league_id=league_id"`
	LedgerEntry    []*LedgerEntry `bun:"rel:has-many,join:discord_guild_id=discord_guild_id,team_id=team_id"`
}

Team is a roleID that can collect points and have members

type TeamPointTotal

type TeamPointTotal struct {
	bun.BaseModel  `bun:"team_point_total"`
	DiscordGuildID uint64 `bun:",notnull"`
	DiscordRoleID  uint64 `bun:",notnull"`
	PointTotal     int64  `bun:",notnull"`
}

Jump to

Keyboard shortcuts

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