Class: BookmarkPlugin

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

Overview

Plugin to allow saving of transcript bookmarks

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



25
26
27
# File 'lib/campfire/polling_bot/plugins/bookmark/bookmark_plugin.rb', line 25

def help
  [["bookmark: <name>", "bookmark the current location"]]
end

#process(message) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/campfire/polling_bot/plugins/bookmark/bookmark_plugin.rb', line 5

def process(message)
  case message.command
  when /^(?:add |create )?bookmark:?\s*(?:this as:?)?\s*("?)(.*?)\1$/i
    save_bookmark(message, $2)
    bot.say("Ok, saved bookmark: #{$2}")
    return HALT
  when /(?:list|show) (\S+) bookmarks/i, /(?:list|show) bookmarks for (\S+)/i
    list_bookmarks(message.person, $1)
    return HALT
  when /(list|show) bookmarks$/
    list_bookmarks(message.person, message.person)
    return HALT
  when /delete bookmark (?:#\s*)?(\d+)/
    delete_bookmark(message.person, $1.to_i)
    return HALT
    
  end
end