Exemple #1
0
func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) {
	if gw.ignoreMessage(&msg) {
		return
	}
	// only relay join/part when configged
	if msg.Event == config.EVENT_JOIN_LEAVE && !gw.Bridges[dest.Account].Config.ShowJoinPart {
		return
	}
	originchannel := msg.Channel
	channels := gw.getDestChannel(&msg, dest.Account)
	for _, channel := range channels {
		// do not send the message to the bridge we come from if also the channel is the same
		if msg.Account == dest.Account && channel == originchannel {
			continue
		}
		msg.Channel = channel
		if msg.Channel == "" {
			log.Debug("empty channel")
			return
		}
		log.Debugf("Sending %#v from %s (%s) to %s (%s)", msg, msg.Account, originchannel, dest.Account, channel)
		gw.modifyUsername(&msg, dest)
		err := dest.Send(msg)
		if err != nil {
			fmt.Println(err)
		}
	}
}
Exemple #2
0
func (gw *SameChannelGateway) modifyUsername(msg *config.Message, dest *bridge.Bridge) {
	br := gw.Bridges[msg.Account]
	nick := gw.Config.General.RemoteNickFormat
	if nick == "" {
		nick = dest.Config.RemoteNickFormat
	}
	nick = strings.Replace(nick, "{NICK}", msg.Username, -1)
	nick = strings.Replace(nick, "{BRIDGE}", br.Name, -1)
	nick = strings.Replace(nick, "{PROTOCOL}", br.Protocol, -1)
	msg.Username = nick
}