Documentation ¶
Index ¶
- Constants
- Variables
- type APITokenEntry
- type AccessToken
- type Birthday
- type Cache
- type CacheLifetimes
- type CacheRedis
- type Captcha
- type CodeExec
- type CodeExecRanna
- type Config
- type Contact
- type DatabaseCreds
- type DatabaseType
- type Discord
- type Giphy
- type GuildAPISettings
- type GuildKarma
- type GuildLogEntry
- type GuildLogSeverity
- type HealthcheckResponse
- type HealthcheckStatus
- type JoinLogEntry
- type KarmaAction
- type KarmaRule
- type KarmaTriggerType
- type LandingPage
- type Logging
- type LokiLogging
- type Metrics
- type Permissions
- type Privacy
- type Ratelimit
- type Report
- type ReportType
- type RoleSelect
- type Schedules
- type Sharding
- type StarboardConfig
- type StarboardEntry
- type StarboardSortBy
- type StorageFile
- type StorageMinio
- type StorageType
- type TwitchApp
- type UnbanRequest
- type UnbanRequestState
- type VerificationQueueEntry
- type WebServer
- type WebServerTLS
Constants ¶
const UnbanRequestCooldown = 14 * 24 * time.Hour // 14 days
Variables ¶
var ( ReportTypes = []string{ "KICK", "BAN", "MUTE", "WARN", "AD", "UNBAN ACCEPTED", "UNBAN REJECTED", } ReportColors = []int{ 0xD81B60, 0xe53935, 0x009688, 0xFB8C00, 0x8E24AA, 0x18dd8e, 0x9518dd, } )
var DefaultConfig = Config{ Version: 6, Discord: Discord{ GeneralPrefix: "sp!", GlobalCommandRateLimit: Ratelimit{ Enabled: true, Burst: 5, LimitSeconds: 3, }, }, Permissions: Permissions{ DefaultUserRules: static.DefaultUserRules, DefaultAdminRules: static.DefaultAdminRules, }, Database: DatabaseType{ Type: "mysql", MySql: DatabaseCreds{}, }, Cache: Cache{ Redis: CacheRedis{ Addr: "localhost:6379", Password: "", Type: 0, }, CacheDatabase: true, }, Logging: Logging{ CommandLogging: true, LogLevel: "info", }, TwitchApp: TwitchApp{}, Storage: StorageType{ Type: "file", File: StorageFile{ Location: "./data", }, Minio: StorageMinio{ Location: "us-east-1", Secure: true, }, }, WebServer: WebServer{ Enabled: true, Addr: ":8080", APITokenKey: random.MustGetRandBase64Str(32), PublicAddr: "https://example.com:8080", TLS: WebServerTLS{ Enabled: false, }, AccessToken: AccessToken{ Secret: random.MustGetRandBase64Str(64), LifetimeSeconds: 10 * 60, }, LandingPage: LandingPage{ ShowLocalInvite: true, ShowPublicInvites: true, }, RateLimit: Ratelimit{ Enabled: false, Burst: 30, LimitSeconds: 3, }, }, Metrics: Metrics{ Enable: false, Addr: ":9091", }, Schedules: Schedules{ GuildBackups: "0 0 6,18 * * *", RefreshTokenCleanup: "0 0 5 * * *", ReportsExpiration: "@every 5m", VerificationKick: "@every 1h", }, CodeExec: CodeExec{ Type: "jdoodle", Ranna: CodeExecRanna{ ApiVersion: "v1", }, RateLimit: Ratelimit{ Enabled: true, Burst: 5, LimitSeconds: 60, }, }, }
Functions ¶
This section is empty.
Types ¶
type APITokenEntry ¶
type AccessToken ¶
type AccessToken struct { Secret string `json:"secret"` LifetimeSeconds int `json:"lifetimeseconds"` }
AccessToken holds the secret and lifetime for JWT access token signature.
type Cache ¶
type Cache struct { Redis CacheRedis `json:"redis"` CacheDatabase bool `json:"cachedatabase"` Lifetimes CacheLifetimes `json:"lifetimes"` }
Cache holds the preferences for caching services.
type CacheLifetimes ¶
type CacheLifetimes struct { General, Guild, Member, User, Role, Channel, Emoji, Message, VoiceState, Presence string }
CacheLifetimes holds a list of duration strings which will later get parsed into durations for caching lifetimes.
type CacheRedis ¶
type CacheRedis struct { Addr string `json:"addr"` Password string `json:"password"` Type int `json:"type"` // Deprecated. Just here for downwards compatibility. Enable bool `json:"enable"` }
CacheRedis holds credentials and settings to connect to a Redis instance.
type CodeExec ¶
type CodeExec struct { Type string `json:"type"` Ranna CodeExecRanna `json:"ranna"` RateLimit Ratelimit `json:"ratelimit"` }
CodeExec wraps configurations for the code execution API used.
type CodeExecRanna ¶
type CodeExecRanna struct { Token string `json:"token"` Endpoint string `json:"endpoint"` ApiVersion string `json:"apiversion"` }
CodeExecRanna holds configuration values for ranna as code execution engine.
type Config ¶
type Config struct { Version int `json:"configVersionPleaseDoNotChange"` Discord Discord `json:"discord"` Permissions Permissions `json:"permissions"` Database DatabaseType `json:"database"` Cache Cache `json:"cache"` Logging Logging `json:"logging"` TwitchApp TwitchApp `json:"twitchapp"` Storage StorageType `json:"storage"` WebServer WebServer `json:"webserver"` Metrics Metrics `json:"metrics"` Schedules Schedules `json:"schedules"` CodeExec CodeExec `json:"codeexec"` Giphy Giphy `json:"giphy"` Privacy Privacy `json:"privacy"` }
Config wraps the whole configuration structure including a version, which must not be changed by users to identify the integrity of config files over version updates.
type Contact ¶
type Contact struct { Title string `json:"title"` Value string `json:"value"` URL string `json:"url,omitempty"` }
Contact holds contact information.
type DatabaseCreds ¶
type DatabaseCreds struct { Host string `json:"host"` User string `json:"user"` Password string `json:"password"` Database string `json:"database"` }
DatabaseCreds holds credentials to connect to a generic database.
type DatabaseType ¶
type DatabaseType struct { Type string `json:"type"` MySql DatabaseCreds `json:"mysql"` Redis CacheRedis `json:"redis"` }
DatabaseType holds the preference for which database module to be used and the seperate "slots" for database configurations.
type Discord ¶
type Discord struct { Token string `json:"token"` GeneralPrefix string `json:"generalprefix"` OwnerID string `json:"ownerid"` ClientID string `json:"clientid"` ClientSecret string `json:"clientsecret"` GuildBackupLoc string `json:"guildbackuploc"` GlobalCommandRateLimit Ratelimit `json:"globalcommandratelimit"` DisabledCommands []string `json:"disabledcommands"` Sharding Sharding `json:"sharding"` GuildsLimit int `json:"guildslimit"` }
Discord holds general configurations to connect to the Discord API application and using the OAuth2 workflow for web frontend authorization.
type Giphy ¶
type Giphy struct {
APIKey string `json:"apikey"`
}
Giphy holds credentials and configuration to connect to the Giphy.com API.
type GuildAPISettings ¶
type GuildAPISettings struct { Enabled bool `json:"enabled"` AllowedOrigins string `json:"allowed_origins"` Protected bool `json:"protected"` TokenHash string `json:"token_hash,omitempty"` }
func (*GuildAPISettings) Hydrate ¶
func (g *GuildAPISettings) Hydrate() *GuildAPISettings
type GuildKarma ¶
type GuildLogEntry ¶
type GuildLogSeverity ¶
type GuildLogSeverity int
const ( GLAll GuildLogSeverity = iota - 1 GLDebug GLInfo GLWarn GLError GLFatal )
type HealthcheckResponse ¶
type HealthcheckResponse struct { Database HealthcheckStatus `json:"database"` Storage HealthcheckStatus `json:"storage"` Redis HealthcheckStatus `json:"redis"` Discord HealthcheckStatus `json:"discord"` AllOk bool `json:"all_ok"` }
type HealthcheckStatus ¶
func HealthcheckStatusFromError ¶
func HealthcheckStatusFromError(err error) HealthcheckStatus
type JoinLogEntry ¶
type KarmaAction ¶
type KarmaAction string
const ( KarmaActionToggleRole KarmaAction = "TOGGLE_ROLE" KarmaActionKick KarmaAction = "KICK" KarmaActionBan KarmaAction = "BAN" KarmaActionSendMessage KarmaAction = "SEND_MESSAGE" )
func (KarmaAction) Validate ¶
func (a KarmaAction) Validate() bool
type KarmaRule ¶
type KarmaRule struct { ID snowflake.ID `json:"id"` GuildID string `json:"guildid"` Trigger KarmaTriggerType `json:"trigger"` Value int `json:"value"` Action KarmaAction `json:"action"` Argument string `json:"argument"` Checksum string `json:"-"` }
func (*KarmaRule) CalculateChecksum ¶
type KarmaTriggerType ¶
type KarmaTriggerType int
const ( KarmaTriggerBelow KarmaTriggerType = iota KarmaTriggerAbove )
func (KarmaTriggerType) Validate ¶
func (tt KarmaTriggerType) Validate() bool
type LandingPage ¶
type LandingPage struct { ShowPublicInvites bool `json:"showpublicinvites"` ShowLocalInvite bool `json:"showlocalinvite"` }
LandingPage wraps the settings for the web interfaces landing page.
type Logging ¶
type Logging struct { CommandLogging bool `json:"commandlogging"` LogLevel string `json:"loglevel"` // can be string or int Loki LokiLogging `json:"loki"` }
Logging holds configuration values for the main logger.
type LokiLogging ¶
type LokiLogging struct { Enabled bool `json:"enabled"` lokiwriter.Options }
LokiLogging holds configuration to push logs to a loki instance.
type Permissions ¶
type Permissions struct { DefaultUserRules []string `json:"defaultuserrules"` DefaultAdminRules []string `json:"defaultadminrules"` }
Permissions wrap standard rulesets for specific user groups like guild admins and default users with no special previleges.
type Ratelimit ¶
type Ratelimit struct { Enabled bool `json:"enabled"` Burst int `json:"burst"` LimitSeconds int `json:"limitseconds"` }
Ratelimit wraps generic rate limit configuration.
type Report ¶
type Report struct { ID snowflake.ID `json:"id"` Type ReportType `json:"type"` GuildID string `json:"guild_id"` ExecutorID string `json:"executor_id"` VictimID string `json:"victim_id"` Msg string `json:"message"` AttachmentURL string `json:"attachment_url"` Timeout *time.Time `json:"timeout"` Anonymous bool `json:"-"` }
Report describes a report object.
func (*Report) AsEmbed ¶
func (r *Report) AsEmbed(publicAddr string) *discordgo.MessageEmbed
AsEmbed creates a discordgo.Embed from the report. publicAddr is passed to generate a public link for a potential report attachment to be displayed in the embeds image section.
func (*Report) AsEmbedField ¶
func (r *Report) AsEmbedField(publicAddr string) *discordgo.MessageEmbedField
AsEmbedField creates a discordgo.MessageEmbedField from the report. publicAddr is passed to generate a publicly available link embedded in the embed field.
func (*Report) GetTimestamp ¶
GetTimestamp returns the timestamp when the report was generated from the reports ID snowflake.
type ReportType ¶
type ReportType int
const ( TypeKick ReportType = iota TypeBan TypeMute TypeWarn TypeAd TypeUnban TypeUnbanRejected TypeMax = iota - 1 )
func TypeFromString ¶
func TypeFromString(s string) (typ ReportType, err error)
type RoleSelect ¶
type Schedules ¶
type Schedules struct { GuildBackups string `json:"guildbackups"` RefreshTokenCleanup string `json:"refreshtokencleanup"` ReportsExpiration string `json:"reportsexpiration"` VerificationKick string `json:"verificationkick"` }
Schedules holds cron-like job schedule specifications for continuously running jobs.
type Sharding ¶
type Sharding struct { AutoID bool `json:"autoid"` ID int `json:"id"` Pool int `json:"pool"` Total int `json:"total"` }
Sharding holds configuration for guild event sharding.
type StarboardConfig ¶
type StarboardEntry ¶
type StarboardEntry struct { MessageID string `json:"message_id"` StarboardID string `json:"starboard_id"` GuildID string `json:"guild_id"` ChannelID string `json:"channel_id"` AuthorID string `json:"author_id"` Content string `json:"content"` MediaURLs []string `json:"media_urls"` Score int `json:"score"` Deleted bool `json:"-"` }
func (*StarboardEntry) MediaURLsEncoded ¶
func (e *StarboardEntry) MediaURLsEncoded() string
func (*StarboardEntry) SetMediaURLs ¶
func (e *StarboardEntry) SetMediaURLs(encoded string) (err error)
type StarboardSortBy ¶
type StarboardSortBy int
const ( StarboardSortByLatest StarboardSortBy = iota StarboardSortByMostRated )
type StorageFile ¶
type StorageFile struct {
Location string `json:"location"`
}
StorageFile holds preferences for a local file storage provider.
type StorageMinio ¶
type StorageMinio struct { Endpoint string `json:"endpoint"` AccessKey string `json:"accesskey"` AccessSecret string `json:"accesssecret"` Location string `json:"location"` Secure bool `json:"secure"` }
StorageMinio holds connection preferences to conenct to a storage provider like MinIO, Amazon S3 or Google Cloud.
type StorageType ¶
type StorageType struct { Type string `json:"type"` Minio StorageMinio `json:"minio"` File StorageFile `json:"file"` }
StorageType holds the preferences for which storage type is to be used and "slots" for the specific configuration of them.
type TwitchApp ¶
type TwitchApp struct { ClientID string `json:"clientid"` ClientSecret string `json:"clientsecret"` }
TwitchApp holds credentials to connect to a Twitch API application.
type UnbanRequest ¶
type UnbanRequest struct { ID snowflake.ID `json:"id"` UserID string `json:"user_id"` GuildID string `json:"guild_id"` UserTag string `json:"user_tag"` Message string `json:"message"` Status UnbanRequestState `json:"status"` ProcessedBy string `json:"processed_by"` Processed time.Time `json:"processed"` ProcessedMessage string `json:"processed_message"` Created time.Time `json:"created"` ReportID snowflake.ID `json:"reportID"` }
func (*UnbanRequest) Hydrate ¶
func (r *UnbanRequest) Hydrate() *UnbanRequest
func (*UnbanRequest) Validate ¶
func (r *UnbanRequest) Validate() error
type UnbanRequestState ¶
type UnbanRequestState int
const ( UnbanRequestStatePending UnbanRequestState = iota UnbanRequestStateDeclined UnbanRequestStateAccepted )
type VerificationQueueEntry ¶
type WebServer ¶
type WebServer struct { Enabled bool `json:"enabled"` Addr string `json:"addr"` TLS WebServerTLS `json:"tls"` APITokenKey string `json:"apitokenkey"` PublicAddr string `json:"publicaddr"` LandingPage LandingPage `json:"landingpage"` DebugPublicAddr string `json:"debugpublicaddr,omitempty"` RateLimit Ratelimit `json:"ratelimit"` Captcha Captcha `json:"captcha"` AccessToken AccessToken `json:"accesstoken"` }
WebServer holds general configurations for the exposed web server.
type WebServerTLS ¶
type WebServerTLS struct { Enabled bool `json:"enabled"` Cert string `json:"certfile"` Key string `json:"keyfile"` }
WebServerTLS wraps preferences for the TLS configuration of the web server.