automod

package
v2.38.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 49 Imported by: 0

README ¶

This is version 2 of YAGPDB automoderator, v1 was scrapped and is deprecated, this version has been made from scratch and its goal is to be much more flexible and capable.

Quick design brainstorm:

  • Servers can create several rulesets
  • Rulesets contains sets of rules
  • Rules contains a set of conditions that all need to be met and another set of effects that will be executed once all the conditions for the rule are met
  • Infringement counters can either be ruleset scoped, global scoped, or custom key scoped (also either ruleset or global scoped, per user or per channel etc as well maybe?)
  • With this you could have a stricter set of automod rules for new users, and and more soft one for "trusted" long time members
  • You should be able to toggle rulesets on with commands, so if you need to slow down a channel or a raid is in progress, you can employ very strict automod rules via a single command invocation

Basic structure, with some example effects and conditions

Ruleset settings:

  • enabled
  • general user specific filters
  • general channel specific filters

Ruleset Rules:

  • Rule 1
    • Conditions (They all need to match):
      • ex: Send x messages within x seconds
      • filter: general user specific filters
      • filter: general channel specific filters
    • Effects applied once the conditions for the rule is met:
      • Increment (ruleset based | global | custom key based "key here") infringement counter and apply proper punishments.
      • (Create channel logs | log message in channel x)
      • Delete message
      • Could also apply a direct mute here for example, without setting up punishments?
  • Rule 2
    • ...

Ruleset punishments:

  • Punishment 1
    • Conditions:
      • (ruleset based | global | custom key based "key here") infringements within x, higher than or equal to x
      • general user specific filters
      • only apply once per x interval
      • punishment x
    • Punishments:
      • mute, kick, ban, lost role, etc...

General user specific filters:

  • role whitelist/blacklist
  • account/member age
  • bot?

General channel specific filters:

  • direct whitelist/blacklist
  • category whitelist/blacklist

Documentation ¶

Index ¶

Constants ¶

View Source
const (
	MaxMessageTriggers        = 20
	MaxMessageTriggersPremium = 100

	MaxViolationTriggers        = 20
	MaxViolationTriggersPremium = 100

	MaxTotalRules        = 25
	MaxTotalRulesPremium = 150

	MaxLists        = 5
	MaxListsPremium = 25

	MaxRuleParts = 25

	MaxRulesets        = 10
	MaxRulesetsPremium = 25
)
View Source
const (
	SettingTypeRole                   = "role"
	SettingTypeMultiRole              = "multi_role"
	SettingTypeChannel                = "channel"
	SettingTypeMultiChannel           = "multi_channel"
	SettingTypeMultiChannelCategories = "multi_channel_cat"
	SettingTypeInt                    = "int"
	SettingTypeString                 = "string"
	SettingTypeBool                   = "bool"
	SettingTypeList                   = "list"
)

Variables ¶

View Source
var DBSchemas = []string{`
CREATE TABLE IF NOT EXISTS automod_rulesets (
	id BIGSERIAL PRIMARY KEY,
	guild_id BIGINT NOT NULL,

	name TEXT NOT NULL,
	enabled BOOLEAN NOT NULL
);
`, `
CREATE INDEX IF NOT EXISTS automod_rulesets_guild_idx ON automod_rulesets(guild_id);


`, `
CREATE TABLE IF NOT EXISTS automod_rules (
	id BIGSERIAL PRIMARY KEY,
	guild_id BIGINT NOT NULL,
	ruleset_id BIGINT references automod_rulesets(id) ON DELETE CASCADE NOT NULL,
	name TEXT NOT NULL,
	trigger_counter BIGINT NOT NULL
);

`, `
CREATE INDEX IF NOT EXISTS automod_rules_guild_idx ON automod_rules(guild_id);

`, `
CREATE INDEX IF NOT EXISTS automod_rules_ruleset_idx ON automod_rules(ruleset_id);

`, `
CREATE TABLE IF NOT EXISTS automod_rule_data (
	id BIGSERIAL PRIMARY KEY,
	guild_id BIGINT NOT NULL,
	rule_id BIGINT references automod_rules(id) ON DELETE CASCADE NOT NULL,

	kind int NOT NULL,
	type_id INT NOT NULL,
	settings JSONB NOT NULL
);

`, `
CREATE INDEX IF NOT EXISTS automod_rule_data_guild_idx ON automod_rule_data(guild_id);

`, `
CREATE TABLE IF NOT EXISTS automod_ruleset_conditions (
	id BIGSERIAL PRIMARY KEY,
	guild_id BIGINT NOT NULL,
	ruleset_id BIGINT references automod_rulesets(id) ON DELETE CASCADE NOT NULL,

	kind int NOT NULL,
	type_id INT NOT NULL,
	settings JSONB NOT NULL
);

`, `
CREATE INDEX IF NOT EXISTS automod_ruleset_conditions_guild_idx ON automod_ruleset_conditions(guild_id);

`, `
CREATE INDEX IF NOT EXISTS automod_ruleset_conditions_ruleset_idx ON automod_ruleset_conditions(ruleset_id);

`, `
CREATE TABLE IF NOT EXISTS automod_violations (
	id BIGSERIAL PRIMARY KEY,
	guild_id BIGINT NOT NULL,
	user_id BIGINT NOT NULL,
	rule_id BIGINT references automod_rules(id) ON DELETE SET NULL,

	created_at TIMESTAMP WITH TIME ZONE NOT NULL,

	name TEXT NOT NULL
);

`, `
CREATE INDEX IF NOT EXISTS automod_violations_guild_idx ON automod_violations(guild_id);
`, `
CREATE INDEX IF NOT EXISTS automod_violations_user_idx ON automod_violations(user_id);

`, `
CREATE TABLE IF NOT EXISTS automod_lists (
	id BIGSERIAL PRIMARY KEY,
	guild_id BIGINT NOT NULL,

	name TEXT NOT NULL,
	kind INT NOT NULL,
	content TEXT[] NOT NULL
);

`, `
CREATE INDEX IF NOT EXISTS automod_lists_guild_idx ON automod_lists(guild_id);

`, `
CREATE TABLE IF NOT EXISTS automod_triggered_rules (
	id BIGSERIAL PRIMARY KEY,
	created_at TIMESTAMP WITH TIME ZONE NOT NULL,
	channel_id BIGINT NOT NULL,
	channel_name TEXT NOT NULL,
	guild_id BIGINT NOT NULL,

	trigger_id BIGINT references automod_rule_data(id) ON DELETE SET NULL,
	trigger_typeid INT NOT NULL, -- backup in case the actual trigger was deleted
	
	rule_id BIGINT references automod_rules(id) ON DELETE SET NULL,
	rule_name TEXT NOT NULL, -- backup in case the rule was deleted
	ruleset_name TEXT NOT NULL,

	user_id BIGINT NOT NULL,
	user_name TEXT NOT NULL,

	extradata JSONB NOT NULL 
);
`, `

CREATE INDEX IF NOT EXISTS automod_triggered_rules_guild_idx ON automod_triggered_rules(guild_id);
`, `
CREATE INDEX IF NOT EXISTS automod_triggered_rules_rule_id_idx on automod_triggered_rules(rule_id);
`, `
CREATE INDEX IF NOT EXISTS automod_triggered_rules_trigger_idx ON automod_triggered_rules(trigger_id);
`}
View Source
var ErrListNotFound = errors.New("list not found")
View Source
var InverseRulePartMap = make(map[RulePart]int)
View Source
var PageHTML string
View Source
var (
	RegexCache *ccache.Cache
)
View Source
var RulePartList = make([]*RulePartPair, 0)
View Source
var RulePartMap = map[int]RulePart{

	1:  &AllCapsTrigger{},
	2:  &MentionsTrigger{},
	3:  &AnyLinkTrigger{},
	4:  &ViolationsTrigger{},
	5:  &WordListTrigger{Blacklist: true},
	6:  &WordListTrigger{Blacklist: false},
	7:  &DomainTrigger{Blacklist: true},
	8:  &DomainTrigger{Blacklist: false},
	9:  &ServerInviteTrigger{},
	10: &GoogleSafeBrowsingTrigger{},
	11: &SlowmodeTrigger{ChannelBased: false},
	12: &SlowmodeTrigger{ChannelBased: true},
	13: &MultiMsgMentionTrigger{ChannelBased: false},
	14: &MultiMsgMentionTrigger{ChannelBased: true},
	15: &MessageRegexTrigger{},
	16: &MessageRegexTrigger{BaseRegexTrigger: BaseRegexTrigger{Inverse: true}},
	17: &SpamTrigger{},
	18: &NicknameRegexTrigger{BaseRegexTrigger: BaseRegexTrigger{Inverse: false}},
	19: &NicknameRegexTrigger{BaseRegexTrigger: BaseRegexTrigger{Inverse: true}},
	20: &NicknameWordlistTrigger{Blacklist: false},
	21: &NicknameWordlistTrigger{Blacklist: true},
	22: &SlowmodeTrigger{Attachments: true, ChannelBased: false},
	23: &SlowmodeTrigger{Attachments: true, ChannelBased: true},
	24: &UsernameWordlistTrigger{Blacklist: false},
	25: &UsernameWordlistTrigger{Blacklist: true},
	26: &UsernameRegexTrigger{BaseRegexTrigger{Inverse: false}},
	27: &UsernameRegexTrigger{BaseRegexTrigger{Inverse: true}},
	29: &UsernameInviteTrigger{},
	30: &MemberJoinTrigger{},
	31: &MessageAttachmentTrigger{},
	32: &MessageAttachmentTrigger{RequiresAttachment: true},
	33: &AntiPhishingLinkTrigger{},
	34: &MessageLengthTrigger{},
	35: &MessageLengthTrigger{Inverted: true},
	36: &SlowmodeTrigger{Links: true, ChannelBased: false},
	37: &SlowmodeTrigger{Links: true, ChannelBased: true},
	38: &AutomodExecution{},

	200: &MemberRolesCondition{Blacklist: true},
	201: &MemberRolesCondition{Blacklist: false},
	202: &ChannelsCondition{Blacklist: true},
	203: &ChannelsCondition{Blacklist: false},
	204: &AccountAgeCondition{Below: false},
	205: &AccountAgeCondition{Below: true},
	206: &MemberAgecondition{Below: false},
	207: &MemberAgecondition{Below: true},
	209: &BotCondition{Ignore: true},
	210: &BotCondition{Ignore: false},
	211: &ChannelCategoriesCondition{Blacklist: true},
	212: &ChannelCategoriesCondition{Blacklist: false},
	213: &MessageEditedCondition{NewMessage: true},
	214: &MessageEditedCondition{NewMessage: false},
	215: &ThreadCondition{true},
	216: &ThreadCondition{false},

	300: &DeleteMessageEffect{},
	301: &AddViolationEffect{},
	302: &KickUserEffect{},
	303: &BanUserEffect{},
	304: &MuteUserEffect{},
	305: &WarnUserEffect{},
	306: &SetNicknameEffect{},
	307: &ResetViolationsEffect{},
	308: &DeleteMessagesEffect{},
	309: &GiveRoleEffect{},
	311: &EnableChannelSlowmodeEffect{},
	312: &RemoveRoleEffect{},
	313: &SendChannelMessageEffect{},
	314: &TimeoutUserEffect{},
}

