Module: BeerBot::Utils
- Defined in:
- lib/beerbot/00.utils/InOut.rb,
lib/beerbot/00.utils/utils.rb
Defined Under Namespace
Classes: InOut
Class Method Summary collapse
-
.make_prefix_parser(prefix) ⇒ Object
Return a parser that takes string msg and extracts a specified prefix at beginning.
Class Method Details
.make_prefix_parser(prefix) ⇒ Object
Return a parser that takes string msg and extracts a specified prefix at beginning.
The prefix might be a nick or a command prefix.
Use this to get commands issued to the bot through a channel.
TODO: make sure this returns msg without the prefix, or nil otherwise.
23 24 25 26 27 28 29 30 |
# File 'lib/beerbot/00.utils/utils.rb', line 23 def self.make_prefix_parser prefix rx = Regexp.new("^#{prefix}\\W?(.*)",'i') lambda {|msg| if m = rx.match(msg) then m[1].strip end } end |