5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-25 09:51:36 +00:00

Make gocritic linter happy

This commit is contained in:
Wim 2018-11-08 00:46:34 +01:00
parent 8d117cb0a4
commit 399789811e
6 changed files with 10 additions and 11 deletions

View File

@ -234,7 +234,7 @@ func (b *Bdiscord) messageUpdate(s *discordgo.Session, m *discordgo.MessageUpdat
// only when message is actually edited // only when message is actually edited
if m.Message.EditedTimestamp != "" { if m.Message.EditedTimestamp != "" {
b.Log.Debugf("Sending edit message") b.Log.Debugf("Sending edit message")
m.Content = m.Content + b.GetString("EditSuffix") m.Content += b.GetString("EditSuffix")
b.messageCreate(s, (*discordgo.MessageCreate)(m)) b.messageCreate(s, (*discordgo.MessageCreate)(m))
} }
} }

View File

@ -44,7 +44,7 @@ func SplitStringLength(input string, length int) string {
a := []rune(input) a := []rune(input)
str := "" str := ""
for i, r := range a { for i, r := range a {
str = str + string(r) str += string(r)
if i > 0 && (i+1)%length == 0 { if i > 0 && (i+1)%length == 0 {
str += "\n" str += "\n"
} }

View File

@ -63,8 +63,7 @@ func New(cfg *bridge.Config) bridge.Bridger {
} }
func (b *Birc) Command(msg *config.Message) string { func (b *Birc) Command(msg *config.Message) string {
switch msg.Text { if msg.Text == "!users" {
case "!users":
b.i.Handlers.Add(girc.RPL_NAMREPLY, b.storeNames) b.i.Handlers.Add(girc.RPL_NAMREPLY, b.storeNames)
b.i.Handlers.Add(girc.RPL_ENDOFNAMES, b.endNames) b.i.Handlers.Add(girc.RPL_ENDOFNAMES, b.endNames)
b.i.Cmd.SendRaw("NAMES " + msg.Channel) b.i.Cmd.SendRaw("NAMES " + msg.Channel)
@ -237,7 +236,7 @@ func (b *Birc) Send(msg config.Message) (string, error) {
} }
if len(b.Local) < b.MessageQueue { if len(b.Local) < b.MessageQueue {
if len(b.Local) == b.MessageQueue-1 { if len(b.Local) == b.MessageQueue-1 {
text = text + " <message clipped>" text += " <message clipped>"
} }
b.Local <- config.Message{Text: text, Username: msg.Username, Channel: msg.Channel, Event: msg.Event} b.Local <- config.Message{Text: text, Username: msg.Username, Channel: msg.Channel, Event: msg.Event}
} else { } else {

View File

@ -234,11 +234,11 @@ func (b *Bmatrix) handleDownloadFile(rmsg *config.Message, content map[string]in
if msgtype == "m.image" { if msgtype == "m.image" {
mext, _ := mime.ExtensionsByType(mtype) mext, _ := mime.ExtensionsByType(mtype)
if len(mext) > 0 { if len(mext) > 0 {
name = name + mext[0] name += mext[0]
} }
} else { } else {
// just a default .png extension if we don't have mime info // just a default .png extension if we don't have mime info
name = name + ".png" name += ".png"
} }
} }

View File

@ -303,7 +303,7 @@ func (b *Btelegram) handleDownload(message *tgbotapi.Message, rmsg *config.Messa
urlPart := strings.Split(url, "/") urlPart := strings.Split(url, "/")
name = urlPart[len(urlPart)-1] name = urlPart[len(urlPart)-1]
if !strings.HasSuffix(name, ".webp") { if !strings.HasSuffix(name, ".webp") {
name = name + ".webp" name += ".webp"
} }
text = " " + url text = " " + url
} }
@ -338,7 +338,7 @@ func (b *Btelegram) handleDownload(message *tgbotapi.Message, rmsg *config.Messa
name = urlPart[len(urlPart)-1] name = urlPart[len(urlPart)-1]
text = " " + url text = " " + url
if !strings.HasSuffix(name, ".ogg") { if !strings.HasSuffix(name, ".ogg") {
name = name + ".ogg" name += ".ogg"
} }
} }
if message.Audio != nil { if message.Audio != nil {
@ -356,7 +356,7 @@ func (b *Btelegram) handleDownload(message *tgbotapi.Message, rmsg *config.Messa
// use the URL instead of native upload // use the URL instead of native upload
if b.GetBool("UseInsecureURL") { if b.GetBool("UseInsecureURL") {
b.Log.Debugf("Setting message text to :%s", text) b.Log.Debugf("Setting message text to :%s", text)
rmsg.Text = rmsg.Text + text rmsg.Text += text
return nil return nil
} }
// if we have a file attached, download it (in memory) and put a pointer to it in msg.Extra // if we have a file attached, download it (in memory) and put a pointer to it in msg.Extra

View File

@ -481,7 +481,7 @@ func (gw *Gateway) handleFiles(msg *config.Message) {
ext := filepath.Ext(fi.Name) ext := filepath.Ext(fi.Name)
fi.Name = fi.Name[0 : len(fi.Name)-len(ext)] fi.Name = fi.Name[0 : len(fi.Name)-len(ext)]
fi.Name = reg.ReplaceAllString(fi.Name, "_") fi.Name = reg.ReplaceAllString(fi.Name, "_")
fi.Name = fi.Name + ext fi.Name += ext
sha1sum := fmt.Sprintf("%x", sha1.Sum(*fi.Data))[:8] sha1sum := fmt.Sprintf("%x", sha1.Sum(*fi.Data))[:8]