mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-11-22 15:10:28 +00:00
Add support for editing messages (slack)
This commit is contained in:
parent
7c773ebae0
commit
8b98f605bc
@ -163,14 +163,17 @@ func (b *Bslack) Send(msg config.Message) (string, error) {
|
|||||||
np.IconURL = msg.Avatar
|
np.IconURL = msg.Avatar
|
||||||
}
|
}
|
||||||
np.Attachments = append(np.Attachments, slack.Attachment{CallbackID: "matterbridge"})
|
np.Attachments = append(np.Attachments, slack.Attachment{CallbackID: "matterbridge"})
|
||||||
b.sc.PostMessage(schannel.ID, message, np)
|
// if we have no ID it means we're creating a new message, not updating an existing one
|
||||||
|
if msg.ID != "" {
|
||||||
/*
|
ts := strings.Fields(msg.ID)
|
||||||
newmsg := b.rtm.NewOutgoingMessage(message, schannel.ID)
|
b.sc.UpdateMessage(schannel.ID, ts[1], message)
|
||||||
b.rtm.SendMessage(newmsg)
|
return "", nil
|
||||||
*/
|
}
|
||||||
|
_, id, err := b.sc.PostMessage(schannel.ID, message, np)
|
||||||
return "", nil
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return "slack " + id, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bslack) getAvatar(user string) string {
|
func (b *Bslack) getAvatar(user string) string {
|
||||||
@ -233,7 +236,7 @@ func (b *Bslack) handleSlack() {
|
|||||||
text = b.replaceURL(text)
|
text = b.replaceURL(text)
|
||||||
text = html.UnescapeString(text)
|
text = html.UnescapeString(text)
|
||||||
flog.Debugf("Sending message from %s on %s to gateway", message.Username, b.Account)
|
flog.Debugf("Sending message from %s on %s to gateway", message.Username, b.Account)
|
||||||
msg := config.Message{Text: text, Username: message.Username, Channel: message.Channel, Account: b.Account, Avatar: b.getAvatar(message.Username), UserID: message.UserID}
|
msg := config.Message{Text: text, Username: message.Username, Channel: message.Channel, Account: b.Account, Avatar: b.getAvatar(message.Username), UserID: message.UserID, ID: "slack " + message.Raw.Timestamp}
|
||||||
if message.Raw.SubType == "me_message" {
|
if message.Raw.SubType == "me_message" {
|
||||||
msg.Event = config.EVENT_USER_ACTION
|
msg.Event = config.EVENT_USER_ACTION
|
||||||
}
|
}
|
||||||
@ -241,6 +244,10 @@ func (b *Bslack) handleSlack() {
|
|||||||
msg.Username = "system"
|
msg.Username = "system"
|
||||||
msg.Event = config.EVENT_JOIN_LEAVE
|
msg.Event = config.EVENT_JOIN_LEAVE
|
||||||
}
|
}
|
||||||
|
// edited messages have a submessage, use this timestamp
|
||||||
|
if message.Raw.SubMessage != nil {
|
||||||
|
msg.ID = "slack " + message.Raw.SubMessage.Timestamp
|
||||||
|
}
|
||||||
b.Remote <- msg
|
b.Remote <- msg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user