-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
irc: more ways for bot.say()
to help with overlength messages
#2050
Conversation
Addresses a shortcoming of the `trailing` parameter, which alone is insufficient to handle some common output patterns used by Sopel's own core plugins. For example, the `wikipedia` plugin outputs article snippets in between quotation marks. Long snippets are truncated and the quote closed by the `trailing` parameter, but short snippets never invoke `trailing`. They lose both the closing quote AND the URL linking to the full article. With this additional parameter, it will be easier for plugins to include variable-length data in "the middle" of a message and still guarantee that any important information at the end of the line will be shown.
Fixes a bug that I never reported in an issue: Missing the URL on short snippets because the URL was part of `trailing`, which only gets used if the text is too long for an IRC line. That bug was the whole inspiration for implementing a new parameter. The only outstanding problem I see now is that a short first line can make it appear as if the article ends there: [wikipedia] ONT | "ONT or Ont may refer to:" | <link_to_page> Ideal output would be: [wikipedia] ONT | "ONT or Ont may refer to: […]" | <link_to_page> That's a separate issue, though.
I didn't really understand the usefulness of |
Like this? "It's useful for": Lines 570 to 571 in fb38d3b
Meanwhile I still don't really like the name "finial". 🙁 Maybe I should just make it "final". Or, since I can't use "finally" because it's a reserved word, I briefly consulted a thesaurus and found "lastly" instead. Surely one of these is better than what I wrote at 1am. 😹 |
Maybe just |
I thought of and immediately discarded the idea of "suffix" as too similar to the Bit of history could be helpful here. I started out renaming the existing And that's how I got "finial". It was kind of just a placeholder. Since What do you think of renaming |
Oh. It wasn't in 7.0?
Oh yes, 100% agree, it makes so much more sense to me! Do you need help with the tests? |
I'll find out tonight (my time)/tomorrow (your time) when I actually make the change. It should be as easy as making sure I run two find-and-replaces in the correct order… But you should feel free to suggest/add more tests for edge cases I didn't think of! |
finial
parameter to bot.say()
bot.say()
to help with overlength messages
The new-to-7.1 `trailing` parameter is now called `truncation`, so the new `finial` argument could be renamed to `trailing`. Updated existing uses of these arguments in core plugins: * reddit * tld * wikipedia * wiktionary
62174cb
to
400dd57
Compare
Renames done. I already broke some stuff by forgetting to update some usage, so double-checking that I didn't miss any previously updated code that expects the old meaning of |
I was looking at all the place where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, even if you don't update the xkcd plugin, I think it's all good. I checked on my side if I could see anything missing, and it looks all good to me!
I have elected to leave the xkcd plugin alone, so as not to alter its behavior in an unrelated PR. The other plugins touched here were either bug fixes or no-op replacement of logic without changing behavior. I think… merged this from my phone, haha. |
Description
Addresses a shortcoming of the
trailing
parameter, which alone is insufficient to handle some common output patterns used by Sopel's own core plugins.For example, the
wikipedia
plugin outputs article snippets in between quotation marks. Long snippets are truncated and the quote closed by thetrailing
parameter, but short snippets never invoketrailing
. They lose both the closing quote AND the URL linking to the full article.With these now two optional parameters (
truncation
andtrailing
), it will be easier for plugins to include variable-length data in "the middle" of a message and still guarantee that any important information at the end of the line will be shown.Checklist
make qa
(runsmake quality
andmake test
)Notes
The nameReplaced "finial" with "trailing", and renamed the existing "trailing" parameter to "truncation" (short for "truncation indicator").finial
is the best idea I could think up while writing this patch, but there's probably a better option out there. What I want isfinally
, but that's a reserved word…When writing the new parameter, I thought more core plugins would use it. Looks like only
wikipedia
needs the extra finesse, but that's fine. I have a few external plugins that will take advantage.And yes, I'm fully aware that this approaches over-engineering. 🙃