Sha256: e4fa49703ef64508e96747d23e432665ea39513393a382c24ce79435eb0aba57
Contents?: true
Size: 938 Bytes
Versions: 1
Compression:
Stored size: 938 Bytes
Contents
class TelegramBot class Matcher def ===(_) false end def arguments(msg) [] end end class TextMatcher < Matcher attr_accessor :pattern def initialize(pat = nil) @pattern = pat end def ===(msg) return false unless msg.type == :text return true if @pattern.nil? @pattern === msg.text end def arguments(msg) if Regexp === @pattern md = @pattern.match(msg.text) md.to_a else [msg.text] end end end class CommandMatcher < Matcher attr_accessor :command def initialize(command) @command = command end def ===(msg) msg.type == :text and msg.text.start_with?("/#{@command}") end def arguments(msg) msg.text.split[1..-1] end end class AnythingMatcher < Matcher def ===(_) true end end class FallbackMatcher < AnythingMatcher end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
telegram_bot_ruby-0.1.5 | lib/telegram_bot/matcher.rb |