A Twitch Bot, in Ruby
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
3.1 KiB

  1. # TwitchChatbot
  2. A simple chatbot for Twitch written in Ruby. Used for handling commands and previewing chat so that you don't need to have the browser open and can avoid using a lot of RAM and CPU.
  3. ----
  4. ## Preview
  5. ![alt text](https://i.imgur.com/QOuqtfS.png "Preview of the chat bot")
  6. ----
  7. I use this chatbot to preview chat without having a browser open so that I save CPU and RAM.
  8. But as you can see in the preview image it's also able to handle custom commands including API commands.
  9. ----
  10. ## How To Use:
  11. 1. Clone this repo to the system which will run the bot
  12. 2. `cd` into the repo root and create the file `./credentials.txt` (i.e. `touch credentials.txt`)
  13. 2. Copy/paste into the file as such:
  14. * OAUTH = "oauth:GENERATED_OAUTH_TOKEN"
  15. CHANNEL = "TWITCH_CHANNEL_NAME"
  16. BOTNAME = "TWITCH_USERNAME"
  17. * Generate the token for the **OAUTH value** from
  18. <https://twitchapps.com/tmi/>
  19. * The **CHANNEL value** is the path fragment of your Twitch URL:
  20. <s>https://twitch.tv/</s>channel_name
  21. * The **BOTNAME value** is your Twitch username or the bot's
  22. username (if you created a separate one)
  23. 2. Run `ruby TwitchBot.rb`
  24. ----
  25. ## **Adding Commands:**
  26. ### **Regular Commands:**
  27. 1. Open **"CommandsHandler.rb"** and scroll down to the `commands` array and add your own.
  28. 2. Go to folder **"Responses"** and add the command as a text file in all lowercase. _Examples have been included_
  29. ### **Admin Commands:**
  30. If you are adding admin commands add a custom response next to it. There you'll be able to add commands that gives data to the socket instead of a chat message as a response. Example:
  31. `admin_commands = {
  32. "disconnect" => "PART ##{CHANNEL}"
  33. }`
  34. When the command `"!disconnect"` has been typed in chat by the channel owner _(or anyone specified in the `admins` array)_ it will send a request to disconnect from the current Twitch channel.
  35. ![alt text](https://i.imgur.com/iYtSvaG.png "Prefix, commands and admin commands")
  36. ### **API Commands:**
  37. If you want to add API commands you just scroll down to `# ----- API COMMANDS ----- #` _(First section after receiving messages)_ and add your commands. In the example it calls some functions which are made at the bottom of the script.
  38. ![alt text](https://i.imgur.com/CBF7vYf.png "Right after the received messages section")
  39. Then you scroll down to the bottom under `# ----- API COMMANDS ----- #` and add a function to that command.
  40. ![alt text](https://i.imgur.com/xejccqp.png "Here you add your dedicated function for the API command")
  41. ----
  42. ## Extras:
  43. _**The response files in the Responses folder have 3 arguments available**_ (You can add your own)
  44. ![alt text](https://i.imgur.com/Pb6JPz8.png "Preview of command arguments")
  45. In the template the arguments USER, CHANNEL, COMMANDS are available. _(COMMANDS shows all available commands)_
  46. ![alt text](https://i.imgur.com/7oRcLvw.png "Here you can add your replacements")
  47. ## License
  48. [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FBenTearzz%2FRubyTwitchChatbot.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FBenTearzz%2FRubyTwitchChatbot?ref=badge_large)