automod

package
v1.19.7 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: MIT Imports: 36 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 needs to be met and another set of effects that will be executed once all the conditions for the rule is 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 happening 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 (
	CacheKeyRulesets bot.GSCacheKey = "automod_2_rulesets"
	CacheKeyLists    bot.GSCacheKey = "automod_2_lists"
)
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"
)
View Source
const DBSchema = `` /* 2657-byte string literal not displayed */

Variables

View Source
var ErrListNotFound = errors.New("list not found")
View Source
var InverseRulePartMap = make(map[RulePart]int)
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},

	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},

	300: &DeleteMessageEffect{},
	301: &AddViolationEffect{},
	302: &KickUserEffect{},
	303: &BanUserEffect{},
	304: &MuteUserEffect{},
	305: &WarnUserEffect{},
	306: &SetNicknameEffect{},
	307: &ResetViolationsEffect{},
	308: &DeleteMessagesEffect{},
	309: &GiveRoleEffect{},
}

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.

Functions

func CheckLimits added in v1.7.0

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

func FetchGuildLists added in v1.7.0

func FetchGuildLists(gs *dstate.GuildState) ([]*models.AutomodList, error)

func FindFetchGuildList added in v1.7.0

func FindFetchGuildList(gs *dstate.GuildState, listID int64) (*models.AutomodList, error)

func GuildMaxLists added in v1.7.0

func GuildMaxLists(guildID int64) int

func GuildMaxMessageTriggers added in v1.7.0

func GuildMaxMessageTriggers(guildID int64) int

func GuildMaxRulesets added in v1.18.0

func GuildMaxRulesets(guildID int64) int

func GuildMaxTotalRules added in v1.7.0

func GuildMaxTotalRules(guildID int64) int

func GuildMaxViolationTriggers added in v1.7.0

func GuildMaxViolationTriggers(guildID int64) int

func ParseAllRulePartData added in v1.7.0

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

func ParseRulePartData added in v1.7.0

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

func PrepareMessageForWordCheck added in v1.7.4

func PrepareMessageForWordCheck(input string) string

func ReadRuleRowData added in v1.7.0

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

func RegisterPlugin

func RegisterPlugin()

func WebLoadRuleSettings added in v1.7.0

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

Types

type AccountAgeCondition added in v1.7.0

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

func (*AccountAgeCondition) DataType added in v1.7.0

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

func (*AccountAgeCondition) Description added in v1.7.0

func (ac *AccountAgeCondition) Description() string

func (*AccountAgeCondition) IsMet added in v1.7.0

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

func (*AccountAgeCondition) Kind added in v1.7.0

func (ac *AccountAgeCondition) Kind() RulePartType

func (*AccountAgeCondition) MergeDuplicates added in v1.7.0

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

func (*AccountAgeCondition) Name added in v1.7.0

func (ac *AccountAgeCondition) Name() string

func (*AccountAgeCondition) UserSettings added in v1.7.0

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

type AccountAgeConditionData added in v1.7.0

type AccountAgeConditionData struct {
	Treshold int
}

type AddViolationEffect added in v1.7.0

type AddViolationEffect struct{}

func (*AddViolationEffect) Apply added in v1.7.0

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

func (*AddViolationEffect) DataType added in v1.7.0

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

func (*AddViolationEffect) Description added in v1.7.0

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

func (*AddViolationEffect) Kind added in v1.7.0

func (vio *AddViolationEffect) Kind() RulePartType

func (*AddViolationEffect) Name added in v1.7.0

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

func (*AddViolationEffect) UserSettings added in v1.7.0

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

type AddViolationEffectData added in v1.7.0

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

type AllCapsTrigger added in v1.7.0

type AllCapsTrigger struct{}

func (*AllCapsTrigger) CheckMessage added in v1.7.0

func (caps *AllCapsTrigger) CheckMessage(ms *dstate.MemberState, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string, data interface{}) (bool, error)

func (*AllCapsTrigger) DataType added in v1.7.0

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

func (*AllCapsTrigger) Description added in v1.7.0

func (caps *AllCapsTrigger) Description() string

func (*AllCapsTrigger) Kind added in v1.7.0

