zigdon / xkcd-Bucket

Bucket is the channel bot for #xkcd
http://wiki.xkcd.com/irc/Bucket
121 stars 31 forks source link

Bucket needs initial-capital-only variable expansion #121

Open dgw opened 6 years ago

dgw commented 6 years ago

Properly capitalizing complete-sentence responses that begin with a variable is, um… kind of impossible. Not only does Bucket refuse to touch the capitalization of a value if it contains a capital letter anywhere, but if the value is all-lowercase the only altered capitalization options are ALL CAPS and Title Case. There's no Initial capital only option.

This might not actually be a variable-expansion thing, but a new pre-output filter, I'm not sure. Honestly I haven't spent a huge amount of time thinking about the implementation, but I do think there's a need.

The main barrier I have to building a plugin right now is that there's not really room in the existing syntax for this. $Variable already means Title Case, and changing that to mean Initial capital would mean needing to edit all existing factoids that currently use it for Title Case. (While Bucket could theoretically run a one-time migration against the database, I'd be worried about edge cases. And Bucket's database isn't currently versioned.) The alternatives for indicating Title Case are also all messy in certain situations—$TitleCase looks awful for single-word variables like the ever-popular $NoUn, for example, and TWocaps is just objectively ugly.

Alternatively, individual tidbits (not entire factoids) could be flagged as "Always capitalize this", but that probably needs a database schema change, which I would rather avoid doing. (Bucket's schema also already has enough unused columns.) And then there would need to be esoteric, probably op-only, commands for setting and removing the "capitalize this factoid" flag. Just building the UX for that would be icky, especially because it differs from e.g. protect x (which affects an entire set of factoids, not just one).

So instead of showing up with an example plugin, I have this placeholder issue. Either I'll come up with better ideas and add them here, or someone else will. (Or no one will, and this issue will remain open until GitHub eventually shuts down… :laughing:)