bot

package
v0.0.0-...-0291a47 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArchiveEvent

type ArchiveEvent struct {
	CreatedAt             time.Time
	UUID                  string `gorm:"primaryKey;uniqueIndex"`
	ArchiveEventEventUUID string
	ServerID              string `gorm:"index"`
	ServerName            string
	RequestURL            string
	RequestDomainName     string `gorm:"index"`
	ResponseURL           string
	ResponseDomainName    string `gorm:"index"`
	Cached                bool
}

This is the representation of request and response URLs from users or the Archiver API

type ArchiverBot

type ArchiverBot struct {
	DB     *gorm.DB
	DG     *discordgo.Session
	Config ArchiverBotConfig
}

Handlers ArchiverBot is the main type passed around throughout the code It has many functions for overall bot management

func (*ArchiverBot) BotReadyHandler

func (bot *ArchiverBot) BotReadyHandler(s *discordgo.Session, r *discordgo.Ready)

BotReadyHandler is called when the bot is considered ready to use the Discord session

func (*ArchiverBot) GuildCreateHandler

func (bot *ArchiverBot) GuildCreateHandler(s *discordgo.Session, gc *discordgo.GuildCreate)

GuildCreateHandler is called whenever the bot joins a new guild.

func (*ArchiverBot) GuildDeleteHandler

func (bot *ArchiverBot) GuildDeleteHandler(s *discordgo.Session, gd *discordgo.GuildDelete)

GuildDeleteHandler is called whenever the bot leaves a guild.

func (*ArchiverBot) InteractionHandler

func (bot *ArchiverBot) InteractionHandler(s *discordgo.Session, i *discordgo.InteractionCreate)

InteractionInit configures all interactive commands

func (*ArchiverBot) MessageReactionAddHandler

func (bot *ArchiverBot) MessageReactionAddHandler(s *discordgo.Session, r *discordgo.MessageReactionAdd)

This function will be called every time a new react is created on any message that the authenticated bot has access to

func (*ArchiverBot) SettingsIntegrationResponse

func (bot *ArchiverBot) SettingsIntegrationResponse(sc ServerConfig) *discordgo.InteractionResponseData

SettingsIntegrationResponse returns server settings in a *discordgo.InteractionResponseData

func (ArchiverBot) StartHealthAPI

func (b ArchiverBot) StartHealthAPI()

type ArchiverBotConfig

type ArchiverBotConfig struct {
	AdminIds   []string `env:"ADMINISTRATOR_IDS"`
	DBHost     string   `env:"DB_HOST"`
	DBName     string   `env:"DB_NAME"`
	DBPassword string   `env:"DB_PASSWORD"`
	DBUser     string   `env:"DB_USER"`
	LogLevel   string   `env:"LOG_LEVEL"`
	Token      string   `env:"TOKEN"`
	Cookie     string   `env:"COOKIE"`
}

ArchiverBotConfig is attached to ArchiverBot so config settings can be accessed easily

type ServerConfig

type ServerConfig struct {
	DiscordId          string         `gorm:"primaryKey;uniqueIndex" pretty:"Server ID"`
	Name               string         `pretty:"Server Name" gorm:"default:default"`
	ArchiveEnabled     sql.NullBool   `pretty:"Bot enabled" gorm:"default:true"`
	AlwaysArchiveFirst sql.NullBool   `pretty:"Archive the page first (slower)" gorm:"default:false"`
	ShowDetails        sql.NullBool   `pretty:"Show extra details" gorm:"default:true"`
	RetryAttempts      sql.NullInt32  `pretty:"Number of times to retry calling archive.org" gorm:"default:1"`
	RemoveRetriesDelay sql.NullInt32  `pretty:"Seconds to wait to remove retry button" gorm:"default:30"`
	UTCOffset          sql.NullInt32  `pretty:"UTC Offset" gorm:"default:4"`
	UTCSign            sql.NullString `pretty:"UTC Sign (Negative if west of Greenwich)" gorm:"default:-"`
	UpdatedAt          time.Time
}

type ServerRegistration

type ServerRegistration struct {
	DiscordId string `gorm:"primaryKey;uniqueIndex"`
	Name      string
	UpdatedAt time.Time
	JoinedAt  time.Time
	Active    sql.NullBool `pretty:"Bot is active in the server" gorm:"default:true"`
	Config    ServerConfig `gorm:"foreignKey:DiscordId"`
}

Servers

Jump to

Keyboard shortcuts

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