func (caps *AllCapsTrigger) Kind() RulePartType

func (*AllCapsTrigger) MergeDuplicates added in v1.7.0

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

func (*AllCapsTrigger) Name added in v1.7.0

func (caps *AllCapsTrigger) Name() string

func (*AllCapsTrigger) UserSettings added in v1.7.0

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

type AllCapsTriggerData added in v1.7.0

type AllCapsTriggerData struct {
	MinLength  int
	Percentage int
}

type AnyLinkTrigger added in v1.7.0

type AnyLinkTrigger struct{}

func (*AnyLinkTrigger) CheckMessage added in v1.7.0

func (alc *AnyLinkTrigger) CheckMessage(ms *dstate.MemberState, cs *dstate.ChannelState, m *discordgo.Message, stripped string, data interface{}) (bool, error)

func (*AnyLinkTrigger) DataType added in v1.7.0

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

func (*AnyLinkTrigger) Description added in v1.7.0

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

func (*AnyLinkTrigger) Kind added in v1.7.0

func (alc *AnyLinkTrigger) Kind() RulePartType

func (*AnyLinkTrigger) MergeDuplicates added in v1.7.0

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

func (*AnyLinkTrigger) Name added in v1.7.0

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

func (*AnyLinkTrigger) UserSettings added in v1.7.0

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

type BanUserEffect added in v1.7.0

type BanUserEffect struct{}

func (*BanUserEffect) Apply added in v1.7.0

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

func (*BanUserEffect) DataType added in v1.7.0

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

func (*BanUserEffect) Description added in v1.7.0

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

func (*BanUserEffect) Kind added in v1.7.0

func (ban *BanUserEffect) Kind() RulePartType

func (*BanUserEffect) MergeDuplicates added in v1.7.0

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

func (*BanUserEffect) Name added in v1.7.0

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

func (*BanUserEffect) UserSettings added in v1.7.0

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

type BanUserEffectData added in v1.8.0

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

type BaseRegexTrigger added in v1.7.0

type BaseRegexTrigger struct {
	Inverse bool
}

func (BaseRegexTrigger) DataType added in v1.7.0

func (r BaseRegexTrigger) DataType() interface{}

func (BaseRegexTrigger) Kind added in v1.7.0

func (r BaseRegexTrigger) Kind() RulePartType

func (BaseRegexTrigger) UserSettings added in v1.7.0

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

type BaseRegexTriggerData added in v1.7.0

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

type BotCondition added in v1.7.0

type BotCondition struct {
	Ignore bool
}

func (*BotCondition) DataType added in v1.7.0

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

func (*BotCondition) Description added in v1.7.0

func (bc *BotCondition) Description() string

func (*BotCondition) IsMet added in v1.7.0

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

func (*BotCondition) Kind added in v1.7.0

func (bc *BotCondition) Kind() RulePartType

func (*BotCondition) MergeDuplicates added in v1.7.0

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

func (*BotCondition) Name added in v1.7.0

func (bc *BotCondition) Name() string

func (*BotCondition) UserSettings added in v1.7.0

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

type ChannelCategoriesCondition added in v1.7.0

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

func (*ChannelCategoriesCondition) DataType added in v1.7.0

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

func (*ChannelCategoriesCondition) Description added in v1.7.0

func (cd *ChannelCategoriesCondition) Description() string

func (*ChannelCategoriesCondition) IsMet added in v1.7.0

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

func (*ChannelCategoriesCondition) Kind added in v1.7.0

func (*ChannelCategoriesCondition) MergeDuplicates added in v1.7.0

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

func (*ChannelCategoriesCondition) Name added in v1.7.0

func (*ChannelCategoriesCondition) UserSettings added in v1.7.0

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

type ChannelCategoryConditionData added in v1.7.0

type ChannelCategoryConditionData struct {
	Categories []int64
}

type ChannelsCondition added in v1.7.0

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

func (*ChannelsCondition) DataType added in v1.7.0

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

func (*ChannelsCondition) Description added in v1.7.0

func (cd *ChannelsCondition) Description() string

func (*ChannelsCondition) IsMet added in v1.7.0

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

func (*ChannelsCondition) Kind added in v1.7.0

