From e900325a668a1b62b56b664473994b9dd91b2f0d Mon Sep 17 00:00:00 2001 From: Tearzz Date: Tue, 24 Apr 2018 14:49:47 +0200 Subject: [PATCH] Updated CommandsHandler.rb Added prefix to each command in commands. Now it shows prefix when using the COMMANDS argument in files. --- CommandsHandler.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CommandsHandler.rb b/CommandsHandler.rb index 74a053d..e42d331 100644 --- a/CommandsHandler.rb +++ b/CommandsHandler.rb @@ -20,6 +20,10 @@ def HandleCommands(line) "commands", "chatbot",] + if commands.length > 0 + commands.map! { |command| prefix + command } # apply prefix to all commands + end + replacements = [ ["USER", "@#{user}"], ["CHANNEL", "#{CHANNEL}"], @@ -50,7 +54,7 @@ def HandleCommands(line) # ----- ADMIN COMMANDS ----- # if user == CHANNEL admin_commands.each do |command, value| - if message.include?(prefix + command) + if message.include?(command) return value + "\r\n" end end @@ -58,7 +62,8 @@ def HandleCommands(line) # ----- COMMANDS ----- # commands.each do |command| - if message.include?(prefix + command) + if message.include?(command) + command.tr!("!", "") # Remove "!" file = open("Responses/" + command + ".txt") response = file.read file.close