Method: Cinch::Handler#initialize

Defined in:
lib/cinch/handler.rb

#initialize(bot, event, pattern, options = {}, &block) ⇒ Handler

Returns a new instance of Handler.

Parameters:

  • bot (Bot)
  • event (Symbol)
  • pattern (Pattern)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :group (Symbol) — default: nil

    Match group the h belongs to.

  • :execute_in_callback (Boolean) — default: false

    Whether to execute the handler in an instance of Callback

  • :strip_colors (Boolean) — default: false

    Strip colors from message before attemping match

  • :args (Array) — default: []

    Additional arguments to pass to the block

Since:

  • 2.0.0



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/cinch/handler.rb', line 43

def initialize(bot, event, pattern, options = {}, &block)
  options = {
    group: nil,
    execute_in_callback: false,
    strip_colors: false,
    args: [],
  }.merge(options)
  @bot = bot
  @event = event
  @pattern = pattern
  @group = options[:group]
  @execute_in_callback = options[:execute_in_callback]
  @strip_colors        = options[:strip_colors]
  @args                = options[:args]
  @block               = block

  @thread_group = ThreadGroup.new
end