func (cd *ChannelsCondition) Kind() RulePartType

func (*ChannelsCondition) MergeDuplicates added in v1.7.0

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

func (*ChannelsCondition) Name added in v1.7.0

func (cd *ChannelsCondition) Name() string

func (*ChannelsCondition) UserSettings added in v1.7.0

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

type ChannelsConditionData added in v1.7.0

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 added in v1.7.0

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

type CreateRuleData added in v1.7.0

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

type CreateRulesetData added in v1.7.0

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

type CtxKey

type CtxKey int
const (
	CtxKeyCurrentRuleset CtxKey = iota
)

type DeleteMessageEffect added in v1.7.0

type DeleteMessageEffect struct{}

func (*DeleteMessageEffect) Apply added in v1.7.0

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

func (*DeleteMessageEffect) DataType added in v1.7.0

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

func (*DeleteMessageEffect) Description added in v1.7.0

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

func (*DeleteMessageEffect) Kind added in v1.7.0

func (del *DeleteMessageEffect) Kind() RulePartType

func (*DeleteMessageEffect) MergeDuplicates added in v1.7.0

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

func (*DeleteMessageEffect) Name added in v1.7.0

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

func (*DeleteMessageEffect) UserSettings added in v1.7.0

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

type DeleteMessagesEffect added in v1.13.3

type DeleteMessagesEffect struct{}

func (*DeleteMessagesEffect) Apply added in v1.13.3

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

func (*DeleteMessagesEffect) DataType added in v1.13.3

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

func (*DeleteMessagesEffect) Description added in v1.13.3

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

func (*DeleteMessagesEffect) Kind added in v1.13.3

func (del *DeleteMessagesEffect) Kind() RulePartType

func (*DeleteMessagesEffect) MergeDuplicates added in v1.13.3

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

func (*DeleteMessagesEffect) Name added in v1.13.3

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

func (*DeleteMessagesEffect) UserSettings added in v1.13.3

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

type DeleteMessagesEffectData added in v1.13.3

type DeleteMessagesEffectData struct {
	NumMessages int
	TimeLimit   int
}

type DomainTrigger added in v1.7.0

type DomainTrigger struct {
	Blacklist bool
}

func (*DomainTrigger) CheckMessage added in v1.7.0

func (dt *DomainTrigger) CheckMessage(ms *dstate.MemberState, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string, data interface{}) (bool, error)

func (*DomainTrigger) DataType added in v1.7.0

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

func (*DomainTrigger) Description added in v1.7.0

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

func (*DomainTrigger) Kind added in v1.7.0

func (dt *DomainTrigger) Kind() RulePartType

func (*DomainTrigger) Name added in v1.7.0

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

func (*DomainTrigger) UserSettings added in v1.7.0

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

type DomainTriggerData added in v1.7.0

type DomainTriggerData struct {
	ListID int64
}

type Effect added in v1.7.0

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

type ErrUnknownTypeID added in v1.7.0

type ErrUnknownTypeID struct {
	TypeID int
}

func (*ErrUnknownTypeID) Error added in v1.7.0

func (e *ErrUnknownTypeID) Error() string

type GiveRoleEffect added in v1.16.0

type GiveRoleEffect struct{}

func (*GiveRoleEffect) Apply added in v1.16.0

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

func (*GiveRoleEffect) DataType added in v1.16.0

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

func (*GiveRoleEffect) Description added in v1.16.0

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

func (*GiveRoleEffect) Kind added in v1.16.0

func (gr *GiveRoleEffect) Kind() RulePartType

func (*GiveRoleEffect) Name added in v1.16.0

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

func (*GiveRoleEffect) UserSettings added in v1.16.0

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

type GiveRoleEffectData added in v1.16.0

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

type GoogleSafeBrowsingTrigger added in v1.7.0

type GoogleSafeBrowsingTrigger struct{}

func (*GoogleSafeBrowsingTrigger) CheckMessage added in v1.7.0

func (g *GoogleSafeBrowsingTrigger) CheckMessage(ms *dstate.MemberState, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string, data interface{}) (bool, error)

func (*GoogleSafeBrowsingTrigger) DataType added in v1.7.0

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

