Browse Source

Fix script for ruy 2.5.1; ignore credentials

master
Ryan Richardson 5 years ago
parent
commit
9bace7e18b
5 changed files with 19 additions and 19 deletions
  1. +2
    -0
      .gitignore
  2. +4
    -4
      CommandsHandler.rb
  3. +13
    -2
      README.md
  4. +0
    -6
      TwitchBot.rb
  5. +0
    -7
      credentials.txt

+ 2
- 0
.gitignore View File

@ -0,0 +1,2 @@
credentials.txt
log.txt

+ 4
- 4
CommandsHandler.rb View File

@ -7,11 +7,11 @@ def HandleCommands(line)
# moderators = 100 messages (within a 30 second window) # moderators = 100 messages (within a 30 second window)
# default = 20 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 # max_messages is set to 80 just to keep it safe
user = "" # Required to (Avoid "undefined local variable or method `user'") user = "" # Required to (Avoid "undefined local variable or method `user'")
prefix = "!" prefix = "!"
admins = [ admins = [
#"exampleuser1_inlowercase", #"exampleuser1_inlowercase",
#"exampleuser2_inlowercase" #"exampleuser2_inlowercase"
@ -48,7 +48,7 @@ def HandleCommands(line)
original_message = match && match[3] original_message = match && match[3]
if original_message =~ /^/ if original_message =~ /^/
original_message.strip! original_message.strip!
message = original_message.downcase!
message = original_message.downcase
user = match[1] # Get username user = match[1] # Get username
if message if message

+ 13
- 2
README.md View File

@ -14,8 +14,19 @@ But as you can see in the preview image it's also able to handle custom commands
---- ----
## How To Use: ## 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
<https://twitchapps.com/tmi/>
* The **CHANNEL value** is the path fragment of your Twitch URL:
<s>https://twitch.tv/</s>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`
---- ----

+ 0
- 6
TwitchBot.rb View File

@ -26,11 +26,6 @@ log.info("Loading \"credentials.txt\"")
require_relative('CommandsHandler') # File for handling commands require_relative('CommandsHandler') # File for handling commands
log.info("Loading \"CommandsHandler.rb\"") log.info("Loading \"CommandsHandler.rb\"")
# -------- IGNORE -------- #
OAUTH.downcase!
BOTNAME.downcase!
CHANNEL.downcase!.gsub!("#", "")
# Save "Preparing to connect" to "log.txt" # Save "Preparing to connect" to "log.txt"
log.info("Preparing to connect") log.info("Preparing to connect")
@ -63,7 +58,6 @@ Thread.start do
puts "" puts ""
while (running) do while (running) do
ready = IO.select([socket]) ready = IO.select([socket])
ready[0].each do |s| ready[0].each do |s|
line = s.gets line = s.gets
if line =~ /^/ if line =~ /^/

+ 0
- 7
credentials.txt View File

@ -1,7 +0,0 @@
OAUTH = "OAUTH:TokenRightHere"
BOTNAME = "YourBotName"
CHANNEL = "ChannelToJoin"
# ---------------
# OAUTH token (https://twitchapps.com/tmi/)
# ---------------

Loading…
Cancel
Save