This two-piece code will allow you to setup a Nightbot shoutout command which can be customised to allow per-user shoutout messages, with a fallback default message.
Because Nightbot commands have a character limit, you won't get far with including the custom messages directly in your command string.
The solution is to use Nightbots urlfetch
variable to fetch a JSON object filled with custom messages from somewhere on the web — here I'm placing it in a Github Gist (which works fine, but a bit slowly). You could put it somewhere on a plain old HTTP page served anywhere on the internet.
- Clone this JSON: https://gist.github.com/matthewjohnston4/ef62107655e471384fe027e0738a5c05 and store it where you want.
- Customise the JSON object to add or remove any
"username": "shoutout message"
combinations you want (don't forget those trailing commas). - Note the URL where you placed the file — if you're using a Gist, you should click on the RAW button and use that URL.
- Copy and paste the Nightbot code from here https://gist.github.com/matthewjohnston4/f79505398a512015f055c59398432951 into wherever you configure Nightbot usually. Make sure you update the
urlfetch
URL being used to the URL in step 3 above. - You should be done!
If you want to update an existing shoutout command, change the code in step 4 from !commands add
to !commands edit
and that should work.
## Some notes
The urlfetch
part of Nightbot isn't very efficient, and will sometimes timeout — that's why it might be faster to serve the JSON from a real webpage rather than via Github's Gist system.
I think Gist URLs change any time you update them, which means you'll also have to update your Nightbot command each time. Another reason to serve it from somewhere permanent and fully under your control.
The default message is defined in the Nightbot command code in Step 4 — customise it there — you can use $(query)
anywhere you need to include the username of the shoutoutee.