Module: Rumpy::Bot

Defined in:
lib/rumpy/bot.rb

Overview

include this module into your bot’s class

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pid_fileObject (readonly)

Returns the value of attribute pid_file.



11
12
13
# File 'lib/rumpy/bot.rb', line 11

def pid_file
  @pid_file
end

Instance Method Details

#log_file=(logfile) ⇒ Object

if @log_file isn’t set, initialize it



14
15
16
# File 'lib/rumpy/bot.rb', line 14

def log_file=(logfile)
  @log_file ||= logfile
end

#startObject

one and only public function, defined in this module simply initializes bot’s variables, connection, etc. and starts bot



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rumpy/bot.rb', line 21

def start
  logger_init

  init

  connect

  set_iq_callback
  set_subscription_callback
  set_message_callback

  start_backend_thread
  start_output_queue_thread

  prepare_users

  @logger.info 'Bot is going ONLINE'
  @output_queue.enq Jabber::Presence.new(nil, @status, @priority)

  add_signal_trap

  Thread.stop
rescue => ex
  general_error ex
  exit
end