func (*GoogleSafeBrowsingTrigger) Description added in v1.7.0

func (g *GoogleSafeBrowsingTrigger) Description() string

func (*GoogleSafeBrowsingTrigger) Kind added in v1.7.0

func (*GoogleSafeBrowsingTrigger) MergeDuplicates added in v1.7.0

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

func (*GoogleSafeBrowsingTrigger) Name added in v1.7.0

func (*GoogleSafeBrowsingTrigger) UserSettings added in v1.7.0

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

type JoinListener added in v1.11.6

type JoinListener interface {
	RulePart

	CheckJoin(ms *dstate.MemberState, data interface{}) (isAffected bool, err error)
}

JoinListener is triggers that does stuff when members joins

type KickUserEffect added in v1.7.0

type KickUserEffect struct{}

func (*KickUserEffect) Apply added in v1.7.0

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

func (*KickUserEffect) DataType added in v1.7.0

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

func (*KickUserEffect) Description added in v1.7.0

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

func (*KickUserEffect) Kind added in v1.7.0

func (kick *KickUserEffect) Kind() RulePartType

func (*KickUserEffect) MergeDuplicates added in v1.7.0

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

func (*KickUserEffect) Name added in v1.7.0

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

func (*KickUserEffect) UserSettings added in v1.7.0

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

type KickUserEffectData added in v1.8.0

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

type MemberAgeConditionData added in v1.7.0

type MemberAgeConditionData struct {
	Treshold int
}

type MemberAgecondition added in v1.7.0

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

func (*MemberAgecondition) DataType added in v1.7.0

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

func (*MemberAgecondition) Description added in v1.7.0

func (mc *MemberAgecondition) Description() string

func (*MemberAgecondition) IsMet added in v1.7.0

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

func (*MemberAgecondition) Kind added in v1.7.0

func (mc *MemberAgecondition) Kind() RulePartType

func (*MemberAgecondition) MergeDuplicates added in v1.7.0

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

func (*MemberAgecondition) Name added in v1.7.0

func (mc *MemberAgecondition) Name() string

func (*MemberAgecondition) UserSettings added in v1.7.0

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

type MemberJoinTrigger added in v1.11.6

type MemberJoinTrigger struct {
}

func (*MemberJoinTrigger) CheckJoin added in v1.11.6

func (mj *MemberJoinTrigger) CheckJoin(ms *dstate.MemberState, data interface{}) (isAffected bool, err error)

func (*MemberJoinTrigger) DataType added in v1.11.6

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

func (*MemberJoinTrigger) Description added in v1.11.6

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

func (*MemberJoinTrigger) Kind added in v1.11.6

func (mj *MemberJoinTrigger) Kind() RulePartType

func (*MemberJoinTrigger) Name added in v1.11.6

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

func (*MemberJoinTrigger) UserSettings added in v1.11.6

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

type MemberRolesCondition added in v1.7.0

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

func (*MemberRolesCondition) DataType added in v1.7.0

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

func (*MemberRolesCondition) Description added in v1.7.0

func (mrc *MemberRolesCondition) Description() string

func (*MemberRolesCondition) IsMet added in v1.7.0

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

func (*MemberRolesCondition) Kind added in v1.7.0

func (mrc *MemberRolesCondition) Kind() RulePartType

func (*MemberRolesCondition) MergeDuplicates added in v1.7.0

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

func (*MemberRolesCondition) Name added in v1.7.0

func (mrc *MemberRolesCondition) Name() string

func (*MemberRolesCondition) UserSettings added in v1.7.0

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

type MemberRolesConditionData added in v1.7.0

type MemberRolesConditionData struct {
	Roles []int64
}

type MentionsTrigger added in v1.7.0

type MentionsTrigger struct{}

func (*MentionsTrigger) CheckMessage added in v1.7.0

func (mc *MentionsTrigger) CheckMessage(ms *dstate.MemberState, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string, data interface{}) (bool, error)

func (*MentionsTrigger) DataType added in v1.7.0

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

func (*MentionsTrigger) Description added in v1.7.0

func (mc *MentionsTrigger) Description() string

func (*MentionsTrigger) Kind added in v1.7.0

