Browse Source

Updated CommandsHandler.rb

Added prefix to each command in commands.
Now it shows prefix when using the COMMANDS argument in files.
master
Tearzz 6 years ago
committed by GitHub
parent
commit
e900325a66
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions
  1. +7
    -2
      CommandsHandler.rb

+ 7
- 2
CommandsHandler.rb View File

@ -20,6 +20,10 @@ def HandleCommands(line)
"commands", "commands",
"chatbot",] "chatbot",]
if commands.length > 0
commands.map! { |command| prefix + command } # apply prefix to all commands
end
replacements = [ replacements = [
["USER", "@#{user}"], ["USER", "@#{user}"],
["CHANNEL", "#{CHANNEL}"], ["CHANNEL", "#{CHANNEL}"],
@ -50,7 +54,7 @@ def HandleCommands(line)
# ----- ADMIN COMMANDS ----- # # ----- ADMIN COMMANDS ----- #
if user == CHANNEL if user == CHANNEL
admin_commands.each do |command, value| admin_commands.each do |command, value|
if message.include?(prefix + command)
if message.include?(command)
return value + "\r\n" return value + "\r\n"
end end
end end
@ -58,7 +62,8 @@ def HandleCommands(line)
# ----- COMMANDS ----- # # ----- COMMANDS ----- #
commands.each do |command| commands.each do |command|
if message.include?(prefix + command)
if message.include?(command)
command.tr!("!", "") # Remove "!"
file = open("Responses/" + command + ".txt") file = open("Responses/" + command + ".txt")
response = file.read response = file.read
file.close file.close

Loading…
Cancel
Save