Class: ReloadPlugin

Inherits:
Campfire::PollingBot::Plugin show all
Defined in:
lib/campfire/polling_bot/plugins/reload/reload_plugin.rb

Overview

Plugin to allow Wes to update and reload himself

Constant Summary

Constants inherited from Campfire::PollingBot::Plugin

Campfire::PollingBot::Plugin::HALT

Instance Attribute Summary

Attributes inherited from Campfire::PollingBot::Plugin

#bot, #config

Instance Method Summary collapse

Methods inherited from Campfire::PollingBot::Plugin

accepts, #accepts?, accepts?, bot, bot=, directory, directory=, inherited, #initialize, load_all, load_plugin_classes, #logger, logger, priority, #priority, requires_config, requires_config?, #requires_config?, setup_database, subclasses, #to_s

Constructor Details

This class inherits a constructor from Campfire::PollingBot::Plugin

Instance Method Details

#helpObject

return array of available commands and descriptions



21
22
23
# File 'lib/campfire/polling_bot/plugins/reload/reload_plugin.rb', line 21

def help
  [['reload', "update and reload #{bot.name}"]]
end

#process(message) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/campfire/polling_bot/plugins/reload/reload_plugin.rb', line 5

def process(message)
  case message.command
  when /^reload/i
    bot.say("k")
    system("git pull origin master && bundle install")
    if bot.debug
      head = `git rev-parse HEAD`
      bot.say("updated to: https://github.com/hackarts/wesabot/commit/#{head}")
    end
    bot.say("restarting...")
    exec *INVOCATION
    return HALT
  end
end