diff --git a/inc/telegramclient.rb b/inc/telegramclient.rb index 4a6ca6d..1cf79cd 100644 --- a/inc/telegramclient.rb +++ b/inc/telegramclient.rb @@ -70,6 +70,7 @@ class TelegramClient def initialize(xmpp, jid, **session) return unless @@config @logger = Logger.new(STDOUT, level: @@config[:loglevel], progname: 'TelegramClient: %s | %s' % [jid, session[:login]] ) + @resource = @@config[:tdlib][:client][:device_model] || 'zhabogram' @xmpp = xmpp @jid = jid @session = session @@ -270,7 +271,7 @@ class TelegramClient when TD::Types::UserStatus::Offline then show, status = (Time.now.getutc.to_i-status.was_online.to_i<3600) ? :away : :xa, DateTime.strptime((status.was_online+Time.now.getlocal(@session[:timezone]).utc_offset).to_s,'%s').strftime("Last seen at %H:%M %d/%m/%Y") end - return @xmpp.send_presence(@jid, id, type, show, status, nil, photo, immed) + return @xmpp.send_presence(@jid, id, type, show, status, nil, photo, @resource, immed) end ## send outgoing message to telegram user diff --git a/inc/xmppcomponent.rb b/inc/xmppcomponent.rb index 3fa3403..2a80530 100644 --- a/inc/xmppcomponent.rb +++ b/inc/xmppcomponent.rb @@ -94,10 +94,10 @@ class XMPPComponent @component.send(message) end - def send_presence(to, from=nil, type=nil, show=nil, status=nil, nickname=nil, photo=nil, immed=true) + def send_presence(to, from=nil, type=nil, show=nil, status=nil, nickname=nil, photo=nil, resource=nil, immed=true) @logger.info "Got presence :%s from %s to %s" % [type, from||@component.jid, to] presence = Jabber::Presence.new() - presence.from = from.nil? ? @component.jid : "%s@%s" % [from.to_s, @component.jid.to_s] # presence + presence.from = from.nil? ? @component.jid : "%s@%s%s" % [from.to_s, @component.jid.to_s, (resource ? "/"+resource : "")] # presence presence.to = to # presence presence.type = type unless type.nil? # pres. type presence.show = show unless show.nil? # presence