class Xasin::Telegram::OnMessage

Public Class Methods

new(options) click to toggle source
Calls superclass method Xasin::Telegram::OnTelegramEvent::new
# File lib/xasin/telegram/OnMessage.rb, line 6
def initialize(options)
        super()

        @block = options[:block]
        @regexp = options[:regexp]

        @priority += 1 if @regexp
end

Public Instance Methods

nomp_message(message) click to toggle source
# File lib/xasin/telegram/OnMessage.rb, line 15
def nomp_message(message)
        if @regexp
                match = @regexp.match message.to_s

                if match
                        @block.call message, match
                        message.handled = true
                end
        else
                @block.call message
        end
end