Method: Cinch::Handler#call

Defined in:
lib/cinch/handler.rb

#call(message, captures, arguments) ⇒ Thread

Executes the handler.

Parameters:

  • Message that caused the invocation

  • Capture groups of the pattern that are being passed as arguments

Returns:

Since:

  • 2.0.0



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/cinch/handler.rb', line 89

def call(message, captures, arguments)
  bargs = captures + arguments

  thread = Thread.new {
    @bot.loggers.debug "[New thread] For #{self}: #{Thread.current} -- #{@thread_group.list.size} in total."

    begin
      if @execute_in_callback
        @bot.callback.instance_exec(message, *@args, *bargs, &@block)
      else
        @block.call(message, *@args, *bargs)
      end
    rescue => e
      @bot.loggers.exception(e)
    ensure
      @bot.loggers.debug "[Thread done] For #{self}: #{Thread.current} -- #{@thread_group.list.size - 1} remaining."
    end
  }

  @thread_group.add(thread)
  thread
end