Fix telegram/handlers.go linting (#1658)

This commit is contained in:
Wim 2021-12-10 22:13:54 +01:00 committed by GitHub
parent e1eebcd4e0
commit 658bdd9faa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -436,7 +436,7 @@ func (b *Btelegram) handleEntities(rmsg *config.Message, message *tgbotapi.Messa
return return
} }
var indexMovedBy = 0 indexMovedBy := 0
// for now only do URL replacements // for now only do URL replacements
for _, e := range *message.Entities { for _, e := range *message.Entities {
@ -456,14 +456,14 @@ func (b *Btelegram) handleEntities(rmsg *config.Message, message *tgbotapi.Messa
} }
if e.Type == "code" { if e.Type == "code" {
var offset = e.Offset + indexMovedBy offset := e.Offset + indexMovedBy
rmsg.Text = rmsg.Text[:offset] + "`" + rmsg.Text[offset:offset + e.Length] + "`" + rmsg.Text[offset + e.Length :] rmsg.Text = rmsg.Text[:offset] + "`" + rmsg.Text[offset:offset+e.Length] + "`" + rmsg.Text[offset+e.Length:]
indexMovedBy += 2 indexMovedBy += 2
} }
if e.Type == "pre" { if e.Type == "pre" {
var offset = e.Offset + indexMovedBy offset := e.Offset + indexMovedBy
rmsg.Text = rmsg.Text[:offset] + "```\n" + rmsg.Text[offset:offset + e.Length] + "\n```" + rmsg.Text[offset + e.Length :] rmsg.Text = rmsg.Text[:offset] + "```\n" + rmsg.Text[offset:offset+e.Length] + "\n```" + rmsg.Text[offset+e.Length:]
indexMovedBy += 8 indexMovedBy += 8
} }
} }