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.
 
Ryan Richardson 9bace7e18b Fix script for ruy 2.5.1; ignore credentials 5 years ago
Responses Created chatbot.txt 6 years ago
.gitignore Fix script for ruy 2.5.1; ignore credentials 5 years ago
CommandsHandler.rb Fix script for ruy 2.5.1; ignore credentials 5 years ago
LICENSE Initial commit 6 years ago
README.md Fix script for ruy 2.5.1; ignore credentials 5 years ago
TwitchBot.rb Fix script for ruy 2.5.1; ignore credentials 5 years ago

README.md

TwitchChatbot

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.


Preview

alt text


I use this chatbot to preview chat without having a browser open so that I save CPU and RAM. But as you can see in the preview image it's also able to handle custom commands including API commands.


How To Use:

  1. Clone this repo to the system which will run the bot
  2. cd into the repo root and create the file ./credentials.txt (i.e. touch credentials.txt)
  3. Copy/paste into the file as such:
  • OAUTH = "oauth:GENERATED_OAUTH_TOKEN"
    CHANNEL = "TWITCH_CHANNEL_NAME"
    BOTNAME = "TWITCH_USERNAME"
    
  • Generate the token for the OAUTH value from https://twitchapps.com/tmi/
  • The CHANNEL value is the path fragment of your Twitch URL: https://twitch.tv/channel_name
  • The BOTNAME value is your Twitch username or the bot's username (if you created a separate one)
  1. Run ruby TwitchBot.rb

Adding Commands:

Regular Commands:

  1. Open "CommandsHandler.rb" and scroll down to the commands array and add your own.
  2. Go to folder "Responses" and add the command as a text file in all lowercase. Examples have been included

Admin Commands:

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:
admin_commands = { "disconnect" => "PART ##{CHANNEL}" }

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.

alt text

API Commands:

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.
alt text

Then you scroll down to the bottom under # ----- API COMMANDS ----- # and add a function to that command.
alt text


Extras:

The response files in the Responses folder have 3 arguments available (You can add your own)

alt text

In the template the arguments USER, CHANNEL, COMMANDS are available. (COMMANDS shows all available commands)

alt text

License

FOSSA Status