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