lib/lita/handler/chat_router.rb in lita-4.4.3 vs lib/lita/handler/chat_router.rb in lita-4.5.0

- old
+ new

@@ -7,18 +7,20 @@ def self.extended(klass) klass.send(:include, Common) end # A Struct representing a chat route defined by a handler. - class Route < Struct.new( + Route = Struct.new( :pattern, :callback, :command, :required_groups, :help, :extensions ) + + class Route alias_method :command?, :command end # @overload route(pattern, method_name, **options) # Creates a chat route. @@ -68,9 +70,16 @@ # @return [Boolean] Whether or not the message matched any routes. def dispatch(robot, message) routes.map do |route| next unless route_applies?(route, message, robot) log_dispatch(route) + robot.trigger( + :message_dispatched, + handler: self, + route: route, + message: message, + robot: robot + ) dispatch_to_route(route, robot, message) true end.any? end