func (mc *MentionsTrigger) Kind() RulePartType

func (*MentionsTrigger) MergeDuplicates added in v1.7.0

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

func (*MentionsTrigger) Name added in v1.7.0

func (mc *MentionsTrigger) Name() string

func (*MentionsTrigger) UserSettings added in v1.7.0

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

type MentionsTriggerData added in v1.7.0

type MentionsTriggerData struct {
	Treshold int
}

type MergeableRulePart added in v1.7.0

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

type MessageAttachmentTrigger added in v1.13.0

type MessageAttachmentTrigger struct {
	RequiresAttachment bool
}

func (*MessageAttachmentTrigger) CheckMessage added in v1.13.0

func (mat *MessageAttachmentTrigger) CheckMessage(ms *dstate.MemberState, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string, data interface{}) (bool, error)

func (*MessageAttachmentTrigger) DataType added in v1.13.0

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

func (*MessageAttachmentTrigger) Description added in v1.13.0

func (mat *MessageAttachmentTrigger) Description() string

func (*MessageAttachmentTrigger) Kind added in v1.13.0

func (*MessageAttachmentTrigger) MergeDuplicates added in v1.13.0

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

func (*MessageAttachmentTrigger) Name added in v1.13.0

func (mat *MessageAttachmentTrigger) Name() string

func (*MessageAttachmentTrigger) UserSettings added in v1.13.0

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

type MessageEditedCondition added in v1.12.0

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

func (*MessageEditedCondition) DataType added in v1.12.0

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

func (*MessageEditedCondition) Description added in v1.12.0

func (mc *MessageEditedCondition) Description() string

func (*MessageEditedCondition) IsMet added in v1.12.0

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

func (*MessageEditedCondition) Kind added in v1.12.0

func (*MessageEditedCondition) MergeDuplicates added in v1.12.0

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

func (*MessageEditedCondition) Name added in v1.12.0

func (mc *MessageEditedCondition) Name() string

func (*MessageEditedCondition) UserSettings added in v1.12.0

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

type MessageRegexTrigger added in v1.7.0

type MessageRegexTrigger struct {
	BaseRegexTrigger
}

func (*MessageRegexTrigger) CheckMessage added in v1.7.0

func (r *MessageRegexTrigger) CheckMessage(ms *dstate.MemberState, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string, data interface{}) (bool, error)

func (*MessageRegexTrigger) Description added in v1.7.0

func (r *MessageRegexTrigger) Description() string

func (*MessageRegexTrigger) Name added in v1.7.0

func (r *MessageRegexTrigger) Name() string

type MessageTrigger added in v1.7.0

type MessageTrigger interface {
	RulePart

	CheckMessage(ms *dstate.MemberState, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string, data interface{}) (isAffected bool, err error)
}

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

type MultiMsgMentionTrigger added in v1.7.0

type MultiMsgMentionTrigger struct {
	ChannelBased bool
}

func (*MultiMsgMentionTrigger) CheckMessage added in v1.7.0

func (mt *MultiMsgMentionTrigger) CheckMessage(ms *dstate.MemberState, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string, data interface{}) (bool, error)

func (*MultiMsgMentionTrigger) DataType added in v1.7.0

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

func (*MultiMsgMentionTrigger) Description added in v1.7.0

func (mt *MultiMsgMentionTrigger) Description() string

func (*MultiMsgMentionTrigger) Kind added in v1.7.0

func (*MultiMsgMentionTrigger) MergeDuplicates added in v1.7.0

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

func (*MultiMsgMentionTrigger) Name added in v1.7.0

func (mt *MultiMsgMentionTrigger) Name() string

func (*MultiMsgMentionTrigger) UserSettings added in v1.7.0

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

type MultiMsgMentionTriggerData added in v1.7.0

type MultiMsgMentionTriggerData struct {
	Treshold        int
	Interval        int
	CountDuplicates bool
}

type MuteUserEffect added in v1.7.0

type MuteUserEffect struct{}

func (*MuteUserEffect) Apply added in v1.7.0

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

func (*MuteUserEffect) DataType added in v1.7.0

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

func (*MuteUserEffect) Description added in v1.7.0

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

