Class: GreetingPlugin
- Inherits:
-
Campfire::PollingBot::Plugin
- Object
- Campfire::PollingBot::Plugin
- GreetingPlugin
- Defined in:
- lib/campfire/polling_bot/plugins/greeting/greeting_plugin.rb
Overview
Plugin to greet people when they enter, provide a catch-up url, and notify them of any “future” messages requires the HistoryPlugin
Constant Summary
Constants inherited from Campfire::PollingBot::Plugin
Campfire::PollingBot::Plugin::HALT
Instance Attribute Summary
Attributes inherited from Campfire::PollingBot::Plugin
Instance Method Summary collapse
-
#help ⇒ Object
return array of available commands and descriptions.
- #process(message) ⇒ Object
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
#help ⇒ Object
return array of available commands and descriptions
43 44 45 46 47 48 49 |
# File 'lib/campfire/polling_bot/plugins/greeting/greeting_plugin.rb', line 43 def help [['(disable|turn off) greetings', "don't say hi when you log in (you grump)"], ['(enable|turn on) greetings', "say hi when you log in"], ['toggle greetings', "disable greetings if enabled, enable if disabled. You know--toggle."], ['catch me up|ketchup', "gives you a link to the point in the transcript where you last logged out"] ] end |
#process(message) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/campfire/polling_bot/plugins/greeting/greeting_plugin.rb', line 7 def process() user = .user wants_greeting = wants_greeting?(user) if .kind_of?(Campfire::EnterMessage) link = catch_up_link(.person_full_name) futures = (.person_full_name, .person) if wants_greeting && link bot.say("Hey #{.person.downcase}. Catch up: #{link}") end futures.each{|m| bot.say(m) } elsif .kind_of?(Campfire::TextMessage) case .command when /(disable|turn off) greetings/i wants_greeting(user, false) bot.say("OK, I've disabled greetings for you, #{.person}") return HALT when /(enable|turn on) greetings/i wants_greeting(user, true) bot.say("OK, I've enabled greetings for you, #{.person}") return HALT when /toggle greetings/i old_setting = wants_greeting?(user) wants_greeting(user, !old_setting) bot.say("OK, I've #{old_setting ? 'disabled' : 'enabled'} greetings for you, #{.person}") return HALT when /catch me up|ketchup/i if link = catch_up_link(.person_full_name, true) bot.say("Here you go, #{.person}: #{link}") else bot.say("Hmm...couldn't find when you last logged out, #{.person}") end return HALT end end end |