mirror of
https://github.com/42wim/matterbridge.git
synced 2024-12-20 01:52:38 +01:00
Modify iconurl correctly (mattermost). Closes #145
This commit is contained in:
parent
89c66b9430
commit
eee0036c7f
@ -101,6 +101,7 @@ func (b *Bmattermost) Send(msg config.Message) error {
|
|||||||
}
|
}
|
||||||
if !b.Config.UseAPI {
|
if !b.Config.UseAPI {
|
||||||
matterMessage := matterhook.OMessage{IconURL: b.Config.IconURL}
|
matterMessage := matterhook.OMessage{IconURL: b.Config.IconURL}
|
||||||
|
matterMessage.IconURL = msg.Avatar
|
||||||
matterMessage.Channel = channel
|
matterMessage.Channel = channel
|
||||||
matterMessage.UserName = nick
|
matterMessage.UserName = nick
|
||||||
matterMessage.Type = ""
|
matterMessage.Type = ""
|
||||||
|
@ -190,6 +190,7 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) {
|
|||||||
}
|
}
|
||||||
log.Debugf("Sending %#v from %s (%s) to %s (%s)", msg, msg.Account, originchannel, dest.Account, channel.Name)
|
log.Debugf("Sending %#v from %s (%s) to %s (%s)", msg, msg.Account, originchannel, dest.Account, channel.Name)
|
||||||
msg.Channel = channel.Name
|
msg.Channel = channel.Name
|
||||||
|
gw.modifyAvatar(&msg, dest)
|
||||||
gw.modifyUsername(&msg, dest)
|
gw.modifyUsername(&msg, dest)
|
||||||
// for api we need originchannel as channel
|
// for api we need originchannel as channel
|
||||||
if dest.Protocol == "api" {
|
if dest.Protocol == "api" {
|
||||||
@ -229,6 +230,17 @@ func (gw *Gateway) modifyUsername(msg *config.Message, dest *bridge.Bridge) {
|
|||||||
msg.Username = nick
|
msg.Username = nick
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gw *Gateway) modifyAvatar(msg *config.Message, dest *bridge.Bridge) {
|
||||||
|
iconurl := gw.Config.General.IconURL
|
||||||
|
if iconurl == "" {
|
||||||
|
iconurl = dest.Config.IconURL
|
||||||
|
}
|
||||||
|
iconurl = strings.Replace(iconurl, "{NICK}", msg.Username, -1)
|
||||||
|
if msg.Avatar == "" {
|
||||||
|
msg.Avatar = iconurl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func getChannelID(msg config.Message) string {
|
func getChannelID(msg config.Message) string {
|
||||||
return msg.Channel + msg.Account
|
return msg.Channel + msg.Account
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user