Sha256: 3c4c36bba4e6ccd2aac526cebda5df0a2402fc726e1b2e7c52266840f2aae8f1
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true module Botkit class Bot include Voltage # When setting `bot.halt = true`, the bot will be halted # after the current loop. attr_writer :halt def initialize @halt = false end # Detect if bot should halt himself from the loop. def halt? @halt end def call end def send_message(message) end def reply_message(_message, reply) send_message(reply) end def handle_incoming_message(message) if message.command? emit("command:#{message.command}", message) else emit("internal:message", message) end end 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 def command(name, &block) on("command:#{name}", &block) end def message(&block) on("internal:message", &block) end def exception(&block) on("internal:exception", &block) end def report_exception(exception) emit("internal:exception", exception) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
botkit-0.0.6 | lib/botkit/bot.rb |