class Botkit::Bot
Attributes
halt[W]
When setting `bot.halt = true`, the bot will be halted after the current loop.
Public Class Methods
new()
click to toggle source
# File lib/botkit/bot.rb, line 11 def initialize @halt = false end
Public Instance Methods
call()
click to toggle source
# File lib/botkit/bot.rb, line 20 def call end
command(name, &block)
click to toggle source
# File lib/botkit/bot.rb, line 48 def command(name, &block) on("command:#{name}", &block) end
exception(&block)
click to toggle source
# File lib/botkit/bot.rb, line 56 def exception(&block) on("internal:exception", &block) end
halt?()
click to toggle source
Detect if bot should halt himself from the loop.
# File lib/botkit/bot.rb, line 16 def halt? @halt end
handle_incoming_message(message)
click to toggle source
# File lib/botkit/bot.rb, line 30 def handle_incoming_message(message) if message.command? emit("command:#{message.command}", message) else emit("internal:message", message) end end
message(&block)
click to toggle source
# File lib/botkit/bot.rb, line 52 def message(&block) on("internal:message", &block) end
parse_message(input)
click to toggle source
# File lib/botkit/bot.rb, line 38 def parse_message(input) input = input.to_s _, command, text = *input.match(%r{\A/([^ @]+)(?:@.*?bot)?(?:\s+(.*?))?\z}i) { command: command, text: command ? text : input } end
reply_message(_message, reply)
click to toggle source
# File lib/botkit/bot.rb, line 26 def reply_message(_message, reply) send_message(reply) end
report_exception(exception)
click to toggle source
# File lib/botkit/bot.rb, line 60 def report_exception(exception) emit("internal:exception", exception) end
send_message(message)
click to toggle source
# File lib/botkit/bot.rb, line 23 def send_message(message) end