5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-12-24 18:25:40 +00:00

Fix #1120: replaceAction "_" crash (discord) (#1121)

This commit is contained in:
Qais Patankar 2020-04-25 13:22:22 +01:00 committed by GitHub
parent a18cb74f03
commit 2d8f749e36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -188,8 +188,9 @@ func replaceEmotes(text string) string {
}
func (b *Bdiscord) replaceAction(text string) (string, bool) {
if strings.HasPrefix(text, "_") && strings.HasSuffix(text, "_") {
return text[1 : len(text)-1], true
length := len(text)
if length > 1 && text[0] == '_' && text[length-1] == '_' {
return text[1 : length-1], true
}
return text, false
}