Sha256: f7ba291de3723bfa48c42f71e4091593ff5ed564da4eaaf477881bd6df52b304

Contents?: true

Size: 725 Bytes

Versions: 2

Compression:

Stored size: 725 Bytes

Contents

Ego::Handler.register do |handler|
  handler.description = 'let you know when I don\'t understand something'

  handler.listen /(.*)/, priority: 0

  handler.run do |robot, params|
    robot.respond %Q{I don't understand "#{params[0]}".}

    handler_slug = params[0]
      .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
      .gsub(/([a-z\d])([A-Z])/, '\1_\2')
      .tr('\'', '')
      .gsub(/\W+/, '_')
      .gsub(/__+/, '_')
      .downcase

    STDERR.puts <<-EOF
Perhaps add a handler to #{Ego::Filesystem.config "handler/#{handler_slug}.rb"}:

Ego::Handler.register do |handler|
  handler.description = 'do something'

  handler.listen /^#{params[0]}$/

  handler.run do |robot, params|
    # ...
  end
end
    EOF
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ego-0.3.0 lib/ego/handler/default.rb
ego-0.2.0 lib/ego/handler/default.rb