module BeerBot::Utils
Private Class Methods
make_prefix_parser(prefix)
click to toggle source
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.
# 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