From 1cef81445d75e4518417a7df35b95e474276ffb1 Mon Sep 17 00:00:00 2001 From: Astoria Floyd Date: Tue, 10 Aug 2021 19:01:08 -0500 Subject: [PATCH] Reconfigured bot.lua, added in echoClean --- bot.lua | 26 +++++++++++++++++--------- commands/complexCommands.lua | 14 ++++++++++++++ commands/experimentalCommands.lua | 8 +++----- docs/help | 8 ++++---- docs/helpTestMode | 10 ++++------ 5 files changed, 42 insertions(+), 24 deletions(-) diff --git a/bot.lua b/bot.lua index ba6588b..5e5d328 100644 --- a/bot.lua +++ b/bot.lua @@ -18,28 +18,36 @@ end) --Command handler client:on('messageCreate', function(message) if message.author.bot then return end + local shouldReinit = false if Tools.testModeDetection() == true and mode == "normal" then mode = "testMode" + shouldReinit = true elseif Tools.testModeDetection() == false and mode == "testMode" then mode = "normal" - selfReinitialize() + shouldReinit = false end if mode == "testMode" then - Commands = Tools.initialize() - Tools = dofile("./API/tools.lua") + shouldReinit = true + end + if mode == "normal" and Tools.messageDectection(message, "reinitialize") == true then p("reinitd at "..os.time()) + reinitialize(message) + elseif mode == "testMode" and Tools.messageDectection(message, "reinitialize") == true then + message:reply("You cannot preform this command because testMode is on!") + p("Not reinitd at "..os.time()) end local args = message.content:split(" ") local lowerArgs = args[1]:lower() local command = Commands[lowerArgs] if command then + if shouldReinit == true then + Commands = Tools.initialize() + Tools = dofile("./API/tools.lua") + command = Commands[lowerArgs] + p("reinitd at "..os.time()) + shouldReinit = false + end command.exec(message, args) - elseif mode == "normal" and Tools.messageDectection(message, "reinitialize") == true then - p("reinitd at "..os.time()) - reinitialize(message) - elseif mode == "testMode" and Tools.messageDectection(message, "reinitialize") == true then - message:reply("You cannot preform this command because testMode is on!") - p("Not reinitd at "..os.time()) end end) diff --git a/commands/complexCommands.lua b/commands/complexCommands.lua index 15b2f72..3f3da99 100644 --- a/commands/complexCommands.lua +++ b/commands/complexCommands.lua @@ -54,6 +54,20 @@ end local echo = string.sub(message.content, 5+prefixLength) local echoed = tools.echo(echo) local result = "```fix" .. "\n" .. echoed .. "```" + if result == "```fix\n```" then message:delete() return + else + message.channel:send(result) + message:delete() + end +end +}; + +[prefix..'echoclean'] = { -- Echo's what you said back out, in a fix codeblock. Could be against TOS. + exec = function (message) + local prefixLength = string.len(prefix) + local echo = string.sub(message.content, 10+prefixLength) + local echoed = tools.echo(echo) + local result = echoed message.channel:send(result) message:delete() end diff --git a/commands/experimentalCommands.lua b/commands/experimentalCommands.lua index e9bed00..f56c75f 100644 --- a/commands/experimentalCommands.lua +++ b/commands/experimentalCommands.lua @@ -9,14 +9,12 @@ local commands = { -- Define commands its a table that will contain our commands message.channel:send("Experimental mode works!") end }; - -[prefix..'test'] = { -- Test Command. +--[[ +[prefix..'fumo'] = { -- To be implemented later.. exec = function (message) - message.channel:send("I can add new commands on the fly, probably just going to be for testing purposes. Probably a security hole. Hence why this is the _experimental_ branch") - message:delete() end }; - +]] } function experimentalCommands.initialize() diff --git a/docs/help b/docs/help index 7916da4..8304f54 100644 --- a/docs/help +++ b/docs/help @@ -2,15 +2,15 @@ Basic functions --------------- -figlet -Converts text to ASCII art +Converts text to ASCII art. Currently disabled due to security problems. -cowsay -Converts text to the speech of a cow +Converts text to the speech of a cow. Currently disabled due to security problems. -ping Pong! -roll [Argument] Rolls a dice, by default d20! -time -Displays the time in military time, as if you were in chicago +Displays the time in military time, as if you were in chicago. -helpme ^-^ Basic Information @@ -18,7 +18,7 @@ Basic Information All functions start with '!' though this may change in the future Under construction! More or less from scratch(Only just got basic I/O working!) May have secret functions! -Mess with the code +Mess with the code to your hearts content. ------------------ The source code is freely availible at https://github.com/AstoriaFloyd/thembot diff --git a/docs/helpTestMode b/docs/helpTestMode index 3480d5b..18c3ced 100644 --- a/docs/helpTestMode +++ b/docs/helpTestMode @@ -2,31 +2,29 @@ Basic functions --------------- -figlet -Converts text to ASCII art +Converts text to ASCII art. Currently disabled due to security problems. -cowsay -Converts text to the speech of a cow +Converts text to the speech of a cow. Currently disabled due to security problems. -ping Pong! -roll [Argument] Rolls a dice, by default d20! -time -Displays the time in military time, as if you were in chicago +Displays the time in military time, as if you were in chicago. -helpme ^-^ - Basic Information ----------------- All functions start with '!' though this may change in the future Under construction! More or less from scratch(Only just got basic I/O working!) May have secret functions! -Mess with the code +Mess with the code to your hearts content. ------------------ The source code is freely availible at https://github.com/AstoriaFloyd/thembot Feel free to modify, redistribute, whatever. If you want to monitise it, sure go ahead. This code follows the WTFPL, in all 0 of its conditions. - Extra Information ----------------- This bot is currently in text mode.