From 9bace7e18b00538fbb3e6f982621035f6f3ae01a Mon Sep 17 00:00:00 2001 From: Ryan Richardson Date: Sat, 2 Mar 2019 08:51:01 -0800 Subject: [PATCH] Fix script for ruy 2.5.1; ignore credentials --- .gitignore | 2 ++ CommandsHandler.rb | 8 ++++---- README.md | 15 +++++++++++++-- TwitchBot.rb | 6 ------ credentials.txt | 7 ------- 5 files changed, 19 insertions(+), 19 deletions(-) create mode 100644 .gitignore delete mode 100644 credentials.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2a61416 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +credentials.txt +log.txt diff --git a/CommandsHandler.rb b/CommandsHandler.rb index b4c7f81..9718965 100644 --- a/CommandsHandler.rb +++ b/CommandsHandler.rb @@ -7,11 +7,11 @@ def HandleCommands(line) # moderators = 100 messages (within a 30 second window) # default = 20 messages (within a 30 second window) # max_messages is set to 80 just to keep it safe - + user = "" # Required to (Avoid "undefined local variable or method `user'") - + prefix = "!" - + admins = [ #"exampleuser1_inlowercase", #"exampleuser2_inlowercase" @@ -48,7 +48,7 @@ def HandleCommands(line) original_message = match && match[3] if original_message =~ /^/ original_message.strip! - message = original_message.downcase! + message = original_message.downcase user = match[1] # Get username if message diff --git a/README.md b/README.md index ced4e51..33acded 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,19 @@ But as you can see in the preview image it's also able to handle custom commands ---- ## How To Use: -1. Open **"credentials.txt"** and replace OAUTH, BOTNAME and CHANNEL with the values you need. -2. Run **"TwitchBot.rb"** +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`) +2. 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 + + * 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) +2. Run `ruby TwitchBot.rb` ---- diff --git a/TwitchBot.rb b/TwitchBot.rb index 18bc094..dce246a 100644 --- a/TwitchBot.rb +++ b/TwitchBot.rb @@ -26,11 +26,6 @@ log.info("Loading \"credentials.txt\"") require_relative('CommandsHandler') # File for handling commands log.info("Loading \"CommandsHandler.rb\"") -# -------- IGNORE -------- # -OAUTH.downcase! -BOTNAME.downcase! -CHANNEL.downcase!.gsub!("#", "") - # Save "Preparing to connect" to "log.txt" log.info("Preparing to connect") @@ -63,7 +58,6 @@ Thread.start do puts "" while (running) do ready = IO.select([socket]) - ready[0].each do |s| line = s.gets if line =~ /^/ diff --git a/credentials.txt b/credentials.txt deleted file mode 100644 index 34a3588..0000000 --- a/credentials.txt +++ /dev/null @@ -1,7 +0,0 @@ -OAUTH = "OAUTH:TokenRightHere" -BOTNAME = "YourBotName" -CHANNEL = "ChannelToJoin" - -# --------------- -# OAUTH token (https://twitchapps.com/tmi/) -# --------------- \ No newline at end of file