maps rule part indentifiers to actual condition types since these are stored in the database, changing the id's would require an update of all the relevant rows so don't do that.

View Source
var SanitizeTextName = "Also match visually similar characters such as \"Ĥéĺĺó\""

Functions ¶

func CheckLimits ¶

func CheckLimits(exec boil.ContextExecutor, rule *models.AutomodRule, tmpl web.TemplateData, parts []*models.AutomodRuleDatum) (newParts []*models.AutomodRuleDatum, ok bool, err error)

func FetchGuildLists ¶

func FetchGuildLists(guildID int64) ([]*models.AutomodList, error)

func FindFetchGuildList ¶

func FindFetchGuildList(guildID int64, listID int64) (*models.AutomodList, error)

func GuildMaxLists ¶

func GuildMaxLists(guildID int64) int

func GuildMaxMessageTriggers ¶

func GuildMaxMessageTriggers(guildID int64) int

func GuildMaxRulesets ¶

func GuildMaxRulesets(guildID int64) int

func GuildMaxTotalRules ¶

func GuildMaxTotalRules(guildID int64) int

func GuildMaxViolationTriggers ¶

func GuildMaxViolationTriggers(guildID int64) int

func ParseAllRulePartData ¶

func ParseAllRulePartData(dataModels []*models.AutomodRuleDatum) ([]interface{}, error)

func ParseRulePartData ¶

func ParseRulePartData(model *models.AutomodRuleDatum) (interface{}, error)

func PrepareMessageForWordCheck ¶

func PrepareMessageForWordCheck(input string) string

func ReadRuleRowData ¶

func ReadRuleRowData(guild *dstate.GuildSet, tmpl web.TemplateData, rawData []RuleRowData, form url.Values, namePrefix string) (result []*models.AutomodRuleDatum, validationOK bool, err error)

func RegisterPlugin ¶

func RegisterPlugin()

func WebLoadRuleSettings ¶

func WebLoadRuleSettings(r *http.Request, tmpl web.TemplateData, ruleset *models.AutomodRuleset)

Types ¶

type AccountAgeCondition ¶

type AccountAgeCondition struct {
	Below bool // if true, then blacklist mode, otherwise whitelist mode
}

func (*AccountAgeCondition) DataType ¶

func (ac *AccountAgeCondition) DataType() interface{}

func (*AccountAgeCondition) Description ¶

func (ac *AccountAgeCondition) Description() string

func (*AccountAgeCondition) IsMet ¶

func (ac *AccountAgeCondition) IsMet(data *TriggeredRuleData, settings interface{}) (bool, error)

func (*AccountAgeCondition) Kind ¶

func (ac *AccountAgeCondition) Kind() RulePartType

func (*AccountAgeCondition) MergeDuplicates ¶

func (ac *AccountAgeCondition) MergeDuplicates(data []interface{}) interface{}

func (*AccountAgeCondition) Name ¶

func (ac *AccountAgeCondition) Name() string

func (*AccountAgeCondition) UserSettings ¶

func (ac *AccountAgeCondition) UserSettings() []*SettingDef

type AccountAgeConditionData ¶

type AccountAgeConditionData struct {
	Treshold int
}

type AddViolationEffect ¶

type AddViolationEffect struct{}

func (*AddViolationEffect) Apply ¶

func (vio *AddViolationEffect) Apply(ctxData *TriggeredRuleData, settings interface{}) error

func (*AddViolationEffect) DataType ¶

func (vio *AddViolationEffect) DataType() interface{}

func (*AddViolationEffect) Description ¶

func (vio *AddViolationEffect) Description() (description string)

func (*AddViolationEffect) Kind ¶

func (vio *AddViolationEffect) Kind() RulePartType

func (*AddViolationEffect) Name ¶

func (vio *AddViolationEffect) Name() (name string)

func (*AddViolationEffect) UserSettings ¶

func (vio *AddViolationEffect) UserSettings() []*SettingDef

type AddViolationEffectData ¶

type AddViolationEffectData struct {
	Name string `valid:",1,100,trimspace"`
}

type AllCapsTrigger ¶

type AllCapsTrigger struct{}

func (*AllCapsTrigger) CheckMessage ¶

func (caps *AllCapsTrigger) CheckMessage(triggerCtx *TriggerContext, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string) (bool, error)

func (*AllCapsTrigger) DataType ¶

func (caps *AllCapsTrigger) DataType() interface{}

func (*AllCapsTrigger) Description ¶

func (caps *AllCapsTrigger) Description() string

func (*AllCapsTrigger) Kind ¶

func (caps *AllCapsTrigger) Kind() RulePartType

func (*AllCapsTrigger) MergeDuplicates ¶

func (caps *AllCapsTrigger) MergeDuplicates(data []interface{}) interface{}

func (*AllCapsTrigger) Name ¶

func (caps *AllCapsTrigger) Name() string

func (*AllCapsTrigger) UserSettings ¶

func (caps *AllCapsTrigger) UserSettings() []*SettingDef

