litaio / lita

ChatOps for Ruby.
https://www.lita.io
MIT License
1.68k stars 179 forks source link

Custom Handler not loading #212

Closed warroyo closed 4 years ago

warroyo commented 7 years ago

I am trying to create a new handler and Lita does not seem to be registering it. I am running Lita version 4.7.1 and ruby 2.3. I have used the lita handler command to generate the scaffolding of the handler and just added the basic echo example as the handler code. I have created a gem and deployed it to my internal gem repo. I see that bundle install is pulling in my gem along with other community handlers. but when asking lita echo hello nothing happens and no errors are thrown. also saying help there is not any refernce to "echo" .

here is my handler code(this is just the echo example)

module Lita
  module Handlers
    class EchoHandler < Handler
      route(/^echo\s+(.+)/, :echo, command: true, help: {
              "echo TEXT" => "Replies back with TEXT."
      })

      def echo(response)
        response.reply(response.matches)
      end

    end
    Lita.register_handler(EchoHandler)
  end
end

other than a few changes in the gemspec to remove TODO that is all I have modified from the autogenerated files. Is there something else I need to for the handler to be registered? Is there a way to check to see if it is loaded? I have put Lita in debug but there is no info related to my handler

jimmycuadra commented 7 years ago

A quick way to determine whether or not the Ruby file with the handler is being loaded is to put some code that crashes the program at the very top, e.g. abort "echo handler loaded" and then see if Lita crashes when starting up.

warroyo commented 7 years ago

@jimmycuadra I just tried that out, it looks like it is never loading because Lita started up just fine.

warroyo commented 7 years ago

I am not exactly sure what the issue was here, however it is working now. the gem itself must have something wrong with it when using gem build to create the gem. after seeing in the docs it used rake release now it is working fine, is there something different that rake release does during the build that lita requires?

jimmycuadra commented 7 years ago

rake release is a rake task defined by the bundler gem. It creates a git tag, pushes it to your git remote, and publishes the gem to rubygems.org. It's just a convenience for releasing a new version of a gem. No connection to Lita.