util

package
v0.0.0-...-f4937b0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const ZeroWidth = "\u200B"

Variables

View Source
var NumberRegex = regexp.MustCompile(`[0-9]*[.]?[0-9]+`)
View Source
var RoleIdRegex = regexp.MustCompile(`^(?:<@&!?)?(\d+)>?$`)
View Source
var SnowflakeRegex = regexp.MustCompile(`([0-9]{17,19})`)
View Source
var TimeRegex = map[int64]*regexp.Regexp{
	1:        regexp.MustCompile(`(\d+)s`),
	60:       regexp.MustCompile(`(\d+)m`),
	3600:     regexp.MustCompile(`(\d+)h`),
	86400:    regexp.MustCompile(`(\d+)d`),
	604800:   regexp.MustCompile(`(\d+)w`),
	2628000:  regexp.MustCompile(`(\d+)mo`),
	31536000: regexp.MustCompile(`(\d+)y`),
}

seconds to regex for the string of it, makes iteration easier as you can use k as the multiplier for v

View Source
var UserIdRegex = regexp.MustCompile(`^(?:<@!?)?(\d+)>?$`)
View Source
var UuidRegex = regexp.MustCompile(`\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b`)

Functions

func CalcStats

func CalcStats(s *discordgo.Session)

func CheckForImage

func CheckForImage(m *discordgo.Message) bool

func CheckForVideo

func CheckForVideo(m *discordgo.Message) bool

func FilteredCommand

func FilteredCommand(input string) (output string)

func FilteredTrigger

func FilteredTrigger(input string) (output string)

func GetClosestLevel

func GetClosestLevel(i []int64, targetLevel int64) int64

Gets the closest level that the ideal level can match in the level -> interface map

func IsDevInstance

func IsDevInstance(s *discordgo.Session) bool

func MakeCompleteCensorStruct

func MakeCompleteCensorStruct(automod *structs.Automod, channelID string, userLevel int64) (combined *structs.Censor)

func MakeCompleteSpamStruct

func MakeCompleteSpamStruct(automod *structs.Automod, channelID string, userLevel int64) (combined *structs.Spam)

func MakeReason

func MakeReason(conf *structs.Config, guildId, userId, module, function, trigger string) (reason string)

func ParseTime

func ParseTime(strTime string) int64

returns a int64 unix timestamp representative of a time string

func ReplaceReasonVariable

func ReplaceReasonVariable(conf *structs.Config, strikes []*db.Action, reason string, variable ReasonVariable, module, function, trigger string) string

func SnowflakeToTimestamp

func SnowflakeToTimestamp(userId string) time.Time

Types

type ReasonVariable

type ReasonVariable string
var (
	ReasonVariableModule               ReasonVariable = "{{module}}"
	ReasonVariableFunction             ReasonVariable = "{{function}}"
	ReasonVariableTrigger              ReasonVariable = "{{trigger}}"
	ReasonVariableTriggerCensored      ReasonVariable = "{{trigger_censored}}"
	ReasonVariableStrikeNo             ReasonVariable = "{{strike_no}}"
	ReasonVariableStrikesUntil         ReasonVariable = "{{strikes_until}}"
	ReasonVariableNextPunishment       ReasonVariable = "{{next_punishment}}"
	ReasonVariableNextPunishmentLength ReasonVariable = "{{next_punishment_length}}"
)

Jump to

Keyboard shortcuts

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