Module: Rumpy::Bot

Defined in:
lib/rumpy.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pid_fileObject (readonly)

Returns the value of attribute pid_file.



48
49
50
# File 'lib/rumpy.rb', line 48

def pid_file
  @pid_file
end

Class Method Details

.find_by_jid(jid) ⇒ Object



104
105
106
# File 'lib/rumpy.rb', line 104

def @main_model.find_by_jid(jid)
  super jid.strip.to_s
end

Instance Method Details

#startObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/rumpy.rb', line 50

def start
  @err_file = if @err_file then
               File.open(@err_file, 'w')
             else
               $stderr
             end
  Signal.trap :TERM do |signo|
    @err_file.close
    exit
  end

  init
  connect
  clear_users
  start_subscription_callback
  start_message_callback
  @client.send Jabber::Presence.new.set_priority(@priority).set_status(@status)
  Jabber::Version::SimpleResponder.new(@client, @bot_name || self.class.to_s, @bot_version || '1.0.0', RUBY_PLATFORM)
  Thread.new do
    begin
      loop do
        backend_func().each do |result|
          send_msg *result
        end
      end
    rescue => e
      $err_file.puts e.inspect
      $err_file.puts e.backtrace
    end
  end if self.respond_to? :backend_func
  Thread.stop
end