type AllCapsTriggerData ¶

type AllCapsTriggerData struct {
	MinLength    int
	Percentage   int
	SanitizeText bool
}

type AntiPhishingLinkTrigger ¶

type AntiPhishingLinkTrigger struct{}

func (*AntiPhishingLinkTrigger) CheckMessage ¶

func (a *AntiPhishingLinkTrigger) CheckMessage(triggerCtx *TriggerContext, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string) (bool, error)

func (*AntiPhishingLinkTrigger) DataType ¶

func (a *AntiPhishingLinkTrigger) DataType() interface{}

func (*AntiPhishingLinkTrigger) Description ¶

func (a *AntiPhishingLinkTrigger) Description() string

func (*AntiPhishingLinkTrigger) Kind ¶

func (*AntiPhishingLinkTrigger) Name ¶

func (a *AntiPhishingLinkTrigger) Name() string

func (*AntiPhishingLinkTrigger) UserSettings ¶

func (a *AntiPhishingLinkTrigger) UserSettings() []*SettingDef

type AnyLinkTrigger ¶

type AnyLinkTrigger struct{}

func (*AnyLinkTrigger) CheckMessage ¶

func (alc *AnyLinkTrigger) CheckMessage(triggerCtx *TriggerContext, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string) (bool, error)

func (*AnyLinkTrigger) DataType ¶

func (alc *AnyLinkTrigger) DataType() interface{}

func (*AnyLinkTrigger) Description ¶

func (alc *AnyLinkTrigger) Description() (description string)

func (*AnyLinkTrigger) Kind ¶

func (alc *AnyLinkTrigger) Kind() RulePartType

func (*AnyLinkTrigger) MergeDuplicates ¶

func (alc *AnyLinkTrigger) MergeDuplicates(data []interface{}) interface{}

func (*AnyLinkTrigger) Name ¶

func (alc *AnyLinkTrigger) Name() (name string)

func (*AnyLinkTrigger) UserSettings ¶

func (alc *AnyLinkTrigger) UserSettings() []*SettingDef

type AutomodExecution ¶ added in v2.25.0

type AutomodExecution struct {
}

func (*AutomodExecution) CheckRuleID ¶ added in v2.25.0

func (am *AutomodExecution) CheckRuleID(triggerCtx *TriggerContext, ruleID int64) (bool, error)

func (*AutomodExecution) DataType ¶ added in v2.25.0

func (am *AutomodExecution) DataType() interface{}

func (*AutomodExecution) Description ¶ added in v2.25.0

func (am *AutomodExecution) Description() (description string)

func (*AutomodExecution) Kind ¶ added in v2.25.0

func (am *AutomodExecution) Kind() RulePartType

func (*AutomodExecution) Name ¶ added in v2.25.0

func (am *AutomodExecution) Name() (name string)

func (*AutomodExecution) UserSettings ¶ added in v2.25.0

func (am *AutomodExecution) UserSettings() []*SettingDef

type AutomodExecutionData ¶ added in v2.25.0

type AutomodExecutionData struct {
	RuleID string
}

type AutomodListener ¶ added in v2.25.0

type AutomodListener interface {
	RulePart

	CheckRuleID(triggerCtx *TriggerContext, ruleID int64) (isAffected bool, err error)
}

AutomodListener is a trigger for when Discord's built in automod kicks in

type BanUserEffect ¶

type BanUserEffect struct{}

func (*BanUserEffect) Apply ¶

func (ban *BanUserEffect) Apply(ctxData *TriggeredRuleData, settings interface{}) error

func (*BanUserEffect) DataType ¶

func (ban *BanUserEffect) DataType() interface{}

func (*BanUserEffect) Description ¶

func (ban *BanUserEffect) Description() (description string)

func (*BanUserEffect) Kind ¶

func (ban *BanUserEffect) Kind() RulePartType

func (*BanUserEffect) MergeDuplicates ¶

func (ban *BanUserEffect) MergeDuplicates(data []interface{}) interface{}

func (*BanUserEffect) Name ¶

func (ban *BanUserEffect) Name() (name string)

func (*BanUserEffect) UserSettings ¶

func (ban *BanUserEffect) UserSettings() []*SettingDef

type BanUserEffectData ¶

type BanUserEffectData struct {
	Duration          int
	CustomReason      string `valid:",0,150,trimspace"`
	MessageDeleteDays int
}

type BaseRegexTrigger ¶

type BaseRegexTrigger struct {
	Inverse bool
}

func (BaseRegexTrigger) DataType ¶

func (r BaseRegexTrigger) DataType() interface{}

func (BaseRegexTrigger) Kind ¶

func (r BaseRegexTrigger) Kind() RulePartType

func (BaseRegexTrigger) UserSettings ¶

func (r BaseRegexTrigger) UserSettings() []*SettingDef

type BaseRegexTriggerData ¶

type BaseRegexTriggerData struct {
	Regex        string `valid:",1,250"`
	SanitizeText bool
}

type BotCondition ¶

type BotCondition struct {
	Ignore bool
}

func (*BotCondition) DataType ¶

func (bc *BotCondition) DataType() interface{}

func (*BotCondition) Description ¶

func (bc *BotCondition) Description() string

func (*BotCondition) IsMet ¶

func (bc *BotCondition) IsMet(data *TriggeredRuleData, settings interface{}) (bool, error)

func (*BotCondition) Kind ¶

func (bc *BotCondition) Kind() RulePartType

func (*BotCondition) MergeDuplicates ¶

func (bc *BotCondition) MergeDuplicates(data []interface{}) interface{}

func (*BotCondition) Name ¶

func (bc *BotCondition) Name() string

func (*BotCondition) UserSettings ¶

func (bc *BotCondition) UserSettings() []*SettingDef

type ChannelCategoriesCondition ¶

type ChannelCategoriesCondition struct {
	Blacklist bool // if true, then blacklist mode, otherwise whitelist mode
}

func (*ChannelCategoriesCondition) DataType ¶

func (cd *ChannelCategoriesCondition) DataType() interface{}

func (*ChannelCategoriesCondition) Description ¶

func (cd *ChannelCategoriesCondition) Description() string

func (*ChannelCategoriesCondition) IsMet ¶

func (cd *ChannelCategoriesCondition) IsMet(data *TriggeredRuleData, settings interface{}) (bool, error)

func (*ChannelCategoriesCondition) Kind ¶

func (*ChannelCategoriesCondition) MergeDuplicates ¶

func (cd *ChannelCategoriesCondition) MergeDuplicates(data []interface{}) interface{}

func (*ChannelCategoriesCondition) Name ¶

func (*ChannelCategoriesCondition) UserSettings ¶

func (cd *ChannelCategoriesCondition) UserSettings() []*SettingDef

type ChannelCategoryConditionData ¶

type ChannelCategoryConditionData struct {
	Categories []int64
}

type ChannelsCondition ¶

type ChannelsCondition struct {
	Blacklist bool // if true, then blacklist mode, otherwise whitelist mode
}

func (*ChannelsCondition) DataType ¶

func (cd *ChannelsCondition) DataType() interface{}

func (*ChannelsCondition) Description ¶

func (cd *ChannelsCondition) Description() string

func (*ChannelsCondition) IsMet ¶

func (cd *ChannelsCondition) IsMet(data *TriggeredRuleData, settings interface{}) (bool, error)

func (*ChannelsCondition) Kind ¶

func (cd *ChannelsCondition) Kind() RulePartType

func (*ChannelsCondition) MergeDuplicates ¶

func (cd *ChannelsCondition) MergeDuplicates(data []interface{}) interface{}

func (*ChannelsCondition) Name ¶

func (cd *ChannelsCondition) Name() string

func (*ChannelsCondition) UserSettings ¶

func (cd *ChannelsCondition) UserSettings() []*SettingDef

type ChannelsConditionData ¶

type ChannelsConditionData struct {
	Channels []int64
}

type Condition ¶

type Condition interface {
	RulePart

	// IsMet is called to check wether this condition is met or not
	IsMet(data *TriggeredRuleData, parsedSettings interface{}) (bool, error)
}

type CreateListData ¶