func (*MuteUserEffect) Kind added in v1.7.0

func (mute *MuteUserEffect) Kind() RulePartType

func (*MuteUserEffect) MergeDuplicates added in v1.7.0

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

func (*MuteUserEffect) Name added in v1.7.0

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

func (*MuteUserEffect) UserSettings added in v1.7.0

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

type MuteUserEffectData added in v1.7.0

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

type NicknameListener added in v1.7.0

type NicknameListener interface {
	RulePart

	CheckNickname(ms *dstate.MemberState, data interface{}) (isAffected bool, err error)
}

NicknameListener is a trigger that gets triggered on a nickname change

type NicknameRegexTrigger added in v1.7.0

type NicknameRegexTrigger struct {
	BaseRegexTrigger
}

func (*NicknameRegexTrigger) CheckNickname added in v1.7.0

func (r *NicknameRegexTrigger) CheckNickname(ms *dstate.MemberState, data interface{}) (bool, error)

func (*NicknameRegexTrigger) Description added in v1.7.0

func (r *NicknameRegexTrigger) Description() string

func (*NicknameRegexTrigger) Name added in v1.7.0

func (r *NicknameRegexTrigger) Name() string

type NicknameWordlistTrigger added in v1.7.0

type NicknameWordlistTrigger struct {
	Blacklist bool
}

func (*NicknameWordlistTrigger) CheckNickname added in v1.7.0

func (nwl *NicknameWordlistTrigger) CheckNickname(ms *dstate.MemberState, data interface{}) (bool, error)

func (*NicknameWordlistTrigger) DataType added in v1.7.0

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

func (*NicknameWordlistTrigger) Description added in v1.7.0

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

func (*NicknameWordlistTrigger) Kind added in v1.7.0

func (*NicknameWordlistTrigger) Name added in v1.7.0

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

func (*NicknameWordlistTrigger) UserSettings added in v1.7.0

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

type NicknameWordlistTriggerData added in v1.7.0

type NicknameWordlistTriggerData struct {
	ListID int64
}

type ParsedPart added in v1.7.0

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 added in v1.7.0

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

func ParseRuleData added in v1.7.0

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

type ParsedRuleset added in v1.7.0

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

func ParseRuleset added in v1.7.0

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

type Plugin

type Plugin struct {
}

func (*Plugin) AddCommands added in v1.7.0

func (p *Plugin) AddCommands()

func (*Plugin) BotInit added in v1.4.1

func (p *Plugin) BotInit()

func (*Plugin) CheckConditions added in v1.7.0

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

func (*Plugin) CheckTriggers added in v1.7.0

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

func (*Plugin) FetchGuildRulesets added in v1.7.0

func (p *Plugin) FetchGuildRulesets(gs *dstate.GuildState) ([]*ParsedRuleset, error)

func (*Plugin) InitWeb

func (p *Plugin) InitWeb()

func (*Plugin) LoadServerHomeWidget added in v1.17.0

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

func (*Plugin) PluginInfo added in v1.17.0

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

func (*Plugin) RulesetRulesTriggered added in v1.7.0

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

func (*Plugin) RulesetRulesTriggeredCondsPassed added in v1.7.0

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

type ResetViolationsEffect added in v1.13.3

type ResetViolationsEffect struct{}

func (*ResetViolationsEffect) Apply added in v1.13.3

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

func (*ResetViolationsEffect) DataType added in v1.13.3

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

func (*ResetViolationsEffect) Description added in v1.13.3

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

func (*ResetViolationsEffect) Kind added in v1.13.3

func (*ResetViolationsEffect) Name added in v1.13.3

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

func (*ResetViolationsEffect) UserSettings added in v1.13.3

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

type ResetViolationsEffectData added in v1.13.3

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

type RulePart added in v1.7.0

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 added in v1.7.0

type RulePartPair struct {
	ID   int
	Part RulePart
}

type RulePartType added in v1.7.0

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

type RuleRowData added in v1.7.0

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

type ServerInviteTrigger added in v1.7.0

type ServerInviteTrigger struct{}

func (*ServerInviteTrigger) CheckMessage added in v1.7.0

