def on(event, regexp = //, *args, &block)
      event = event.to_s.to_sym

      pattern = case regexp
                when Pattern
                  regexp
                when Regexp
                  Pattern.new(nil, regexp, nil)
                else
                  if event == :ctcp
                    Pattern.generate(:ctcp, regexp)
                  else
                    Pattern.new(/^/, /#{Regexp.escape(regexp.to_s)}/, /$/)
                  end
                end

      handler = Handler.new(self, event, pattern, {args: args, execute_in_callback: true}, &block)
      @handlers.register(handler)

      return handler
    end
def on(event, regexp = //, *args, &block)
      event = event.to_s.to_sym

      pattern = case regexp
                when Pattern
                  regexp
                when Regexp
                  Pattern.new(nil, regexp, nil)
                else
                  if event == :ctcp
                    Pattern.generate(:ctcp, regexp)
                  else
                    Pattern.new(/^/, /#{Regexp.escape(regexp.to_s)}/, /$/)
                  end
                end

      handler = Handler.new(self, event, pattern, {args: args, execute_in_callback: true}, &block)
      @handlers.register(handler)

      return handler
    end
@endgroup
 @group Events &amp; Plugins
 Registers a handler.

 @param [String, Symbol, Integer] event the event to match. For a
   list of available events, check the {file:docs/events.md Events
   documentation}.

 @param [Regexp, Pattern, String] regexp every message of the
   right event will be checked against this argument and the event
   will only be called if it matches

 @param [Array<Object>] args Arguments that should be passed to
   the block, additionally to capture groups of the regexp.

 @yieldparam [Array<String>] args each capture group of the regex will
   be one argument to the block.

 @return [Handler] The handlers that have been registered