type CreateListData struct {
	Name string `valid:",1,50"`
}

type CreateRuleData ¶

type CreateRuleData struct {
	Name string `valid:",1,50"`
}

type CreateRulesetData ¶

type CreateRulesetData struct {
	Name string `valid:",1,100"`
}

type CtxKey ¶

type CtxKey int
const (
	CtxKeyCurrentRuleset CtxKey = iota
)

type DeleteMessageEffect ¶

type DeleteMessageEffect struct{}

func (*DeleteMessageEffect) Apply ¶

func (del *DeleteMessageEffect) Apply(ctxData *TriggeredRuleData, settings interface{}) error

func (*DeleteMessageEffect) DataType ¶

func (del *DeleteMessageEffect) DataType() interface{}

func (*DeleteMessageEffect) Description ¶

func (del *DeleteMessageEffect) Description() (description string)

func (*DeleteMessageEffect) Kind ¶

func (del *DeleteMessageEffect) Kind() RulePartType

func (*DeleteMessageEffect) MergeDuplicates ¶

func (del *DeleteMessageEffect) MergeDuplicates(data []interface{}) interface{}

func (*DeleteMessageEffect) Name ¶

func (del *DeleteMessageEffect) Name() (name string)

func (*DeleteMessageEffect) UserSettings ¶

func (del *DeleteMessageEffect) UserSettings() []*SettingDef

type DeleteMessagesEffect ¶

type DeleteMessagesEffect struct{}

func (*DeleteMessagesEffect) Apply ¶

func (del *DeleteMessagesEffect) Apply(ctxData *TriggeredRuleData, settings interface{}) error

func (*DeleteMessagesEffect) DataType ¶

func (del *DeleteMessagesEffect) DataType() interface{}

func (*DeleteMessagesEffect) Description ¶

func (del *DeleteMessagesEffect) Description() (description string)

func (*DeleteMessagesEffect) Kind ¶

func (del *DeleteMessagesEffect) Kind() RulePartType

func (*DeleteMessagesEffect) MergeDuplicates ¶

func (del *DeleteMessagesEffect) MergeDuplicates(data []interface{}) interface{}

func (*DeleteMessagesEffect) Name ¶

func (del *DeleteMessagesEffect) Name() (name string)

func (*DeleteMessagesEffect) UserSettings ¶

func (del *DeleteMessagesEffect) UserSettings() []*SettingDef

type DeleteMessagesEffectData ¶

type DeleteMessagesEffectData struct {
	NumMessages int
	TimeLimit   int
}

type DomainTrigger ¶

type DomainTrigger struct {
	Blacklist bool
}

func (*DomainTrigger) CheckMessage ¶

func (dt *DomainTrigger) CheckMessage(triggerCtx *TriggerContext, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string) (bool, error)

func (*DomainTrigger) DataType ¶

func (dt *DomainTrigger) DataType() interface{}

func (*DomainTrigger) Description ¶

func (dt *DomainTrigger) Description() (description string)

func (*DomainTrigger) Kind ¶

func (dt *DomainTrigger) Kind() RulePartType

func (*DomainTrigger) Name ¶

func (dt *DomainTrigger) Name() (name string)

func (*DomainTrigger) UserSettings ¶

func (dt *DomainTrigger) UserSettings() []*SettingDef

type DomainTriggerData ¶

type DomainTriggerData struct {
	ListID int64
}

type Effect ¶

type Effect interface {
	Apply(ctxData *TriggeredRuleData, settings interface{}) error
}

type EnableChannelSlowmodeEffect ¶

type EnableChannelSlowmodeEffect struct {
	// contains filtered or unexported fields
}

func (*EnableChannelSlowmodeEffect) Apply ¶

func (slow *EnableChannelSlowmodeEffect) Apply(ctxData *TriggeredRuleData, settings interface{}) error

func (*EnableChannelSlowmodeEffect) DataType ¶

func (slow *EnableChannelSlowmodeEffect) DataType() interface{}

func (*EnableChannelSlowmodeEffect) Description ¶

func (slow *EnableChannelSlowmodeEffect) Description() (description string)

func (*EnableChannelSlowmodeEffect) Kind ¶

func (*EnableChannelSlowmodeEffect) Name ¶

func (slow *EnableChannelSlowmodeEffect) Name() (name string)

func (*EnableChannelSlowmodeEffect) UserSettings ¶

func (slow *EnableChannelSlowmodeEffect) UserSettings() []*SettingDef

type EnableChannelSlowmodeEffectData ¶

type EnableChannelSlowmodeEffectData struct {
	Duration  int `valid:",0,604800,trimspace"`
	Ratelimit int `valid:",0,21600,trimspace"`
}

type ErrUnknownTypeID ¶

type ErrUnknownTypeID struct {
	TypeID int
}

func (*ErrUnknownTypeID) Error ¶

func (e *ErrUnknownTypeID) Error() string

type GiveRoleEffect ¶

type GiveRoleEffect struct{}

func (*GiveRoleEffect) Apply ¶

func (gf *GiveRoleEffect) Apply(ctxData *TriggeredRuleData, settings interface{}) error

func (*GiveRoleEffect) DataType ¶

func (gf *GiveRoleEffect) DataType() interface{}

func (*GiveRoleEffect) Description ¶

func (gf *GiveRoleEffect) Description() (description string)

func (*GiveRoleEffect) Kind ¶

func (gr *GiveRoleEffect) Kind() RulePartType

func (*GiveRoleEffect) Name ¶

func (gf *GiveRoleEffect) Name() (name string)

func (*GiveRoleEffect) UserSettings ¶

func (gf *GiveRoleEffect) UserSettings() []*SettingDef

type GiveRoleEffectData ¶

type GiveRoleEffectData struct {
	Duration int `valid:",0,604800,trimspace"`
	Role     int64
}

type GoogleSafeBrowsingTrigger ¶

type GoogleSafeBrowsingTrigger struct{}

func (*GoogleSafeBrowsingTrigger) CheckMessage ¶

func (g *GoogleSafeBrowsingTrigger) CheckMessage(triggerCtx *TriggerContext, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string) (bool, error)

func (*GoogleSafeBrowsingTrigger) DataType ¶

func (g *GoogleSafeBrowsingTrigger) DataType() interface{}

func (*GoogleSafeBrowsingTrigger) Description ¶

func (g *GoogleSafeBrowsingTrigger) Description() string

func (*GoogleSafeBrowsingTrigger) Kind ¶

func (*GoogleSafeBrowsingTrigger) MergeDuplicates ¶

func (g *GoogleSafeBrowsingTrigger) MergeDuplicates(data []interface{}) interface{}

func (*GoogleSafeBrowsingTrigger) Name ¶

func (*GoogleSafeBrowsingTrigger) UserSettings ¶

func (g *GoogleSafeBrowsingTrigger) UserSettings() []*SettingDef

type JoinListener ¶

type JoinListener interface {
	RulePart

	CheckJoin(triggerCtx *TriggerContext) (isAffected bool, err error)
}

JoinListener is triggers that does stuff when members joins

type KickUserEffect ¶

type KickUserEffect struct{}

func (*KickUserEffect) Apply ¶

func (kick *KickUserEffect) Apply(ctxData *TriggeredRuleData, settings interface{}) error

func (*KickUserEffect) DataType ¶

func (kick *KickUserEffect) DataType() interface{}

func (*KickUserEffect) Description ¶

func (kick *KickUserEffect) Description() (description string)

func (*KickUserEffect) Kind ¶

func (kick *KickUserEffect) Kind() RulePartType

func (*KickUserEffect) MergeDuplicates ¶

func (kick *KickUserEffect) MergeDuplicates(data []interface{}) interface{}

func (*KickUserEffect) Name ¶

func (kick *KickUserEffect) Name() (name string)

func (*KickUserEffect) UserSettings ¶

func (kick *KickUserEffect) UserSettings() []*SettingDef

type KickUserEffectData ¶

type KickUserEffectData struct {
	CustomReason string `valid:",0,150,trimspace"`
}

type MemberAgeConditionData ¶

type MemberAgeConditionData struct {
	Treshold int
}

type MemberAgecondition ¶

