Class: SamplePlugin

Inherits:
Campfire::PollingBot::Plugin show all
Defined in:
lib/campfire/sample_plugin.rb

Overview

Sample Campfire plugin. Plugins must be placed in the plugins directory in order to be loaded.

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, load_all, load_plugin_classes, #logger, logger, priority, #priority, requires_config, #requires_config?, requires_config?, setup_database, subclasses, #to_s

Constructor Details

#initializeSamplePlugin

If you need to do any one-time setup when the plugin is initially loaded, do it here. Optional.


42
43
# File 'lib/campfire/sample_plugin.rb', line 42

def initialize
end

Instance Method Details

#heartbeatObject

If your plugin implements the heartbeat method, it will be called every time the bot polls the room for activity (currently every 3 seconds), whether or not there are any new messages. The heartbeat method is optional. It does not take any parameters.


49
50
# File 'lib/campfire/sample_plugin.rb', line 49

def heartbeat
end

#helpObject

help is actually functionality provided by another plugin, HelpPlugin. Just return an array of ['command', 'description'] tuples


63
64
65
66
# File 'lib/campfire/sample_plugin.rb', line 63

def help
  [['some command', 'description of some command'],
   ['some other command', 'description of some other command']]
end

#process(message) ⇒ Object

process is the only method your plugin needs to implement. This is called by the bot whenever it has a new message that matches one of the message types accepted by the plugin. See Campfire::Message for message documentation. If no other plugins should receive the message after this plugin, return HALT.


58
59
# File 'lib/campfire/sample_plugin.rb', line 58

def process(message)
end