func (inv *ServerInviteTrigger) CheckMessage(ms *dstate.MemberState, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string, data interface{}) (bool, error)

func (*ServerInviteTrigger) DataType added in v1.7.0

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

func (*ServerInviteTrigger) Description added in v1.7.0

func (inv *ServerInviteTrigger) Description() string

func (*ServerInviteTrigger) Kind added in v1.7.0

func (inv *ServerInviteTrigger) Kind() RulePartType

func (*ServerInviteTrigger) MergeDuplicates added in v1.7.0

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

func (*ServerInviteTrigger) Name added in v1.7.0

func (inv *ServerInviteTrigger) Name() string

func (*ServerInviteTrigger) UserSettings added in v1.7.0

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

type SetNicknameEffect added in v1.7.0

type SetNicknameEffect struct{}

func (*SetNicknameEffect) Apply added in v1.7.0

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

func (*SetNicknameEffect) DataType added in v1.7.0

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

func (*SetNicknameEffect) Description added in v1.7.0

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

func (*SetNicknameEffect) Kind added in v1.7.0

func (sn *SetNicknameEffect) Kind() RulePartType

func (*SetNicknameEffect) MergeDuplicates added in v1.7.0

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

func (*SetNicknameEffect) Name added in v1.7.0

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

func (*SetNicknameEffect) UserSettings added in v1.7.0

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

type SetNicknameEffectData added in v1.7.0

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

type SettingDef added in v1.7.0

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

type SettingType added in v1.7.0

type SettingType string

type SlowmodeTrigger added in v1.7.0

type SlowmodeTrigger struct {
	ChannelBased bool
	Attachments  bool // whether this trigger checks any messages or just attachments
}

func (*SlowmodeTrigger) CheckMessage added in v1.7.0

func (s *SlowmodeTrigger) CheckMessage(ms *dstate.MemberState, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string, data interface{}) (bool, error)

func (*SlowmodeTrigger) DataType added in v1.7.0

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

func (*SlowmodeTrigger) Description added in v1.7.0

func (s *SlowmodeTrigger) Description() string

func (*SlowmodeTrigger) Kind added in v1.7.0

func (s *SlowmodeTrigger) Kind() RulePartType

func (*SlowmodeTrigger) MergeDuplicates added in v1.7.0

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

func (*SlowmodeTrigger) Name added in v1.7.0

func (s *SlowmodeTrigger) Name() string

func (*SlowmodeTrigger) UserSettings added in v1.7.0

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

type SlowmodeTriggerData added in v1.7.0

type SlowmodeTriggerData struct {
	Treshold int
	Interval int
}

type SpamTrigger added in v1.7.0

type SpamTrigger struct{}

func (*SpamTrigger) CheckMessage added in v1.7.0

func (spam *SpamTrigger) CheckMessage(ms *dstate.MemberState, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string, data interface{}) (bool, error)

func (*SpamTrigger) DataType added in v1.7.0

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

func (*SpamTrigger) Description added in v1.7.0

func (spam *SpamTrigger) Description() string

func (*SpamTrigger) Kind added in v1.7.0

func (spam *SpamTrigger) Kind() RulePartType

func (*SpamTrigger) Name added in v1.7.0

func (spam *SpamTrigger) Name() string

func (*SpamTrigger) UserSettings added in v1.7.0

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

type SpamTriggerData added in v1.7.0

type SpamTriggerData struct {
	Treshold  int
	TimeLimit int
}

type TriggeredRuleData added in v1.7.0