type MemberAgecondition struct {
	Below bool // if true, then blacklist mode, otherwise whitelist mode
}

func (*MemberAgecondition) DataType ¶

func (mc *MemberAgecondition) DataType() interface{}

func (*MemberAgecondition) Description ¶

func (mc *MemberAgecondition) Description() string

func (*MemberAgecondition) IsMet ¶

func (mc *MemberAgecondition) IsMet(data *TriggeredRuleData, settings interface{}) (bool, error)

func (*MemberAgecondition) Kind ¶

func (mc *MemberAgecondition) Kind() RulePartType

func (*MemberAgecondition) MergeDuplicates ¶

func (mc *MemberAgecondition) MergeDuplicates(data []interface{}) interface{}

func (*MemberAgecondition) Name ¶

func (mc *MemberAgecondition) Name() string

func (*MemberAgecondition) UserSettings ¶

func (mc *MemberAgecondition) UserSettings() []*SettingDef

type MemberJoinTrigger ¶

type MemberJoinTrigger struct {
}

func (*MemberJoinTrigger) CheckJoin ¶

func (mj *MemberJoinTrigger) CheckJoin(t *TriggerContext) (isAffected bool, err error)

func (*MemberJoinTrigger) DataType ¶

func (mj *MemberJoinTrigger) DataType() interface{}

func (*MemberJoinTrigger) Description ¶

func (mj *MemberJoinTrigger) Description() (description string)

func (*MemberJoinTrigger) Kind ¶

func (mj *MemberJoinTrigger) Kind() RulePartType

func (*MemberJoinTrigger) Name ¶

func (mj *MemberJoinTrigger) Name() (name string)

func (*MemberJoinTrigger) UserSettings ¶

func (mj *MemberJoinTrigger) UserSettings() []*SettingDef

type MemberRolesCondition ¶

type MemberRolesCondition struct {
	Blacklist bool // if true, then blacklist mode, otherwise whitelist mode
}

func (*MemberRolesCondition) DataType ¶

func (mrc *MemberRolesCondition) DataType() interface{}

func (*MemberRolesCondition) Description ¶

func (mrc *MemberRolesCondition) Description() string

func (*MemberRolesCondition) IsMet ¶

func (mrc *MemberRolesCondition) IsMet(data *TriggeredRuleData, settings interface{}) (bool, error)

func (*MemberRolesCondition) Kind ¶

func (mrc *MemberRolesCondition) Kind() RulePartType

func (*MemberRolesCondition) MergeDuplicates ¶

func (mrc *MemberRolesCondition) MergeDuplicates(data []interface{}) interface{}

func (*MemberRolesCondition) Name ¶

func (mrc *MemberRolesCondition) Name() string

func (*MemberRolesCondition) UserSettings ¶

func (mrc *MemberRolesCondition) UserSettings() []*SettingDef

type MemberRolesConditionData ¶

type MemberRolesConditionData struct {
	Roles           []int64
	RequireAllRoles bool
}

type MentionsTrigger ¶

type MentionsTrigger struct{}

func (*MentionsTrigger) CheckMessage ¶

func (mc *MentionsTrigger) CheckMessage(triggerCtx *TriggerContext, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string) (bool, error)

func (*MentionsTrigger) DataType ¶

func (mc *MentionsTrigger) DataType() interface{}

func (*MentionsTrigger) Description ¶

func (mc *MentionsTrigger) Description() string

func (*MentionsTrigger) Kind ¶

func (mc *MentionsTrigger) Kind() RulePartType

func (*MentionsTrigger) MergeDuplicates ¶

func (mc *MentionsTrigger) MergeDuplicates(data []interface{}) interface{}

func (*MentionsTrigger) Name ¶

func (mc *MentionsTrigger) Name() string

func (*MentionsTrigger) UserSettings ¶

func (mc *MentionsTrigger) UserSettings() []*SettingDef

type MentionsTriggerData ¶

type MentionsTriggerData struct {
	Treshold int
}

type MergeableRulePart ¶

type MergeableRulePart interface {
	MergeDuplicates(data []interface{}) interface{}
}

type MessageAttachmentTrigger ¶

type MessageAttachmentTrigger struct {
	RequiresAttachment bool
}

func (*MessageAttachmentTrigger) CheckMessage ¶

func (mat *MessageAttachmentTrigger) CheckMessage(triggerCtx *TriggerContext, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string) (bool, error)

func (*MessageAttachmentTrigger) DataType ¶

func (mat *MessageAttachmentTrigger) DataType() interface{}

func (*MessageAttachmentTrigger) Description ¶

func (mat *MessageAttachmentTrigger) Description() string

func (*MessageAttachmentTrigger) Kind ¶

func (*MessageAttachmentTrigger) MergeDuplicates ¶

func (mat *MessageAttachmentTrigger) MergeDuplicates(data []interface{}) interface{}

func (*MessageAttachmentTrigger) Name ¶

func (mat *MessageAttachmentTrigger) Name() string

func (*MessageAttachmentTrigger) UserSettings ¶

func (mat *MessageAttachmentTrigger) UserSettings() []*SettingDef

type MessageEditedCondition ¶

type MessageEditedCondition struct {
	NewMessage bool // if true, then blacklist mode, otherwise whitelist mode
}

func (*MessageEditedCondition) DataType ¶

func (mc *MessageEditedCondition) DataType() interface{}

func (*MessageEditedCondition) Description ¶

func (mc *MessageEditedCondition) Description() string

func (*MessageEditedCondition) IsMet ¶

func (mc *MessageEditedCondition) IsMet(data *TriggeredRuleData, settings interface{}) (bool, error)

func (*MessageEditedCondition) Kind ¶

func (*MessageEditedCondition) MergeDuplicates ¶

func (mc *MessageEditedCondition) MergeDuplicates(data []interface{}) interface{}

func (*MessageEditedCondition) Name ¶

func (mc *MessageEditedCondition) Name() string

func (*MessageEditedCondition) UserSettings ¶

func (mc *MessageEditedCondition) UserSettings() []*SettingDef

type MessageLengthTrigger ¶

type MessageLengthTrigger struct {
	Inverted bool
}

func (*MessageLengthTrigger) CheckMessage ¶

func (ml *MessageLengthTrigger) CheckMessage(triggerCtx *TriggerContext, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string) (bool, error)

func (*MessageLengthTrigger) DataType ¶

func (ml *MessageLengthTrigger) DataType() interface{}

func (*MessageLengthTrigger) Description ¶

func (ml *MessageLengthTrigger) Description() (description string)

func (*MessageLengthTrigger) Kind ¶

func (*MessageLengthTrigger) Name ¶

func (ml *MessageLengthTrigger) Name() (name string)

func (*MessageLengthTrigger) UserSettings ¶

func (ml *MessageLengthTrigger) UserSettings() []*SettingDef

type MessageLengthTriggerData ¶

type MessageLengthTriggerData struct {
	Length int
}

type MessageRegexTrigger ¶

type MessageRegexTrigger struct {
	BaseRegexTrigger
}

func (*MessageRegexTrigger) CheckMessage ¶

func (r *MessageRegexTrigger) CheckMessage(triggerCtx *TriggerContext, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string) (bool, error)

func (*MessageRegexTrigger) Description ¶

func (r *MessageRegexTrigger) Description() string

func (*MessageRegexTrigger) Name ¶

func (r *MessageRegexTrigger) Name() string

type MessageTrigger ¶

type MessageTrigger interface {
	RulePart

	CheckMessage(triggerCtx *TriggerContext, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string) (isAffected bool, err error)
}

MessageCondition is a active condition that needs to run on a message

type MultiMsgMentionTrigger ¶

type MultiMsgMentionTrigger struct {
	ChannelBased bool
}

func (*MultiMsgMentionTrigger) CheckMessage ¶

func (mt *MultiMsgMentionTrigger) CheckMessage(triggerCtx *TriggerContext, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string) (bool, error)

func (*MultiMsgMentionTrigger) DataType ¶

func (mt *MultiMsgMentionTrigger) DataType() interface{}

func (*MultiMsgMentionTrigger) Description ¶

func (mt *MultiMsgMentionTrigger) Description() string

