summaryrefslogtreecommitdiffstats
path: root/bridge/xmpp/xmpp.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2016-11-13 23:09:06 +0100
committerWim <wim@42.be>2016-11-13 23:09:06 +0100
commit497633867759601d658233257447b5b86aa1b01e (patch)
treebc732d5333ddcd0343e1c2d7fd0a025c23822196 /bridge/xmpp/xmpp.go
parent4fb0544b0e25bf6409811fc3e574bf45efea369d (diff)
parent99d130d1ed4c389a76d4fe7f5ea8fccb78bad444 (diff)
downloadmatterbridge-msglm-497633867759601d658233257447b5b86aa1b01e.tar.gz
matterbridge-msglm-497633867759601d658233257447b5b86aa1b01e.tar.bz2
matterbridge-msglm-497633867759601d658233257447b5b86aa1b01e.zip
Merge branch 'refactor'
Diffstat (limited to 'bridge/xmpp/xmpp.go')
-rw-r--r--bridge/xmpp/xmpp.go39
1 files changed, 10 insertions, 29 deletions
diff --git a/bridge/xmpp/xmpp.go b/bridge/xmpp/xmpp.go
index 51237a08..f57fa515 100644
--- a/bridge/xmpp/xmpp.go
+++ b/bridge/xmpp/xmpp.go
@@ -10,12 +10,11 @@ import (
)
type Bxmpp struct {
- xc *xmpp.Client
- xmppMap map[string]string
- Config *config.Protocol
- origin string
- protocol string
- Remote chan config.Message
+ xc *xmpp.Client
+ xmppMap map[string]string
+ Config *config.Protocol
+ Remote chan config.Message
+ Account string
}
var flog *log.Entry
@@ -25,12 +24,11 @@ func init() {
flog = log.WithFields(log.Fields{"module": protocol})
}
-func New(cfg config.Protocol, origin string, c chan config.Message) *Bxmpp {
+func New(cfg config.Protocol, account string, c chan config.Message) *Bxmpp {
b := &Bxmpp{}
b.xmppMap = make(map[string]string)
b.Config = &cfg
- b.protocol = protocol
- b.origin = origin
+ b.Account = account
b.Remote = c
return b
}
@@ -48,31 +46,14 @@ func (b *Bxmpp) Connect() error {
return nil
}
-func (b *Bxmpp) FullOrigin() string {
- return b.protocol + "." + b.origin
-}
-
func (b *Bxmpp) JoinChannel(channel string) error {
b.xc.JoinMUCNoHistory(channel+"@"+b.Config.Muc, b.Config.Nick)
return nil
}
-func (b *Bxmpp) Name() string {
- return b.protocol + "." + b.origin
-}
-
-func (b *Bxmpp) Protocol() string {
- return b.protocol
-}
-
-func (b *Bxmpp) Origin() string {
- return b.origin
-}
-
func (b *Bxmpp) Send(msg config.Message) error {
flog.Debugf("Receiving %#v", msg)
- nick := config.GetNick(&msg, b.Config)
- b.xc.Send(xmpp.Chat{Type: "groupchat", Remote: msg.Channel + "@" + b.Config.Muc, Text: nick + msg.Text})
+ b.xc.Send(xmpp.Chat{Type: "groupchat", Remote: msg.Channel + "@" + b.Config.Muc, Text: msg.Username + msg.Text})
return nil
}
@@ -128,8 +109,8 @@ func (b *Bxmpp) handleXmpp() error {
nick = s[1]
}
if nick != b.Config.Nick {
- flog.Debugf("Sending message from %s on %s to gateway", nick, b.FullOrigin())
- b.Remote <- config.Message{Username: nick, Text: v.Text, Channel: channel, Origin: b.origin, Protocol: b.protocol, FullOrigin: b.FullOrigin()}
+ flog.Debugf("Sending message from %s on %s to gateway", nick, b.Account)
+ b.Remote <- config.Message{Username: nick, Text: v.Text, Channel: channel, Account: b.Account}
}
}
case xmpp.Presence: