______ _____
| ____| / ____|
| |__ _ __ __ _ _ __ ___ ___| | __ __ _ _ __ ___ ___
| __| `__/ _' | '_ ` _ \ / _ \ | |_ |/ _' | '_ ` _ \ / _ \
| | | | | (_| | | | | | | __/ |__| | (_| | | | | | | __/
|_| |_| \__,_|_| |_| |_|\___|\_____|\__,_|_| |_| |_|\___|
- Code by CaperCube
- v0.1
This is a node.js Twitch chat bot that allows your Twitch viewers to submit prompts to a text file on your computer. The idea being that you can then open that file and remove offensive prompts and then use that file in your next round of Frame Game.
If you're feeling lucky, you could change this bot so it overwrites the "FrameGame_Data\StreamingAssets\prompts.txt" file in your FrameGame directory, but I wouldn't reccomend that. Sounds like a Twitch ban waiting to happen.
Feel free to modify this code however you like!
Be cautious of using any code you recive from unknown sources. Node.js applications can be harmful if modified by those with malicious intent.
Here's some beginner / intermediate level instructions to get this bot up and running:
- Install dev environment (I like VSCode)
- Install Node.js on your system
- Create a directory on your system to contain this bot app
- (If Using VSCode) Open your bot directory using File > Open Folder, then click Terminal > New Terminal in the top bar
- The project requires
tmi.jsanddotenvso run the commandnpm installin the terminal - Create a file called
.envin the bot's root directory (wherever yourindex.htmlfile is) - Obtain your OAuth code here at twitchapps
- !!WARNING!! THIS OAUTH CODE GIVES PERMISSIONS TO YOUR TWITCH ACCOUNT!! DO NOT SHOW THIS TO ANYONE! I mean, unless you really trust them or something, but it's best if you don't.
- Fill in the
.envfile like so: (replace everything in [] with your info)# The twitch chanel the bot will joinTWITCH_CHANNEL = [your-twitch-username]# The name of the user the bot will useTWITCH_BOTNAME = [Your-Bots-Name]# The OAUTH code for the user the bot will useOAUTH_CODE = [oauth:******************************]
- Type
node .in the terminal, and hit enter to start the bot - Close VSCode or click in the terminal and press
Ctrl + cto stop the bot
Viewers and mods in your Twitch chat can use chat commands to operate this bot. Here are the commands:
!submit [p] - If submissions are open, this will submit a prompt [p] to the list (if that prompt doesn't already exist)
!help - Prints commands excluding mod commands to the chat. If a mod uses this command, it will print all commands.
!about - Prints info about Frame Game to the chat
!bot - Prints info about the bot to the chat
!open [n] - Opens the prompt submission window for [n] unique prompts. Submissions will close once 25 prompts are submitted. This also resets each viewer's submittion count ([n] is an optional prompt, if not present, will use current value)
!close - Manully closes the submissions and saves to a text file
!clear - Clears all prompts in the prompt list
!ban [u] - Finds ChatUser with name [u] and flags them as banned, also adds them to the banList, then saves the banlist file
!unban [u] - Finds ChatUser with name [u] un-bans them, also removes them from the banList, then saves the banlist file
!clearban - Unbans all users and saves the banlist file
!userlimit [n] - Adjusts how many prompts [n] each user con submit per window
!charlimit [n] - Adjusts prompt character limit
!listlength [n] - Adjusts submission list length
!saveprompts - Saves a .txt file with all the prompts in it
!savelog - Saves a .txt file in "./userlogs/" with the prompt submit logs from this session
!saveban - Saves a .txt file with all banned users
!loadprompts - Loads the "./prompts.txt" file (if the file exists) and appends to the prompt array
(Not done yet) - need to change so it creates new users from the loaded list, and doesn't create duplicate users
!loadbanlist - Loads the "./banlist.txt" file (if the file exists) and appends to the banList array