mirror of
https://github.com/42wim/matterbridge.git
synced 2024-12-19 17:42:35 +01:00
Launch every account only once. Fixes #48
This commit is contained in:
parent
545377742c
commit
e93847a95e
@ -106,10 +106,7 @@ func (b *Bmattermost) Protocol() string {
|
|||||||
|
|
||||||
func (b *Bmattermost) Send(msg config.Message) error {
|
func (b *Bmattermost) Send(msg config.Message) error {
|
||||||
flog.Debugf("Receiving %#v", msg)
|
flog.Debugf("Receiving %#v", msg)
|
||||||
if msg.FullOrigin != b.FullOrigin() {
|
return b.SendType(msg.Username, msg.Text, msg.Channel, "")
|
||||||
return b.SendType(msg.Username, msg.Text, msg.Channel, "")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bmattermost) SendType(nick string, message string, channel string, mtype string) error {
|
func (b *Bmattermost) SendType(nick string, message string, channel string, mtype string) error {
|
||||||
|
@ -26,12 +26,12 @@ func New(cfg *config.Config, gateway *config.Gateway) error {
|
|||||||
gw.MyConfig = gateway
|
gw.MyConfig = gateway
|
||||||
exists := make(map[string]bool)
|
exists := make(map[string]bool)
|
||||||
for _, br := range append(gateway.In, gateway.Out...) {
|
for _, br := range append(gateway.In, gateway.Out...) {
|
||||||
if exists[br.Account+br.Channel] {
|
if exists[br.Account] {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Infof("Starting bridge: %s channel: %s", br.Account, br.Channel)
|
log.Infof("Starting bridge: %s channel: %s", br.Account, br.Channel)
|
||||||
gw.Bridges = append(gw.Bridges, bridge.New(cfg, &br, c))
|
gw.Bridges = append(gw.Bridges, bridge.New(cfg, &br, c))
|
||||||
exists[br.Account+br.Channel] = true
|
exists[br.Account] = true
|
||||||
}
|
}
|
||||||
gw.mapChannels()
|
gw.mapChannels()
|
||||||
gw.mapIgnores()
|
gw.mapIgnores()
|
||||||
@ -103,10 +103,11 @@ func (gw *Gateway) handleMessage(msg config.Message, dest bridge.Bridge) {
|
|||||||
if gw.ignoreMessage(&msg) {
|
if gw.ignoreMessage(&msg) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
originchannel := msg.Channel
|
||||||
channels := gw.getDestChannel(&msg, dest.FullOrigin())
|
channels := gw.getDestChannel(&msg, dest.FullOrigin())
|
||||||
for _, channel := range channels {
|
for _, channel := range channels {
|
||||||
// do not send the message to the bridge we come from if also the channel is the same
|
// do not send the message to the bridge we come from if also the channel is the same
|
||||||
if msg.FullOrigin == dest.FullOrigin() && msg.Channel == channel {
|
if msg.FullOrigin == dest.FullOrigin() && channel == originchannel {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
msg.Channel = channel
|
msg.Channel = channel
|
||||||
@ -115,7 +116,7 @@ func (gw *Gateway) handleMessage(msg config.Message, dest bridge.Bridge) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
gw.modifyMessage(&msg, dest)
|
gw.modifyMessage(&msg, dest)
|
||||||
log.Debugf("Sending %#v from %s to %s", msg, msg.FullOrigin, dest.FullOrigin())
|
log.Debugf("Sending %#v from %s (%s) to %s (%s)", msg, msg.FullOrigin, originchannel, dest.FullOrigin(), channel)
|
||||||
err := dest.Send(msg)
|
err := dest.Send(msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user