type TriggeredRuleData struct {
	// Should always be available
	Plugin  *Plugin
	GS      *dstate.GuildState
	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 added in v1.7.0

func (*TriggeredRuleData) ConstructReason added in v1.7.0

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

type UpdateListData added in v1.7.0

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

type UpdateRuleData added in v1.7.0

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

type UpdateRulesetData added in v1.7.0

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

type UsernameInviteTrigger added in v1.9.0

type UsernameInviteTrigger struct {
}

func (*UsernameInviteTrigger) CheckUsername added in v1.9.0

func (uv *UsernameInviteTrigger) CheckUsername(ms *dstate.MemberState, data interface{}) (bool, error)

func (*UsernameInviteTrigger) DataType added in v1.9.0

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

func (*UsernameInviteTrigger) Description added in v1.9.0

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

func (*UsernameInviteTrigger) Kind added in v1.9.0

func (*UsernameInviteTrigger) Name added in v1.9.0

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

func (*UsernameInviteTrigger) UserSettings added in v1.9.0

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

type UsernameListener added in v1.9.0

type UsernameListener interface {
	RulePart

	CheckUsername(ms *dstate.MemberState, data interface{}) (isAffected bool, err error)
}

UsernameListener is a trigger that gets triggered on a nickname change

type UsernameRegexTrigger added in v1.9.0

type UsernameRegexTrigger struct {
	BaseRegexTrigger
}

func (*UsernameRegexTrigger) CheckUsername added in v1.9.0

func (r *UsernameRegexTrigger) CheckUsername(ms *dstate.MemberState, data interface{}) (bool, error)

func (*UsernameRegexTrigger) Description added in v1.9.0

func (r *UsernameRegexTrigger) Description() string

func (*UsernameRegexTrigger) Name added in v1.9.0

func (r *UsernameRegexTrigger) Name() string

type UsernameWordlistTrigger added in v1.9.0

type UsernameWordlistTrigger struct {
	Blacklist bool
}

func (*UsernameWordlistTrigger) CheckUsername added in v1.9.0

func (uwl *UsernameWordlistTrigger) CheckUsername(ms *dstate.MemberState, data interface{}) (bool, error)

func (*UsernameWordlistTrigger) DataType added in v1.9.0

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

func (*UsernameWordlistTrigger) Description added in v1.9.0

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

func (*UsernameWordlistTrigger) Kind added in v1.9.0

func (*UsernameWordlistTrigger) Name added in v1.9.0

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

func (*UsernameWordlistTrigger) UserSettings added in v1.9.0

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

type UsernameWorldlistData added in v1.9.0

type UsernameWorldlistData struct {
	ListID int64
}

type ViolationListener added in v1.7.0

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 added in v1.7.0

type ViolationsTrigger struct{}

func (*ViolationsTrigger) CheckUser added in v1.7.0

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

func (*ViolationsTrigger) DataType added in v1.7.0

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

func (*ViolationsTrigger) Description added in v1.7.0

func (vt *ViolationsTrigger) Description() string

func (*ViolationsTrigger) Kind added in v1.7.0

func (vt *ViolationsTrigger) Kind() RulePartType

func (*ViolationsTrigger) Name added in v1.7.0

func (vt *ViolationsTrigger) Name() string

func (*ViolationsTrigger) UserSettings added in v1.7.0

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

type ViolationsTriggerData added in v1.7.0

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

type WarnUserEffect added in v1.7.0

type WarnUserEffect struct{}

func (*WarnUserEffect) Apply added in v1.7.0

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

func (*WarnUserEffect) DataType added in v1.7.0

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

func (*WarnUserEffect) Description added in v1.7.0

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

func (*WarnUserEffect) Kind added in v1.7.0

func (warn *WarnUserEffect) Kind() RulePartType

func (*WarnUserEffect) MergeDuplicates added in v1.7.0

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

func (*WarnUserEffect) Name added in v1.7.0

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

func (*WarnUserEffect) UserSettings added in v1.7.0

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

type WarnUserEffectData added in v1.8.0

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

type WordListTrigger added in v1.7.0

type WordListTrigger struct {
	Blacklist bool
}

func (*WordListTrigger) CheckMessage added in v1.7.0

func (wl *WordListTrigger) CheckMessage(ms *dstate.MemberState, cs *dstate.ChannelState, m *discordgo.Message, mdStripped string, data interface{}) (bool, error)

func (*WordListTrigger) DataType added in v1.7.0

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

func (*WordListTrigger) Description added in v1.7.0

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

func (*WordListTrigger) Kind added in v1.7.0

func (wl *WordListTrigger) Kind() RulePartType

func (*WordListTrigger) Name added in v1.7.0

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

func (*WordListTrigger) UserSettings added in v1.7.0

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

type WorldListTriggerData added in v1.7.0

type WorldListTriggerData struct {
	ListID int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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