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

Merge pull request #606 from 42wim/fix-590

This commit is contained in:
Wim 2018-11-25 20:40:22 +01:00 committed by GitHub
commit f716b8fc0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -357,6 +357,10 @@ func (b *Bslack) editMessage(msg *config.Message, channelInfo *slack.Channel) (b
} }
func (b *Bslack) postMessage(msg *config.Message, messageParameters *slack.PostMessageParameters, channelInfo *slack.Channel) (string, error) { func (b *Bslack) postMessage(msg *config.Message, messageParameters *slack.PostMessageParameters, channelInfo *slack.Channel) (string, error) {
// don't post empty messages
if msg.Text == "" {
return "", nil
}
for { for {
_, id, err := b.rtm.PostMessage(channelInfo.ID, msg.Text, *messageParameters) _, id, err := b.rtm.PostMessage(channelInfo.ID, msg.Text, *messageParameters)
if err == nil { if err == nil {
@ -386,11 +390,16 @@ func (b *Bslack) uploadFile(msg *config.Message, channelID string) {
ts := time.Now() ts := time.Now()
b.Log.Debugf("Adding file %s to cache at %s with timestamp", fi.Name, ts.String()) b.Log.Debugf("Adding file %s to cache at %s with timestamp", fi.Name, ts.String())
b.cache.Add("filename"+fi.Name, ts) b.cache.Add("filename"+fi.Name, ts)
initialComment := fmt.Sprintf("File from %s", msg.Username)
if fi.Comment != "" {
initialComment += fmt.Sprintf("with comment: %s", fi.Comment)
}
res, err := b.sc.UploadFile(slack.FileUploadParameters{ res, err := b.sc.UploadFile(slack.FileUploadParameters{
Reader: bytes.NewReader(*fi.Data), Reader: bytes.NewReader(*fi.Data),
Filename: fi.Name, Filename: fi.Name,
Channels: []string{channelID}, Channels: []string{channelID},
InitialComment: fi.Comment, InitialComment: initialComment,
ThreadTimestamp: msg.ParentID,
}) })
if err != nil { if err != nil {
b.Log.Errorf("uploadfile %#v", err) b.Log.Errorf("uploadfile %#v", err)