Method: HWPing::Bot#initialize
- Defined in:
- lib/hwping/bot.rb
#initialize(handler, config = {}) ⇒ Bot
Initialize a bot and return with its Cinch instance
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/hwping/bot.rb', line 34 def initialize(handler, config = {}) @bot = Cinch::Bot.new do configure do |c| c.nick = config.nick c.server = config.server c.port = config.port c.channels = config.channels.map { |m| "\##{m}" } end # For channel mesages, just reply with the matching message on :channel, /^hwping/ do |e| r = handler.channel(e) e.reply(MESSAGES[r]) end # For private messages, build a reply message from the format strinc and the passed variables on :private do |e| (r, *f) = handler.private(e) e.reply(MESSAGES[r] % f) end end end |