diff --git a/telegram/client.go b/telegram/client.go index 5220c2d..9a98be7 100644 --- a/telegram/client.go +++ b/telegram/client.go @@ -48,6 +48,7 @@ type Client struct { options []client.Option me *client.User + resource string xmpp *xmpp.Component jid string Session *persistence.Session @@ -115,8 +116,14 @@ func NewClient(conf config.TelegramConfig, jid string, component *xmpp.Component IgnoreFileNames: false, } + resource := conf.Tdlib.Client.DeviceModel + if resource == "" { + resource = "telegabber" + } + return &Client{ parameters: ¶meters, + resource: resource, xmpp: component, jid: jid, Session: session, diff --git a/telegram/utils.go b/telegram/utils.go index e2fbe3b..a0e8147 100644 --- a/telegram/utils.go +++ b/telegram/utils.go @@ -217,6 +217,7 @@ func (c *Client) ProcessStatusUpdate(chatID int64, status string, show string, o gateway.SPShow(show), gateway.SPStatus(status), gateway.SPPhoto(photo), + gateway.SPResource(c.resource), gateway.SPImmed(gateway.SPImmed.Get(oldArgs)), } if presenceType != "" { diff --git a/xmpp/gateway/gateway.go b/xmpp/gateway/gateway.go index 779c6fe..4edaec4 100644 --- a/xmpp/gateway/gateway.go +++ b/xmpp/gateway/gateway.go @@ -88,6 +88,9 @@ var SPNickname = args.NewString() // SPPhoto is a XEP-0153 hash of avatar in vCard var SPPhoto = args.NewString() +// SPResource is an optional resource +var SPResource = args.NewString() + // SPImmed skips queueing var SPImmed = args.NewBool(args.Default(true)) @@ -95,6 +98,12 @@ func newPresence(bareJid string, to string, args ...args.V) stanza.Presence { var presenceFrom string if SPFrom.IsSet(args) { presenceFrom = SPFrom.Get(args) + "@" + bareJid + if SPResource.IsSet(args) { + resource := SPResource.Get(args) + if resource != "" { + presenceFrom += "/" + resource + } + } } else { presenceFrom = bareJid }