Class: JabberAdmin::Commands::SetPresence

Inherits:
Object
  • Object
show all
Defined in:
lib/jabber_admin/commands/set_presence.rb

Overview

Send a stanza; provide From JID and valid To JID.

Class Method Summary collapse

Class Method Details

.call(callable, user:, type: 'available', show: 'chat', status: '', priority: '7') ⇒ Object

rubocop:disable Metrics/ParameterLists – because of the mapping rubocop:disable Metrics/MethodLength – because of the mapping

Parameters:

  • callable (Proc, #call)

    the callable to call

  • user (String)

    user JID w/ resource (eg. tom@localhost/bot)

  • type (String) (defaults to: 'available')

    the presence type (eg. available, error, probe)

  • show (String) (defaults to: 'chat')

    the showed presence (eg. away, chat, dnd, xa)

  • status (String) (defaults to: '')

    the user status (eg. I’m online)

  • priority (String) (defaults to: '7')

    presence priority (eg. 7)



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/jabber_admin/commands/set_presence.rb', line 20

def self.call(callable, user:, type: 'available', show: 'chat',
              status: '', priority: '7')
  uid, host = user.split('@')
  host, resource = host.split('/')
  resource ||= 'bot'
  callable.call('set_presence',
                user: uid,
                host: host,
                resource: resource,
                type: type,
                show: show,
                status: status,
                priority: priority)
end