module TelegramBot::EventHandler
Public Class Methods
included(clazz)
click to toggle source
# File lib/telegram_bot/handler.rb, line 40 def self.included(clazz) clazz.prepend PrependMethods end
Public Instance Methods
handle(msg)
click to toggle source
# File lib/telegram_bot/handler.rb, line 53 def handle(msg) @handlers.each do |hndlr| next unless hndlr === msg proxy = MessageProxy.new(self, msg, hndlr) proxy.instance_exec(*hndlr.arguments(msg), &hndlr.action) break unless hndlr.pass? end end
on(type, *args, pass: false, &block)
click to toggle source
# File lib/telegram_bot/handler.rb, line 45 def on(type, *args, pass: false, &block) matcher_class_name = "telegram_bot/#{type}_matcher".classify matcher_class = matcher_class_name.constantize matcher = matcher_class.new(*args) handler = Handler.new(matcher, block, pass) @handlers << handler end