From abd5914603d74bb33959f8a6b23808462e18e366 Mon Sep 17 00:00:00 2001 From: mcmlxxix <> Date: Thu, 25 Aug 2011 19:45:17 +0000 Subject: [PATCH] add quote and addquote commands (and fix them too) --- exec/load/ircbot_commands.js | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/exec/load/ircbot_commands.js b/exec/load/ircbot_commands.js index da644729a5..d58f01eac5 100644 --- a/exec/load/ircbot_commands.js +++ b/exec/load/ircbot_commands.js @@ -226,6 +226,43 @@ Bot_Commands["IDENT"].command = function (target,onick,ouh,srv,lvl,cmd) { return; } +Bot_Commands["ADDQUOTE"] = new Bot_Command(80,true,false); +Bot_Commands["ADDQUOTE"].command = function (target,onick,ouh,srv,lvl,cmd) { + cmd.shift(); + var the_quote = cmd.join(" "); + Quotes.push(the_quote); + srv.o(target,"Thanks for the quote!"); + return; +} + +Bot_Commands["QUOTE"] = new Bot_Command(0,false,false); +Bot_Commands["QUOTE"].command = function (target,onick,ouh,srv,lvl,cmd) { + if(Quotes.length == 0) { + srv.o(target,"I have no quotes. :("); + return; + } + if (cmd[1]) { + cmd.shift(); + var searched_quotes = new Object(); + var search_params = cmd.join(" "); + var lucky_number; + while (true_array_len(searched_quotes) < Quotes.length) { + lucky_number = random(Quotes.length); + if (!searched_quotes[lucky_number]) { + if (Quotes[lucky_number].toUpperCase().match(search_params.toUpperCase())) { + srv.o(target, Quotes[lucky_number]); + return; + } + searched_quotes[lucky_number] = true; + } + } + srv.o(target,"Couldn't find a quote that matches your criteria."); + return; + } + srv.o(target, quotes[random(Quotes.length)]); + return; +} + Bot_Commands["GREET"] = new Bot_Command(50,false,false); Bot_Commands["GREET"].usage = get_cmd_prefix() + "GREET <greeting>, " + -- GitLab