├── .gitignore ├── scripts └── startBot.sh ├── .env.example ├── commands ├── drinkWater.js ├── lightsValentine.js ├── twitter.js ├── podcast.js ├── youtube.js ├── discord.js ├── fail.js ├── lightsOff.js ├── lightsOn.js ├── lightsChristmas.js ├── lightsRandom.js ├── song.js ├── randomTheme.js ├── hype.js └── commands.js ├── TwitchChatBot.js ├── package.json └── ReadMe.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .env -------------------------------------------------------------------------------- /scripts/startBot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd .. 3 | npm run dev 4 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | TWITCH_USERNAME= 2 | TWITCH_PASSWORD= 3 | HUE_BRIDGE_IP= 4 | HUE_USERNAME= 5 | HUE_LIGHT_IDS= 6 | SOUND_EFFECTS_DIRECTORY= 7 | VSCODE_SETTINGS_PATH= 8 | TWITCH_ID= -------------------------------------------------------------------------------- /commands/drinkWater.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | callback: (channel, tags, message, self, client) => { 3 | client.say(channel, 'Let me grab my drink!'); 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /commands/lightsValentine.js: -------------------------------------------------------------------------------- 1 | const { playSound, hue, lightIds } = require('jqq-stream-utils'); 2 | 3 | module.exports = { 4 | callback: () => { 5 | hue.setColors(lightIds, 'pink'); 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /commands/twitter.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | callback: async (channel, tags, message, self, client) => { 3 | client.say(channel, "Follow me on Twitter at https://www.twitter.com/jamesqquick"); 4 | }, 5 | 6 | }; 7 | -------------------------------------------------------------------------------- /commands/podcast.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | callback: async (channel, tags, message, self, client) => { 3 | client.say(channel, "Check out the Compressed.fm podcast at https://www.compressed.fm"); 4 | }, 5 | 6 | }; 7 | -------------------------------------------------------------------------------- /commands/youtube.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | callback: async (channel, tags, message, self, client) => { 3 | client.say(channel, "Check out my YouTube channel at https://www.youtube.com/jamesqquick"); 4 | }, 5 | 6 | }; 7 | -------------------------------------------------------------------------------- /commands/discord.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | callback: async (channel, tags, message, self, client) => { 3 | client.say(channel, "Check out the Learn Build Teach Discord at https://www.learnbuildteach.com"); 4 | }, 5 | 6 | }; 7 | -------------------------------------------------------------------------------- /commands/fail.js: -------------------------------------------------------------------------------- 1 | const { playSound } = require('jqq-stream-utils'); 2 | 3 | module.exports = { 4 | callback: () => { 5 | playSound('fail.wav'); 6 | }, 7 | userCooldown: 300, 8 | globalCooldown: 300, 9 | }; 10 | -------------------------------------------------------------------------------- /commands/lightsOff.js: -------------------------------------------------------------------------------- 1 | const { playSound, hue, lightIds } = require('jqq-stream-utils'); 2 | 3 | module.exports = { 4 | callback: () => { 5 | playSound('light-switch.wav'); 6 | hue.turnOffLights(lightIds); 7 | }, 8 | globalCooldown: 60, 9 | }; 10 | -------------------------------------------------------------------------------- /commands/lightsOn.js: -------------------------------------------------------------------------------- 1 | const { playSound, hue, lightIds } = require('jqq-stream-utils'); 2 | 3 | module.exports = { 4 | callback: () => { 5 | playSound('light-switch.wav'); 6 | hue.turnOnLights(lightIds); 7 | }, 8 | globalCooldown: 60, 9 | }; 10 | -------------------------------------------------------------------------------- /commands/lightsChristmas.js: -------------------------------------------------------------------------------- 1 | const { playSound, hue, lightIds } = require('jqq-stream-utils'); 2 | 3 | module.exports = { 4 | callback: (...args) => { 5 | playSound('light-switch.wav'); 6 | hue.setColor(lightIds[0], 'green'); 7 | hue.setColor(lightIds[1], 'red'); 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /commands/lightsRandom.js: -------------------------------------------------------------------------------- 1 | const { playSound, hue, lightIds } = require('jqq-stream-utils'); 2 | 3 | module.exports = { 4 | callback: () => { 5 | playSound('light-switch.wav'); 6 | hue.turnOnAllLights(); 7 | lightIds.forEach((id) => hue.setColor(id, 'random')); 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /TwitchChatBot.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config(); 2 | const { QuickTwitchBot } = require('quick-chat-bot'); 3 | const path = require('path'); 4 | const bot = new QuickTwitchBot({ 5 | username: process.env.TWITCH_USERNAME, 6 | password: process.env.TWITCH_PASSWORD, 7 | channel: process.env.TWITCH_USERNAME, 8 | commandsDir: path.join(__dirname, 'commands'), 9 | }); 10 | bot.connect(); 11 | -------------------------------------------------------------------------------- /commands/song.js: -------------------------------------------------------------------------------- 1 | const { getCurrentSong } = require('jqq-stream-utils'); 2 | 3 | module.exports = { 4 | callback: async (channel, tags, message, self, client) => { 5 | const { err, data } = await getCurrentSong(); 6 | console.log(err, data); 7 | if (data) { 8 | client.say(channel, `Currently playing - ${data}`); 9 | } 10 | }, 11 | globalCooldown: 30, 12 | }; 13 | -------------------------------------------------------------------------------- /commands/randomTheme.js: -------------------------------------------------------------------------------- 1 | const { playSound, setRandomTheme } = require('jqq-stream-utils'); 2 | 3 | module.exports = { 4 | callback: async (channel, tags, message, self, client) => { 5 | console.log('Responding to command: randomTheme'); 6 | const theme = await setRandomTheme(); 7 | playSound('coin.wav'); 8 | client.say(channel, `Switched to '${theme}' theme.`); 9 | }, 10 | globalCooldown: 60, 11 | userCooldown: 300, 12 | }; 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "james-q-quick-twitch-bot", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "Airtable.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "start": "node TwitchChatBot.js", 11 | "dev": "nodemon TwitchChatBot.js" 12 | }, 13 | "keywords": [], 14 | "author": "", 15 | "license": "ISC", 16 | "dependencies": { 17 | "axios": "^0.21.1", 18 | "dotenv": "^8.2.0", 19 | "jqq-stream-utils": "^0.0.6", 20 | "quick-chat-bot": "0.0.2" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /commands/hype.js: -------------------------------------------------------------------------------- 1 | const { 2 | setRandomTheme, 3 | playSound, 4 | hue, 5 | lightIds, 6 | } = require('jqq-stream-utils'); 7 | 8 | module.exports = { 9 | callback: (channel, tags, message, self, client) => { 10 | hue.updateLight(lightIds[0], { transitionTime: 1 }); 11 | hue.updateLight(lightIds[1], { transitionTime: 1 }); 12 | hue.blinkLights(lightIds, 300, 10); 13 | setRandomTheme(); 14 | for (let i = 0; i < 10; i++) { 15 | setTimeout(setRandomTheme, 0 + i * 400); 16 | } 17 | playSound('light-switch.wav'); 18 | client.say(channel, "IT'S HYPE TIME!"); 19 | }, 20 | globalCooldown: 60, 21 | }; 22 | -------------------------------------------------------------------------------- /commands/commands.js: -------------------------------------------------------------------------------- 1 | const { playSound, setRandomTheme } = require('jqq-stream-utils'); 2 | 3 | module.exports = { 4 | callback: async (channel, tags, message, self, client) => { 5 | client.say( 6 | channel, 7 | `Here are the list of commands you can run. 8 | !drinkWater - Drink some water! 9 | !randomTheme - Switch to a random VS Code theme! 10 | !discord - Join the Learn Build Teach Discord! 11 | !twitter - Follow me on Twitter! 12 | !youtube - Subscribe to my YouTube channel! 13 | !podcast - Check out the Compressed.fm Podcast! 14 | !lightsOn - Turn on the lights! 15 | !lightsOff - Turn off the lights! 16 | !lightsRandom - Turn on the lights to a random color! 17 | !lightsValentine - Turn on the lights to a Valentine's Day theme! 18 | !fail - Play a fail sound! 19 | !hype - Play sounds and lights to hype up the stream!` 20 | ); 21 | }, 22 | globalCooldown: 60, 23 | userCooldown: 300, 24 | }; 25 | -------------------------------------------------------------------------------- /ReadMe.md: -------------------------------------------------------------------------------- 1 | # James Q Quick Twitch Bot 2 | 3 | This is a Twitch bot built in JavaScript using the `tmi.js` library. 4 | 5 | ## Table of Contents 6 | 7 | - [Installation](#installation) 8 | - [Configuration](#configuration) 9 | - [Running the Bot](#running-the-bot) 10 | - [Adding Custom Commands](#adding-custom-commands) 11 | - [Support & Contributions](#support--contributions) 12 | - [License](#license) 13 | 14 | ## Installation 15 | 16 | 1. Make sure you have [Node.js](https://nodejs.org/en/) installed on your machine (version 12 or higher is recommended). 17 | 2. Clone the repository: 18 | 19 | ```bash 20 | git clone https://github.com/jamesqquick/James-Q-Quick-Twitch-Bot.git 21 | ``` 22 | 23 | Install the required dependencies: 24 | 25 | ```bash 26 | npm install 27 | ``` 28 | 29 | ## Configuration 30 | 31 | Rename the `.env.example` file to `.env`. 32 | 33 | Open the `.env` file and fill in the required information: 34 | 35 | ```bash 36 | TWITCH_USERNAME= 37 | TWITCH_PASSWORD= 38 | HUE_BRIDGE_IP= 39 | HUE_USERNAME= 40 | HUE_LIGHT_IDS= 41 | SOUND_EFFECTS_DIRECTORY= 42 | VSCODE_SETTINGS_PATH= 43 | TWITCH_ID= 44 | ``` 45 | 46 | ## Running the Bot 47 | 48 | To start the bot, simply run the following command: 49 | 50 | ```bash 51 | npm start 52 | ``` 53 | 54 | ## Adding Custom Commands 55 | 56 | Navigate to the src/commands folder. 57 | 58 | Create a new JavaScript file for your custom command, e.g., `myCommand.js`. In the new file, create your custom command by following the format below: 59 | 60 | ```JavaScript 61 | module.exports = { 62 | callback: async (channel, tags, message, self, client) => { 63 | client.say( 64 | channel, 65 | `Hello World` 66 | ); 67 | }, 68 | globalCooldown: 60, 69 | userCooldown: 300, 70 | }; 71 | ``` 72 | 73 | ## Support & Contributions 74 | 75 | If you have any questions or need support, feel free to open an issue or submit a pull request. Contributions are always welcome! 76 | 77 | ## License 78 | 79 | This project is licensed under the MIT License. See the [LICENSE](https://chat.openai.com/LICENSE) file for more details. 80 | --------------------------------------------------------------------------------