Add disco query responder

This commit is contained in:
annelin 2020-09-19 08:24:44 +03:00
parent 9c171116e7
commit 2c3ab0aceb
2 changed files with 5 additions and 0 deletions

View file

@ -1,3 +1,5 @@
include Jabber::Discovery
class XMPPComponent class XMPPComponent
## initialize zhabogram ## initialize zhabogram
@ -21,6 +23,8 @@ class XMPPComponent
@component.add_presence_callback do |stanza| self.handle_presence(stanza) if stanza.to == @component.jid end # presence handler @component.add_presence_callback do |stanza| self.handle_presence(stanza) if stanza.to == @component.jid end # presence handler
@component.add_message_callback do |stanza| self.handle_message(stanza) if stanza.type != :error and stanza.first_element_text('body') end # messages handler @component.add_message_callback do |stanza| self.handle_message(stanza) if stanza.type != :error and stanza.first_element_text('body') end # messages handler
@component.add_iq_callback do |stanza| self.handle_vcard_iq(stanza) if stanza.type == :get and stanza.vcard end # vcards handler @component.add_iq_callback do |stanza| self.handle_vcard_iq(stanza) if stanza.type == :get and stanza.vcard end # vcards handler
@disco = Jabber::Discovery::Responder.new(@component)
@disco.identities = [ Identity.new('gateway', 'Telegram Gateway', 'telegram') ]
@logger.warn 'Connected to XMPP server' @logger.warn 'Connected to XMPP server'
@db.transaction do @db[:sessions].each do |jid, session| @sessions[jid] = TelegramClient.new(self, jid, session) end end # probe all known sessions @db.transaction do @db[:sessions].each do |jid, session| @sessions[jid] = TelegramClient.new(self, jid, session) end end # probe all known sessions
@sessions.each_key do |jid| self.send_presence(jid, nil, :probe) end @sessions.each_key do |jid| self.send_presence(jid, nil, :probe) end

View file

@ -3,6 +3,7 @@ require 'yaml'
require 'yaml/store' require 'yaml/store'
require 'logger' require 'logger'
require 'xmpp4r' require 'xmpp4r'
require 'xmpp4r/discovery'
require 'digest' require 'digest'
require 'base64' require 'base64'
require 'fileutils' require 'fileutils'