Chat game a la 'Hot Potato'

Hi all, I am looking to create what is essentially a dressed-up and flavoured game of Hot Potato, with a couple twists, for a channel I moderate. The basic concept is, a user can call the command, and will toss a ball to a random other user in the chat. Then that user can call the command to toss one to another random user, and so on.

I know a command can @ a random user easily, but there are a few things I’m not sure of how to pull off, if they are possible:

  • I want the command to only chose a random user IF the user calling the command was chosen as the random user of the last instance of the command.
  • further, if possible, I’d like to add a cooldown period where, if the chosen randomuser doesn’t call the command, it can be reset so that the game can resume).
  • I want there to be an alias to this command that functions exactly the same way in regards to the above restriction, but prints different flavour text, so users can choose either command and still be playing the same game of ‘hot potato’.

It’s pretty ambitious, but I’d appreciate any help or response anyone’s able to give me.

You would need to build a custom API that our commands can interact with to build something like this, since you would need to store state of the hot potato game (we don’t offer a way to store state natively at this time)

1 Like

@tulsaeh

It’s possible using ehsankia’s quote list CustomAPI - read more about it here.


About the aspects of your Hot Potato game:

  • The commands I have set up below use the API to store the username of whoever is currently in possession of the hot potato. If the command user is in possession, the command user’s name is removed and another random user’s name is stored. If not, Nightbot will remind chat who actually is in possession.

  • As far as I know, Nightbot isn’t capable of keeping track of time elapsed since a command was used, so it’s neither possible to have a cooldown period nor have Nightbot automatically reset the game. This is why I’ve set up a command for mods to reset the game manually if there is a user who won’t continue the game.

  • I thought it would be better if there was one command !hotpotato that had multiple possible outputs rather than multiple commands each having their own output. This pastebin file is where I am storing those possible outputs. You can either use my paste or create your own.

    If you create your own, make sure to follow the same formatting in my file and change the pastebin link used in the command response (the link is found in the middle of the command response for _hp). The file starts and ends with square brackets. Each output is bounded by backticks `` and separated by commas. p1 represents the ‘sender’ of the hot potato and p2 represents the ‘receiver’, which the command will replace with the corresponding usernames.


Click this link. It will generate three links and two tokens, a public token (8 characters long) and a private token (16 characters long). The public token is located within the first generated link. The private token is located within both the second and third generated links. The tokens are found after token= and before &data=$(querystring) Copy them down and keep them somewhere safe!

I’ve set up 3 commands: !hotpotato and _hp which work in tandem to check whether the user is currently in possession of the ‘hot potato’ and output an appropriate response, and !reset which resets the hot potato game (mod-only). Copy and paste them into chat. Replace PUBLIC_TOKEN with your public token and PRIVATE_TOKEN with your private token:

!addcom -cd=5 !hotpotato -a=_hp $(eval u=`$(user)`.toLowerCase();a=JSON.parse(`$(urlfetch json http://tmi.twitch.tv/group/user/$(channel)/chatters)`).chatters;b=a.moderators.concat(a.staff,a.admins,a.global_mods,a.viewers).filter(c=>![u,$(urlfetch json https://pastebin.com/raw/mtfpjMTp)].some(d=>c==d));e=`$(urlfetch https://twitch.center/customapi/quote?token=PUBLIC_TOKEN&data=0&no_id=1)`;e==u||e==`There are no quotes added`?`PRIVATE_TOKEN `+b[Math.floor(Math.random()*b.length)]:e)

!addcom -cd=5 _hp $(eval a=`$(urlfetch https://twitch.center/customapi/delquote?token=$(1)&clear=1)`;b=`$(urlfetch https://twitch.center/customapi/addquote?token=$(1)&data=$(2))`;c=$(urlfetch json https://pastebin.com/raw/KqzVrruf);`$(query)`.includes(`PRIVATE_TOKEN`)?c[Math.floor(Math.random()*c.length)].replace(/p1/gi,`$(user)`).replace(/p2/gi,`$(2)`):`$(1) is currently in possession!`)

!addcom -ul=mod !reset $(eval a=`$(urlfetch https://twitch.center/customapi/delquote?token=PRIVATE_TOKEN&clear=1)`;`$(user) has reset the hot potato game!`)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.