Skip to content

Commit

Permalink
Fix handling of discord emotes
Browse files Browse the repository at this point in the history
Fix handling of discord emotes
  • Loading branch information
HotaruBlaze authored Jul 23, 2021
2 parents c401bb7 + c7f3938 commit 4427fde
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/relayDiscord.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
} else {
message = m.Content
}

// Convert <:example:868167672758693909> to :example:
message = filterDiscordEmotes(message)

guildMember, err := s.GuildMember(m.GuildID, m.Message.Author.ID)
checkError("[RelayDiscord]: guildMember ", err)
hasNickname := guildMember.Nick
Expand Down
8 changes: 8 additions & 0 deletions src/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ func bToMb(b uint64) uint64 {
return b / 1024 / 1024
}

// filterDiscordEmotes : Formats Discord Emotes Correctly
func filterDiscordEmotes(str string) string {
re := regexp.MustCompile(`<:(\S+):\d+>`)
filteredString := re.ReplaceAllString(str, `:$1:`)

return filteredString
}

// MemoryDebugInfo : Print current memory and GC cycles, Used for monitoring for memory leaks
func MemoryDebugInfo() {
printMemUsage()
Expand Down

0 comments on commit 4427fde

Please sign in to comment.