mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-21 10:12:00 -08:00
Strip extra info from emotes (discord) (#1052)
This commit is contained in:
parent
76e5fe5a87
commit
af0acf0dae
@ -119,6 +119,9 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
|
||||
rmsg.Event = config.EventUserAction
|
||||
}
|
||||
|
||||
// Replace emotes
|
||||
rmsg.Text = replaceEmotes(rmsg.Text)
|
||||
|
||||
b.Log.Debugf("<= Sending message from %s on %s to gateway", m.Author.Username, b.Account)
|
||||
b.Log.Debugf("<= Message is %#v", rmsg)
|
||||
b.Remote <- rmsg
|
||||
|
@ -137,6 +137,7 @@ var (
|
||||
// See https://discordapp.com/developers/docs/reference#message-formatting.
|
||||
channelMentionRE = regexp.MustCompile("<#[0-9]+>")
|
||||
userMentionRE = regexp.MustCompile("@[^@\n]{1,32}")
|
||||
emoteRE = regexp.MustCompile(`<a?(:\w+:)\d+>`)
|
||||
)
|
||||
|
||||
func (b *Bdiscord) replaceChannelMentions(text string) string {
|
||||
@ -182,6 +183,10 @@ func (b *Bdiscord) replaceUserMentions(text string) string {
|
||||
return userMentionRE.ReplaceAllStringFunc(text, replaceUserMentionFunc)
|
||||
}
|
||||
|
||||
func replaceEmotes(text string) string {
|
||||
return emoteRE.ReplaceAllString(text, "$1")
|
||||
}
|
||||
|
||||
func (b *Bdiscord) replaceAction(text string) (string, bool) {
|
||||
if strings.HasPrefix(text, "_") && strings.HasSuffix(text, "_") {
|
||||
return text[1 : len(text)-1], true
|
||||
|
Loading…
Reference in New Issue
Block a user