func (*MultiMsgMentionTrigger) Kind ¶

func (*MultiMsgMentionTrigger) MergeDuplicates ¶

func (mt *MultiMsgMentionTrigger) MergeDuplicates(data []interface{}) interface{}

func (*MultiMsgMentionTrigger) Name ¶

func (mt *MultiMsgMentionTrigger) Name() string

func (*MultiMsgMentionTrigger) UserSettings ¶

func (mt *MultiMsgMentionTrigger) UserSettings() []*SettingDef

type MultiMsgMentionTriggerData ¶

type MultiMsgMentionTriggerData struct {
	Treshold        int
	Interval        int
	CountDuplicates bool
}

type MuteUserEffect ¶

type MuteUserEffect struct{}

func (*MuteUserEffect) Apply ¶

func (mute *MuteUserEffect) Apply(ctxData *TriggeredRuleData, settings interface{}) error

func (*MuteUserEffect) DataType ¶

func (mute *MuteUserEffect) DataType() interface{}

func (*MuteUserEffect) Description ¶

func (mute *MuteUserEffect) Description() (description string)

func (*MuteUserEffect) Kind ¶

func (mute *MuteUserEffect) Kind() RulePartType

func (*MuteUserEffect) MergeDuplicates ¶

func (mute *MuteUserEffect) MergeDuplicates(data []interface{}) interface{}

func (*MuteUserEffect) Name ¶

func (mute *MuteUserEffect) Name() (name string)

func (*MuteUserEffect) UserSettings ¶

func (mute *MuteUserEffect) UserSettings() []*SettingDef

type MuteUserEffectData ¶

type MuteUserEffectData struct {
	Duration     int
	CustomReason string `valid:",0,150,trimspace"`
}

type NicknameListener ¶

type NicknameListener interface {
	RulePart

	CheckNickname(triggerCtx *TriggerContext) (isAffected bool, err error)
}

NicknameListener is a trigger that gets triggered on a nickname change

type NicknameRegexTrigger ¶

type NicknameRegexTrigger struct {
	BaseRegexTrigger
}

func (*NicknameRegexTrigger) CheckNickname ¶

func (r *NicknameRegexTrigger) CheckNickname(t *TriggerContext) (bool, error)

func (*NicknameRegexTrigger) Description ¶

func (r *NicknameRegexTrigger) Description() string

func (*NicknameRegexTrigger) Name ¶

func (r *NicknameRegexTrigger) Name() string

type NicknameWordlistTrigger ¶

type NicknameWordlistTrigger struct {
	Blacklist bool
}

func (*NicknameWordlistTrigger) CheckNickname ¶

func (nwl *NicknameWordlistTrigger) CheckNickname(t *TriggerContext) (bool, error)

func (*NicknameWordlistTrigger) DataType ¶

func (nwl *NicknameWordlistTrigger) DataType() interface{}

func (*NicknameWordlistTrigger) Description ¶

func (nwl *NicknameWordlistTrigger) Description() (description string)

func (*NicknameWordlistTrigger) Kind ¶

func (*NicknameWordlistTrigger) Name ¶

func (nwl *NicknameWordlistTrigger) Name() (name string)

func (*NicknameWordlistTrigger) UserSettings ¶

func (nwl *NicknameWordlistTrigger) UserSettings() []*SettingDef

type NicknameWordlistTriggerData ¶

type NicknameWordlistTriggerData struct {
	ListID       int64
	SanitizeText bool
}

type ParsedPart ¶

type ParsedPart struct {
	// Parts are either children directly of the ruleset, ad ruleset conditions or as children of individual rules
	ParentRule *ParsedRule
	ParentRS   *ParsedRuleset

	RuleModel        *models.AutomodRuleDatum
	RSConditionModel *models.AutomodRulesetCondition

	Part           RulePart
	ParsedSettings interface{}
}

type ParsedRule ¶

type ParsedRule struct {
	Model      *models.AutomodRule
	Triggers   []*ParsedPart
	Conditions []*ParsedPart
	Effects    []*ParsedPart
}

func ParseRuleData ¶

func ParseRuleData(rule *models.AutomodRule) (*ParsedRule, error)

type ParsedRuleset ¶

type ParsedRuleset struct {
	RSModel          *models.AutomodRuleset
	ParsedConditions []*ParsedPart
	Rules            []*ParsedRule
}

func ParseRuleset ¶

func ParseRuleset(rs *models.AutomodRuleset) (*ParsedRuleset, error)

type Plugin ¶

type Plugin struct {
}

func (*Plugin) AddCommands ¶

func (p *Plugin) AddCommands()

func (*Plugin) AllFeatureFlags ¶

func (p *Plugin) AllFeatureFlags() []string

func (*Plugin) BotInit ¶

func (p *Plugin) BotInit()

func (*Plugin) CheckConditions ¶

func (p *Plugin) CheckConditions(ctxData *TriggeredRuleData, conditions []*ParsedPart) bool

func (*Plugin) CheckTriggers ¶

func (p *Plugin) CheckTriggers(rulesets []*ParsedRuleset, gs *dstate.GuildSet, ms *dstate.MemberState, msg *discordgo.Message, cs *dstate.ChannelState, checkF func(trp *ParsedPart) (activated bool, err error)) bool

func (*Plugin) FetchGuildRulesets ¶

func (p *Plugin) FetchGuildRulesets(guildID int64) ([]*ParsedRuleset, error)

func (*Plugin) InitWeb ¶

func (p *Plugin) InitWeb()

func (*Plugin) LoadServerHomeWidget ¶

func (p *Plugin) LoadServerHomeWidget(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)

func (*Plugin) PluginInfo ¶

func (p *Plugin) PluginInfo() *common.PluginInfo

func (*Plugin) RulesetRulesTriggered ¶

func (p *Plugin) RulesetRulesTriggered(ctxData *TriggeredRuleData, checkedConditions bool)

func (*Plugin) RulesetRulesTriggeredCondsPassed ¶

func (p *Plugin) RulesetRulesTriggeredCondsPassed(ruleset *ParsedRuleset, triggeredRules []*ParsedRule, ctxData *TriggeredRuleData)

func (*Plugin) UpdateFeatureFlags ¶

func (p *Plugin) UpdateFeatureFlags(guildID int64) ([]string, error)

type RemoveRoleEffect ¶

type RemoveRoleEffect struct{}

func (*RemoveRoleEffect) Apply ¶

func (rf *RemoveRoleEffect) Apply(ctxData *TriggeredRuleData, settings interface{}) error

func (*RemoveRoleEffect) DataType ¶

func (rf *RemoveRoleEffect) DataType() interface{}

func (*RemoveRoleEffect) Description ¶

func (rf *RemoveRoleEffect) Description() (description string)

func (*RemoveRoleEffect) Kind ¶

func (rr *RemoveRoleEffect) Kind() RulePartType

func (*RemoveRoleEffect) Name ¶

func (rf *RemoveRoleEffect) Name() (name string)

func (*RemoveRoleEffect) UserSettings ¶

func (rf *RemoveRoleEffect) UserSettings() []*SettingDef

type RemoveRoleEffectData ¶

type RemoveRoleEffectData struct {
	Duration int `valid:",0,604800,trimspace"`
	Role     int64
}

type ResetChannelRatelimitData ¶

type ResetChannelRatelimitData struct {
	ChannelID int64
}

type ResetViolationsEffect ¶

type ResetViolationsEffect struct{}

func (*ResetViolationsEffect) Apply ¶

func (rv *ResetViolationsEffect) Apply(ctxData *TriggeredRuleData, settings interface{}) error

func (*ResetViolationsEffect) DataType ¶

func (rv *ResetViolationsEffect) DataType() interface{}

func (*ResetViolationsEffect) Description ¶

func (rv *ResetViolationsEffect) Description() (description string)

func (*ResetViolationsEffect) Kind ¶

func (*ResetViolationsEffect) Name ¶

func (rv *ResetViolationsEffect) Name() (name string)

func (*ResetViolationsEffect) UserSettings ¶

func (rv *ResetViolationsEffect) UserSettings() []*SettingDef

type ResetViolationsEffectData ¶

