summaryrefslogtreecommitdiffstats
path: root/bridge/discord/helpers.go
diff options
context:
space:
mode:
Diffstat (limited to 'bridge/discord/helpers.go')
-rw-r--r--bridge/discord/helpers.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/bridge/discord/helpers.go b/bridge/discord/helpers.go
index 9545a3ae..4e453ad7 100644
--- a/bridge/discord/helpers.go
+++ b/bridge/discord/helpers.go
@@ -9,6 +9,30 @@ import (
"github.com/matterbridge/discordgo"
)
+func (b *Bdiscord) getAllowedMentions() *discordgo.MessageAllowedMentions {
+ // If AllowMention is not specified, then allow all mentions (default Discord behavior)
+ if !b.IsKeySet("AllowMention") {
+ return nil
+ }
+
+ // Otherwise, allow only the mentions that are specified
+ allowedMentionTypes := make([]discordgo.AllowedMentionType, 0, 3)
+ 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{
+ Parse: allowedMentionTypes,
+ }
+}
+
func (b *Bdiscord) getNick(user *discordgo.User, guildID string) string {
b.membersMutex.RLock()
defer b.membersMutex.RUnlock()