Sha256: acec78cb478592f33ffadd50a08dafff887f07f65da960eb8bcfd53faa3acc7f
Contents?: true
Size: 606 Bytes
Versions: 1
Compression:
Stored size: 606 Bytes
Contents
# frozen_string_literal: true module Del # This class is the default router used # to route chat messages to chat routes. class DefaultRouter def initialize(routes = []) @routes = routes end def register(pattern, &block) @routes.push(pattern: pattern, command: block) end def route(message) @routes.each do |route| next unless (matches = route[:pattern].match(message.text)) begin route[:command].call(message, matches) rescue StandardError => error Del.logger.error(error) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
del-0.1.19 | lib/del/default_router.rb |