Class: Tkellem::TkellemBot::ConnectionsCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/tkellem/tkellem_bot.rb

Instance Attribute Summary

Attributes inherited from Command

#args, #bouncer, #conn, #options, #opts

Instance Method Summary collapse

Methods inherited from Command

admin_only?, admin_option, admin_user?, build_options, #initialize, option, register, resources, #respond, run, #show_help, #user

Constructor Details

This class inherits a constructor from Tkellem::TkellemBot::Command

Instance Method Details

#executeObject



455
456
457
458
459
460
461
462
463
464
# File 'lib/tkellem/tkellem_bot.rb', line 455

def execute
  require 'socket'
  $tkellem_server.bouncers.each do |k, bouncer|
    respond "#{bouncer.user.username}@#{bouncer.network.name} (#{bouncer.connected? ? 'connected' : 'connecting'}) #{"since #{bouncer.connected_at}" if bouncer.connected?}"
    bouncer.active_conns.each do |conn|
      port, addr = Socket.unpack_sockaddr_in(conn.get_peername)
      respond "    #{addr} device=#{conn.device_name} since #{conn.connected_at}"
    end
  end
end