Loop over received attachments (keybase)

This commit is contained in:
Gonçalo Ribeiro
2019-10-27 10:16:04 +00:00
parent 8d502a801a
commit e176ad7eb4

View File

@@ -79,16 +79,21 @@ func (b *Bkeybase) Send(msg config.Message) (string, error) {
return "", err return "", err
} }
defer os.RemoveAll(dir) defer os.RemoveAll(dir)
fname := msg.Extra["file"][0].(config.FileInfo).Name
fdata := *msg.Extra["file"][0].(config.FileInfo).Data for _, f := range msg.Extra["file"] {
fcaption := msg.Extra["file"][0].(config.FileInfo).Comment fname := f.(config.FileInfo).Name
fpath := filepath.Join(dir, fname) fdata := *f.(config.FileInfo).Data
if err = ioutil.WriteFile(fpath, fdata, 0600); err != nil { fcaption := f.(config.FileInfo).Comment
return "", err fpath := filepath.Join(dir, fname)
if err = ioutil.WriteFile(fpath, fdata, 0600); err != nil {
return "", err
}
_, _ = b.kbc.SendAttachmentByTeam(b.team, fpath, fcaption, &b.channel)
} }
resp, err := b.kbc.SendAttachmentByTeam(b.team, fpath, fcaption, &b.channel) return "", nil
return strconv.Itoa(resp.Result.MsgID), err
} }
// Send regular message // Send regular message