Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Long help messages must be delivered over DM #1

Closed
stephenyeargin opened this issue Mar 12, 2015 · 10 comments
Closed

[Feature] Long help messages must be delivered over DM #1

stephenyeargin opened this issue Mar 12, 2015 · 10 comments

Comments

@stephenyeargin
Copy link

Problem: Your Hubot has many packages. When a user types hubot help, a flood wall of text fills up the channel, raising the ire of his/her coworkers.

My simplest idea is that if the help text is more than a reasonable number (say, 20 lines), Hubot responds with "Sorry, I can't display that here. Try sending me a direct message of help and I'll get that for you."

For cases where the bot is already exposed on a port (if using this script, it comes standard), the bot could alternatively respond with "See our help docs at http://some-hubot.herokuapp.com/hubot/help". This is less ideal, if only because not every set up has this working properly.

The better option would be to send the user a DM immediately upon asking for help (with a "No problem! Check your direct messages." message in the room). The trouble there would be working with how each adapter implemented sending private messages -- I don't think they all support robot.send { user: some_user_object }, "MY MESSAGE". My initial thoughts went something like this, but I realized halfway through writing it that it is likely impractical to make this script aware of each adapter's DM methodology.

      switch robot.adapterName
        when 'slack'
          if robot.messageRoom
            robot.messageRoom msg.envelope.user.id, emit
        when 'irc'
          if msg.sendPrivate
            msg.sendPrivate emit
        when 'hipchat'
          robot.send msg.user, emit

I'm not certain how much of this should be configurable (Default to always sending a private message, or only if the help text is greater than x lines.)

@therealklanni
Copy link
Contributor

I actually have a private version that does exactly this that I have been using with my personal Hubots. I will update the code a little bit to make this configurable and submit a PR when I get a chance.

@technicalpickles
Copy link
Member

This makes sense to me, especially for adapters like IRC.

Another idea I have thought about is to, for some adapters, using a pastebin service to upload the text of the help, and paste back to the user. Or, just use the http link like you mentioned.

@cycomachead
Copy link

In my hubot, any help command w/o a query returns the web URL, but searches with a term will display the filter inline. There's no checking for number of lines in either case.

You could do something like: "View the help documentation here.... Or send me a private message"

I like the URL solution because when setup, it's usually faster than a PM. However, currently the URL doesn't support search terms which would also be a handy thing.

@MrSaints
Copy link

I've implemented two of the mentioned solutions before. In case anyone is interested in a solution...

(1) The link method may be achieved like so:

module.exports = (robot) ->
    robot.respond /help/i, (msg) ->
         msg.message.done = true
         msg.reply "Full list of commands available at URL HERE"

The msg.message.done just prevents other commands from firing. You can easily place this in the scripts/ directory, but just ensure it is loaded before the help module (alphabetical order).

The regular expression used targets hubot help, and it should not affect command specific help (if that makes sense).

You may obtain the number of commands from robot.helpCommands() if you want to set a condition.

Additionally, you can speed up the time it takes to populate the commands web page by caching the results.

(2) I wrote two separate modules and made changes to a fork of Hubot that would allow long responses to be uploaded onto a paste service such as Pastebin.

a. A general paste module (library and commands). It currently supports Pastebin and Dpaste, e.g. hubot pastebin <content>

b. A long text filter module that checks if the response is longer than X and if so, it will use the paste module to upload the content and return the paste URL

c. (b) relies on changes to be made on Hubot. I've not made any PR since I'm not sure if it's an efficient implementation or appropriate for Hubot's philosophy (design). Instead, I forked it. When send() is called, the message is passed through a custom applyFiltersToArray() method. Once again, I'm unsure if this is the best way to approach it, but it works (tested).

Best of luck.

@technicalpickles
Copy link
Member

The msg.message.done just prevents other commands from firing.

You can use msg.finish() instead. It's the same thing functionally under the hood, but doesn't involve manually setting the state. I'd also suggest renaming msg to response, since it's a Response object under the hood. cc hubotio/hubot#888

@technicalpickles
Copy link
Member

I wrote two separate modules and made changes to a fork of Hubot that would allow long responses to be uploaded onto a paste service such as Pastebin.

This all sounds pretty great, and is in line of what I had been thinking of. Can you file a PR with your filter changes to hubot? I took a quick look, and it reminds me of some of the work being done to add middleware to a few places in hubot over in hubotio/hubot#803

@colinodell
Copy link

+1

@stale
Copy link

stale bot commented Aug 30, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@colinodell
Copy link

Is there any update on this?

@stale stale bot removed the stale label Aug 30, 2017
@stale
Copy link

stale bot commented Nov 28, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 28, 2017
@stale stale bot closed this as completed Dec 5, 2017
bartfeenstra referenced this issue in radicallyopensecurity/hubot-help Feb 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants