diff options
Diffstat (limited to 'xmpp')
-rw-r--r-- | xmpp/component.go | 7 | ||||
-rw-r--r-- | xmpp/handlers.go | 5 |
2 files changed, 10 insertions, 2 deletions
diff --git a/xmpp/component.go b/xmpp/component.go index f5143ea..0f23d50 100644 --- a/xmpp/component.go +++ b/xmpp/component.go @@ -45,6 +45,13 @@ func NewComponent(conf config.XMPPConfig, tc config.TelegramConfig) (*xmpp.Strea if err != nil { return nil, nil, err } + if gateway.Jid.Resource == "" { + if tc.Tdlib.Client.DeviceModel != "" { + gateway.Jid.Resource = tc.Tdlib.Client.DeviceModel + } else { + gateway.Jid.Resource = "telegabber" + } + } tgConf = tc diff --git a/xmpp/handlers.go b/xmpp/handlers.go index b4440a0..d68838b 100644 --- a/xmpp/handlers.go +++ b/xmpp/handlers.go @@ -88,8 +88,9 @@ func HandleMessage(s xmpp.Sender, p stanza.Packet) { if ok { session.ProcessOutgoingMessage(toID, msg.Body, msg.From) return - } else if msg.To == gatewayJid { - if strings.HasPrefix(msg.Body, "/") || strings.HasPrefix(msg.Body, "!") { + } else { + toJid, err := stanza.NewJid(msg.To) + if err == nil && toJid.Bare() == gatewayJid && (strings.HasPrefix(msg.Body, "/") || strings.HasPrefix(msg.Body, "!")) { response := session.ProcessTransportCommand(msg.Body, resource) if response != "" { gateway.SendMessage(msg.From, "", response, component) |