type ResetViolationsEffectData struct {
	Name string `valid:",0,50,trimspace"`
}

type RulePart ¶

type RulePart interface {
	// Datatype needs to return a new object to unmarshal the settings into, if there is none for this rule data entry then return nil
	DataType() interface{}

	// Returns the available user settings that can be changed (such as roles)
	UserSettings() []*SettingDef

	// Returns a human readble name for this rule data entry and a description
	Name() string
	Description() string

	Kind() RulePartType
}

RulePart represents a single condition, trigger or effect

type RulePartPair ¶

type RulePartPair struct {
	ID   int
	Part RulePart
}

type RulePartType ¶

type RulePartType int
const (
	RulePartTrigger   RulePartType = 0
	RulePartCondition RulePartType = 1
	RulePartEffect    RulePartType = 2
)

type RuleRowData ¶

type RuleRowData struct {
	Type int
	Data map[string][]string
}

type SendChannelMessageEffect ¶

type SendChannelMessageEffect struct{}

func (*SendChannelMessageEffect) Apply ¶

func (send *SendChannelMessageEffect) Apply(ctxData *TriggeredRuleData, settings interface{}) error

func (*SendChannelMessageEffect) DataType ¶

func (send *SendChannelMessageEffect) DataType() interface{}

func (*SendChannelMessageEffect) Description ¶

func (send *SendChannelMessageEffect) Description() (description string)

func (*SendChannelMessageEffect) Kind ¶

func (*SendChannelMessageEffect) MergeDuplicates ¶

func (send *SendChannelMessageEffect) MergeDuplicates(data []interface{}) interface{}

func (*SendChannelMessageEffect) Name ¶

func (send *SendChannelMessageEffect) Name() (name string)

func (*SendChannelMessageEffect) UserSettings ¶

func (send *SendChannelMessageEffect) UserSettings() []*SettingDef

type SendChannelMessageEffectData ¶

type SendChannelMessageEffectData struct {
	CustomReason string `valid:",0,280,trimspace"`
	Duration     int    `valid:",0,3600,trimspace"`
	PingUser     bool
	LogChannel   int64
}

type ServerInviteTrigger ¶

type ServerInviteTrigger struct{}

func (*ServerInviteTrigger) CheckMessage ¶

func (inv *ServerInviteTrigger) CheckMessage(triggerCtx *TriggerContext, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string) (bool, error)

func (*ServerInviteTrigger) DataType ¶

func (inv *ServerInviteTrigger) DataType() interface{}

func (*ServerInviteTrigger) Description ¶

func (inv *ServerInviteTrigger) Description() string

func (*ServerInviteTrigger) Kind ¶

func (inv *ServerInviteTrigger) Kind() RulePartType

func (*ServerInviteTrigger) MergeDuplicates ¶

func (inv *ServerInviteTrigger) MergeDuplicates(data []interface{}) interface{}

func (*ServerInviteTrigger) Name ¶

func (inv *ServerInviteTrigger) Name() string

func (*ServerInviteTrigger) UserSettings ¶

func (inv *ServerInviteTrigger) UserSettings() []*SettingDef

type SetNicknameEffect ¶

type SetNicknameEffect struct{}

func (*SetNicknameEffect) Apply ¶

func (sn *SetNicknameEffect) Apply(ctxData *TriggeredRuleData, settings interface{}) error

func (*SetNicknameEffect) DataType ¶

func (sn *SetNicknameEffect) DataType() interface{}

func (*SetNicknameEffect) Description ¶

func (sn *SetNicknameEffect) Description() (description string)

func (*SetNicknameEffect) Kind ¶

func (sn *SetNicknameEffect) Kind() RulePartType

func (*SetNicknameEffect) MergeDuplicates ¶

func (sn *SetNicknameEffect) MergeDuplicates(data []interface{}) interface{}

func (*SetNicknameEffect) Name ¶

func (sn *SetNicknameEffect) Name() (name string)

func (*SetNicknameEffect) UserSettings ¶

func (sn *SetNicknameEffect) UserSettings() []*SettingDef

type SetNicknameEffectData ¶

type SetNicknameEffectData struct {
	NewName string `valid:",0,32,trimspace"`
}

type SettingDef ¶

type SettingDef struct {
	Name        string
	Key         string
	Kind        SettingType
	Min, Max    int
	Default     interface{} `json:",omitempty"`
	Placeholder string      `json:",omitempty"`
}

type SettingType ¶

type SettingType string

type SlowmodeTrigger ¶

type SlowmodeTrigger struct {
	ChannelBased bool
	Attachments  bool // whether this trigger checks attachments or not
	Links        bool // whether this trigger checks links or not
}

func (*SlowmodeTrigger) CheckMessage ¶

func (s *SlowmodeTrigger) CheckMessage(triggerCtx *TriggerContext, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string) (bool, error)

func (*SlowmodeTrigger) DataType ¶

func (s *SlowmodeTrigger) DataType() interface{}

func (*SlowmodeTrigger) Description ¶

func (s *SlowmodeTrigger) Description() string

func (*SlowmodeTrigger) Kind ¶

func (s *SlowmodeTrigger) Kind() RulePartType

func (*SlowmodeTrigger) MergeDuplicates ¶

func (s *SlowmodeTrigger) MergeDuplicates(data []interface{}) interface{}

func (*SlowmodeTrigger) Name ¶

func (s *SlowmodeTrigger) Name() string

func (*SlowmodeTrigger) UserSettings ¶

func (s *SlowmodeTrigger) UserSettings() []*SettingDef

type SlowmodeTriggerData ¶

type SlowmodeTriggerData struct {
	Treshold                 int
	Interval                 int
	SingleMessageAttachments bool
	SingleMessageLinks       bool
}

type SpamTrigger ¶

type SpamTrigger struct{}

func (*SpamTrigger) CheckMessage ¶

func (spam *SpamTrigger) CheckMessage(triggerCtx *TriggerContext, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string) (bool, error)

func (*SpamTrigger) DataType ¶

func (spam *SpamTrigger) DataType() interface{}

func (*SpamTrigger) Description ¶

func (spam *SpamTrigger) Description() string

func (*SpamTrigger) Kind ¶

func (spam *SpamTrigger) Kind() RulePartType

func (*SpamTrigger) Name ¶

func (spam *SpamTrigger) Name() string

func (*SpamTrigger) UserSettings ¶

func (spam *SpamTrigger) UserSettings() []*SettingDef

type SpamTriggerData ¶

type SpamTriggerData struct {
	Treshold     int
	TimeLimit    int
	SanitizeText bool
}

type ThreadCondition ¶ added in v2.27.0

type ThreadCondition struct {
	Threads bool
}

func (*ThreadCondition) DataType ¶ added in v2.27.0

func (bc *ThreadCondition) DataType() interface{}

func (*ThreadCondition) Description ¶ added in v2.27.0

func (bc *ThreadCondition) Description() string

func (*ThreadCondition) IsMet ¶ added in v2.27.0

func (bc *ThreadCondition) IsMet(data *TriggeredRuleData, settings interface{}) (bool, error)

func (*ThreadCondition) Kind ¶ added in v2.27.0

func (bc *ThreadCondition) Kind() RulePartType

func (*ThreadCondition) MergeDuplicates ¶ added in v2.27.0

func (bc *ThreadCondition) MergeDuplicates(data []interface{}) interface{}

func (*ThreadCondition) Name ¶ added in v2.27.0

func (bc *ThreadCondition) Name() string

func (*ThreadCondition) UserSettings ¶ added in v2.27.0

func (bc *ThreadCondition) UserSettings() []*SettingDef

type TimeoutUserEffect ¶ added in v2.3.0

type TimeoutUserEffect struct{}

func (*TimeoutUserEffect) Apply ¶ added in v2.3.0

func (timeout *TimeoutUserEffect) Apply(ctxData *TriggeredRuleData, settings interface{}) error

func (*TimeoutUserEffect) DataType ¶ added in v2.3.0

func (timeout *TimeoutUserEffect) DataType() interface{}

func (*TimeoutUserEffect) Description ¶ added in v2.3.0

func (timeout *TimeoutUserEffect) Description() (description string)

