dentarg / hubot-url-title

:crocodile: Returns the title when a link is posted
https://www.npmjs.com/package/hubot-url-title
4 stars 10 forks source link

Limit length of title returned to chat #24

Closed thomasrussellmurphy closed 8 years ago

thomasrussellmurphy commented 8 years ago

Some sites have extremely long <title>s that may exceed the message length of the chat medium that hubot is running on. For example: http://www.vishay.com/company/press/releases/2016/160721VLMU1610/

Currently, hubot-url-title just spits back the processed title at https://github.com/dentarg/hubot-url-title/blob/master/src/scripts/hubot-url-title.coffee#L74

Suggested enhancement: impose a configurable maximum character length on the message hubot responds with. For example, https://github.com/hacsoc/lulu/blob/f6b230922639c0fc017f062686a22bf2c5fea8a5/scripts/web.coffee, specifically the diff at https://github.com/hacsoc/lulu/commit/f6b230922639c0fc017f062686a22bf2c5fea8a5

dentarg commented 8 years ago

@thomasrussellmurphy what is the problem with returning the full title? can't the adapter you are using in your hubot handle a too long message gracefully? I don't think it's up to hubot-url-title to be responsible for that.

But yes, I can see the use case that one would want to limit titles above a certain length, because long titles can be perceived as spammy.

thomasrussellmurphy commented 8 years ago

Our hubot (lulu) lives in IRC and I believe that the adapter will automatically split long messages into multiple, which is annoying. If a page title is extremely long, there's likely not much useful information. In that Vishay link, the extra stuff is a whole bunch of information about their executives, which is fairly superfluous relative to the earlier characters that are about the specific page.

dentarg commented 8 years ago

Yeah, I can see that being annoying. PR implementing an optional (keeping the current behaviour if not used) configuration for this would be much appreciated.

thomasrussellmurphy commented 8 years ago

Please assign this feature issue to me. I plan on preparing a PR tonight.