Replace 3 AllowPingEveryone/Roles/Users bools with an array
This commit is contained in:
@@ -85,30 +85,28 @@ type ChannelMember struct {
|
||||
type ChannelMembers []ChannelMember
|
||||
|
||||
type Protocol struct {
|
||||
AllowPingEveryone bool // discord
|
||||
AllowPingRoles bool // discord
|
||||
AllowPingUsers bool // discord
|
||||
AuthCode string // steam
|
||||
BindAddress string // mattermost, slack // DEPRECATED
|
||||
Buffer int // api
|
||||
Charset string // irc
|
||||
ClientID string // msteams
|
||||
ColorNicks bool // only irc for now
|
||||
Debug bool // general
|
||||
DebugLevel int // only for irc now
|
||||
DisableWebPagePreview bool // telegram
|
||||
EditSuffix string // mattermost, slack, discord, telegram, gitter
|
||||
EditDisable bool // mattermost, slack, discord, telegram, gitter
|
||||
HTMLDisable bool // matrix
|
||||
IconURL string // mattermost, slack
|
||||
IgnoreFailureOnStart bool // general
|
||||
IgnoreNicks string // all protocols
|
||||
IgnoreMessages string // all protocols
|
||||
Jid string // xmpp
|
||||
JoinDelay string // all protocols
|
||||
Label string // all protocols
|
||||
Login string // mattermost, matrix
|
||||
LogFile string // general
|
||||
AllowMention []string // discord
|
||||
AuthCode string // steam
|
||||
BindAddress string // mattermost, slack // DEPRECATED
|
||||
Buffer int // api
|
||||
Charset string // irc
|
||||
ClientID string // msteams
|
||||
ColorNicks bool // only irc for now
|
||||
Debug bool // general
|
||||
DebugLevel int // only for irc now
|
||||
DisableWebPagePreview bool // telegram
|
||||
EditSuffix string // mattermost, slack, discord, telegram, gitter
|
||||
EditDisable bool // mattermost, slack, discord, telegram, gitter
|
||||
HTMLDisable bool // matrix
|
||||
IconURL string // mattermost, slack
|
||||
IgnoreFailureOnStart bool // general
|
||||
IgnoreNicks string // all protocols
|
||||
IgnoreMessages string // all protocols
|
||||
Jid string // xmpp
|
||||
JoinDelay string // all protocols
|
||||
Label string // all protocols
|
||||
Login string // mattermost, matrix
|
||||
LogFile string // general
|
||||
MediaDownloadBlackList []string
|
||||
MediaDownloadPath string // Basically MediaServerUpload, but instead of uploading it, just write it to a file on the same server.
|
||||
MediaDownloadSize int // all protocols
|
||||
|
||||
@@ -10,16 +10,22 @@ import (
|
||||
)
|
||||
|
||||
func (b *Bdiscord) getAllowedMentions() *discordgo.MessageAllowedMentions {
|
||||
// Allow only the mention types that are not disabled by the config (default is all allowed)
|
||||
// If AllowMention is not specified, then allow all mentions (defautl Discord behavior)
|
||||
if !b.IsKeySet("AllowMention") {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Otherwise, allow only the mentions that are specified
|
||||
allowedMentionTypes := make([]discordgo.AllowedMentionType, 0, 3)
|
||||
if b.GetBool("AllowPingEveryone") || !b.IsKeySet("AllowPingEveryone") {
|
||||
allowedMentionTypes = append(allowedMentionTypes, discordgo.AllowedMentionTypeEveryone)
|
||||
}
|
||||
if b.GetBool("AllowPingRoles") || !b.IsKeySet("AllowPingRoles") {
|
||||
allowedMentionTypes = append(allowedMentionTypes, discordgo.AllowedMentionTypeRoles)
|
||||
}
|
||||
if b.GetBool("AllowPingUsers") || !b.IsKeySet("AllowPingUsers") {
|
||||
allowedMentionTypes = append(allowedMentionTypes, discordgo.AllowedMentionTypeUsers)
|
||||
for _, m := range b.GetStringSlice("AllowMention") {
|
||||
switch m {
|
||||
case "everyone":
|
||||
allowedMentionTypes = append(allowedMentionTypes, discordgo.AllowedMentionTypeEveryone)
|
||||
case "roles":
|
||||
allowedMentionTypes = append(allowedMentionTypes, discordgo.AllowedMentionTypeRoles)
|
||||
case "users":
|
||||
allowedMentionTypes = append(allowedMentionTypes, discordgo.AllowedMentionTypeUsers)
|
||||
}
|
||||
}
|
||||
|
||||
return &discordgo.MessageAllowedMentions{
|
||||
|
||||
@@ -848,15 +848,13 @@ Server="yourservername"
|
||||
## All settings below can be reloaded by editing the file.
|
||||
## They are also all optional.
|
||||
|
||||
# AllowPingEveryone controls if @everyone and @here mentions should send a mention/ping to users. (default true)
|
||||
AllowPingEveryone=true
|
||||
|
||||
# AllowPingRoles controls if @role mentions should send a mention/ping to users. (default true)
|
||||
AllowPingRoles=true
|
||||
|
||||
# AllowPingUsers controls if @user mentions should send a mention/ping to users. (default true)
|
||||
# Even if set to false, the mention will still be nicely displayed and be clickable (but will not ping the user).
|
||||
AllowPingUsers=true
|
||||
# AllowMention controls which mentions are allowed. If not specified, all mentions are allowed.
|
||||
# Note that even when a mention is not allowed, it will still be displayed nicely and be clickable. It just prevents the ping/notification.
|
||||
#
|
||||
# "everyone" allows @everyone and @here mentions
|
||||
# "roles" allows @role mentions
|
||||
# "users" allows @user mentions
|
||||
AllowMention=["everyone", "roles", "users"]
|
||||
|
||||
# ShowEmbeds shows the title, description and URL of embedded messages (sent by other bots)
|
||||
ShowEmbeds=false
|
||||
|
||||
Reference in New Issue
Block a user