func (*TimeoutUserEffect) Kind ¶ added in v2.3.0

func (timeout *TimeoutUserEffect) Kind() RulePartType

func (*TimeoutUserEffect) MergeDuplicates ¶ added in v2.3.0

func (timeout *TimeoutUserEffect) MergeDuplicates(data []interface{}) interface{}

func (*TimeoutUserEffect) Name ¶ added in v2.3.0

func (timeout *TimeoutUserEffect) Name() (name string)

func (*TimeoutUserEffect) UserSettings ¶ added in v2.3.0

func (timeout *TimeoutUserEffect) UserSettings() []*SettingDef

type TimeoutUserEffectData ¶ added in v2.3.0

type TimeoutUserEffectData struct {
	Duration     int    `valid:",0,40320,trimspace"`
	CustomReason string `valid:",0,150,trimspace"`
}

type TriggerContext ¶

type TriggerContext struct {
	GS   *dstate.GuildSet
	MS   *dstate.MemberState
	Data interface{}
}

type TriggeredRuleData ¶

type TriggeredRuleData struct {
	// Should always be available
	Plugin  *Plugin
	GS      *dstate.GuildSet
	MS      *dstate.MemberState
	Ruleset *ParsedRuleset

	// not present when checking rs conditions
	CurrentRule *ParsedRule

	// not present when checking conditions
	TriggeredRules    []*ParsedRule
	ActivatedTriggers []*ParsedPart

	// Optional data that may not be present
	CS                     *dstate.ChannelState
	Message                *discordgo.Message
	StrippedMessageContent string // message content stripped of markdown

	RecursionCounter int

	// Gets added to when we recurse using +violation
	PreviousReasons []string
}

func (*TriggeredRuleData) Clone ¶

func (*TriggeredRuleData) ConstructReason ¶

func (t *TriggeredRuleData) ConstructReason(includePrevious bool) string

type UpdateListData ¶

type UpdateListData struct {
	Name    string `valid:",1,50"`
	Content string `valid:",0,5000"`
}

type UpdateRuleData ¶

type UpdateRuleData struct {
	Name       string `valid:",1,50"`
	Triggers   []RuleRowData
	Conditions []RuleRowData
	Effects    []RuleRowData
}

type UpdateRulesetData ¶

type UpdateRulesetData struct {
	Name       string `valid:",1,50"`
	Enabled    bool
	Conditions []RuleRowData
}

type UsernameInviteTrigger ¶

type UsernameInviteTrigger struct {
}

func (*UsernameInviteTrigger) CheckUsername ¶

func (uv *UsernameInviteTrigger) CheckUsername(t *TriggerContext) (bool, error)

func (*UsernameInviteTrigger) DataType ¶

func (uv *UsernameInviteTrigger) DataType() interface{}

func (*UsernameInviteTrigger) Description ¶

func (uv *UsernameInviteTrigger) Description() (description string)

func (*UsernameInviteTrigger) Kind ¶

func (*UsernameInviteTrigger) Name ¶

func (uv *UsernameInviteTrigger) Name() (name string)

func (*UsernameInviteTrigger) UserSettings ¶

func (uv *UsernameInviteTrigger) UserSettings() []*SettingDef

type UsernameListener ¶

type UsernameListener interface {
	RulePart

	CheckUsername(triggerCtx *TriggerContext) (isAffected bool, err error)
}

UsernameListener is a trigger that gets triggered on a nickname change

type UsernameRegexTrigger ¶

type UsernameRegexTrigger struct {
	BaseRegexTrigger
}

func (*UsernameRegexTrigger) CheckUsername ¶

func (r *UsernameRegexTrigger) CheckUsername(t *TriggerContext) (bool, error)

func (*UsernameRegexTrigger) Description ¶

func (r *UsernameRegexTrigger) Description() string

func (*UsernameRegexTrigger) Name ¶

func (r *UsernameRegexTrigger) Name() string

type UsernameWordlistTrigger ¶

type UsernameWordlistTrigger struct {
	Blacklist bool
}

func (*UsernameWordlistTrigger) CheckUsername ¶

func (uwl *UsernameWordlistTrigger) CheckUsername(t *TriggerContext) (bool, error)

func (*UsernameWordlistTrigger) DataType ¶

func (uwl *UsernameWordlistTrigger) DataType() interface{}

func (*UsernameWordlistTrigger) Description ¶

func (uwl *UsernameWordlistTrigger) Description() (description string)

func (*UsernameWordlistTrigger) Kind ¶

func (*UsernameWordlistTrigger) Name ¶

func (uwl *UsernameWordlistTrigger) Name() (name string)

func (*UsernameWordlistTrigger) UserSettings ¶

func (uwl *UsernameWordlistTrigger) UserSettings() []*SettingDef

type UsernameWorldlistData ¶

type UsernameWorldlistData struct {
	ListID       int64
	SanitizeText bool
}

type ViolationListener ¶

type ViolationListener interface {
	RulePart

	CheckUser(ctxData *TriggeredRuleData, violations []*models.AutomodViolation, data interface{}, triggeredOnHigher bool) (isAffected bool, err error)
}

ViolationListener is a trigger that gets triggered on a violation

type ViolationsTrigger ¶

type ViolationsTrigger struct{}

func (*ViolationsTrigger) CheckUser ¶

func (vt *ViolationsTrigger) CheckUser(ctxData *TriggeredRuleData, violations []*models.AutomodViolation, settings interface{}, triggeredOnHigher bool) (isAffected bool, err error)

func (*ViolationsTrigger) DataType ¶

func (vt *ViolationsTrigger) DataType() interface{}

func (*ViolationsTrigger) Description ¶

func (vt *ViolationsTrigger) Description() string

func (*ViolationsTrigger) Kind ¶

func (vt *ViolationsTrigger) Kind() RulePartType

func (*ViolationsTrigger) Name ¶

func (vt *ViolationsTrigger) Name() string

func (*ViolationsTrigger) UserSettings ¶

func (vt *ViolationsTrigger) UserSettings() []*SettingDef

type ViolationsTriggerData ¶

type ViolationsTriggerData struct {
	Name           string `valid:",1,100,trimspace"`
	Treshold       int
	Interval       int
	IgnoreIfLesser bool
}

type WarnUserEffect ¶

type WarnUserEffect struct{}

func (*WarnUserEffect) Apply ¶

func (warn *WarnUserEffect) Apply(ctxData *TriggeredRuleData, settings interface{}) error

func (*WarnUserEffect) DataType ¶

func (warn *WarnUserEffect) DataType() interface{}

func (*WarnUserEffect) Description ¶

func (warn *WarnUserEffect) Description() (description string)

func (*WarnUserEffect) Kind ¶

func (warn *WarnUserEffect) Kind() RulePartType

func (*WarnUserEffect) MergeDuplicates ¶

func (warn *WarnUserEffect) MergeDuplicates(data []interface{}) interface{}

func (*WarnUserEffect) Name ¶

func (warn *WarnUserEffect) Name() (name string)

func (*WarnUserEffect) UserSettings ¶

func (warn *WarnUserEffect) UserSettings() []*SettingDef

type WarnUserEffectData ¶

type WarnUserEffectData struct {
	CustomReason string `valid:",0,150,trimspace"`
}

type WordListTrigger ¶

type WordListTrigger struct {
	Blacklist bool
}

func (*WordListTrigger) CheckMessage ¶

func (wl *WordListTrigger) CheckMessage(triggerCtx *TriggerContext, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string) (bool, error)

func (*WordListTrigger) DataType ¶

func (wl *WordListTrigger) DataType() interface{}

func (*WordListTrigger) Description ¶

func (wl *WordListTrigger) Description() (description string)

func (*WordListTrigger) Kind ¶

func (wl *WordListTrigger) Kind() RulePartType

func (*WordListTrigger) Name ¶

func (wl *WordListTrigger) Name() (name string)

func (*WordListTrigger) UserSettings ¶

func (wl *WordListTrigger) UserSettings() []*SettingDef

type WorldListTriggerData ¶

type WorldListTriggerData struct {
	ListID       int64
	SanitizeText bool
}

Directories ¶

Path Synopsis

Jump to

Keyboard shortcuts

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