litaio / lita

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

Overriding the default help command #207

Closed cascer1 closed 4 years ago

cascer1 commented 7 years ago

Hi,

I'm working on an adapter for Discord (the existing one doesn't support oauth properly imo). For this I'm also trying to override the default help command to generate something specific to discord. ie: I'm putting everything in a code block and aligning the content to a sort of table.

I was able to get this to work by adding a new command to the adapter, but Lita still outputs the default help command output too.

Is it possible to disable this default help command?

jimmycuadra commented 7 years ago

Currently, no. We were in the process of extracting all the default handlers into a separate plugin, but to retain backwards compatibility it will take a couple major versions to fully migrate. See https://github.com/litaio/lita-default-handlers

khanhzynga commented 7 years ago

Hi Cas and Jimmy, I was able to override the default help command by doing this:

In your own handler, remove the route from the Help handler

Help.routes.pop

Then re-implement (override) the help route: route(/^help\s*(?<substring>.+)?/i, command: true, help: { "help" => t("help.help_value"), t("help.help_string_key") => t("help.help_string_value") }) do |response| response.reply("my custom help") end

You'll need more work to re-implement the actual help listing of this and other built-in commands but that's the basic strategy. Hope this helps.

nwesoccer commented 7 years ago

We accomplished this (not in the scope of an adapter though) by adding the following lines to the top of lita_config.rb and then adding our own HelpMe handler.

Lita.handlers.delete(Lita::Handlers::Info) Lita.handlers.delete(Lita::Handlers::Help) Lita.handlers.delete(Lita::Handlers::Authorization) Lita.handlers.delete(Lita::Handlers::Room) Lita.handlers.delete(Lita::Handlers::Users)