bot

package
v0.0.0-...-7a87904 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Amputation

type Amputation struct {
	CreatedAt           time.Time
	UUID                string `gorm:"primaryKey"`
	AmputationEventUUID string
	ServerID            string
	RequestURL          string
	RequestDomainName   string
	ResponseURL         string
	ResponseDomainName  string
	Cached              bool
}

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

type AmputationEvent

type AmputationEvent struct {
	CreatedAt      time.Time
	UUID           string `gorm:"primaryKey"`
	AuthorId       string
	AuthorUsername string
	ChannelId      string
	MessageId      string
	ServerID       string
	Amputations    []Amputation `gorm:"foreignKey:AmputationEventUUID"`
}

Every successful AmputationEvent will come from a message.

type AmputatorBot

type AmputatorBot struct {
	DB         *gorm.DB
	DG         *discordgo.Session
	Config     AmputatorBotConfig
	StartingUp bool
}

func (*AmputatorBot) BotReady

func (bot *AmputatorBot) BotReady(s *discordgo.Session, r *discordgo.Ready)

BotReady is called when the bot is considered ready to use the Discord session.

func (*AmputatorBot) GuildCreate

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

GuildCreate is called whenever the bot joins a new guild. It is also lazily called upon initial connection to Discord.

func (*AmputatorBot) MessageCreate

func (bot *AmputatorBot) MessageCreate(s *discordgo.Session, m *discordgo.MessageCreate)

This function will be called (due to AddHandler above) every time a new message is created on any channel that the authenticated bot has access to.

func (AmputatorBot) StartHealthAPI

func (b AmputatorBot) StartHealthAPI()

type AmputatorBotConfig

type AmputatorBotConfig 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"`
}

type MessageEvent

type MessageEvent struct {
	CreatedAt        time.Time
	UUID             string `gorm:"primaryKey"`
	AuthorId         string
	AuthorUsername   string
	MessageId        string
	Command          string
	ChannelId        string
	ServerID         string
	AmputationEvents []AmputationEvent `gorm:"foreignKey:UUID"`
}

A MessageEvent is created when we receive a message that requires our attention

type ServerConfig

type ServerConfig struct {
	DiscordId              string `gorm:"primaryKey" pretty:"Server ID"`
	Name                   string `pretty:"Server Name"`
	AmputationEnabled      bool   `pretty:"Amputation Enabled"`
	ReplyToOriginalMessage bool   `pretty:"Reply to original message"`
	UseEmbed               bool   `pretty:"Use embed to reply"`
	GuessAndCheck          bool   `pretty:"Guess at AMP URLs if they are difficult"`
	MaxDepth               int    `pretty:"How many links deep to go to try to find the non-AMP link"`
}

type ServerRegistration

type ServerRegistration struct {
	DiscordId string `gorm:"primaryKey"`
	Name      string
	UpdatedAt time.Time
	Config    ServerConfig `gorm:"foreignKey:DiscordId"`
}

Jump to

Keyboard shortcuts

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