Reconfigured bot.lua, added in echoClean

pull/1/head
Astoria Floyd 3 years ago
parent e848c66804
commit 1cef81445d

@ -18,28 +18,36 @@ end)
--Command handler --Command handler
client:on('messageCreate', function(message) client:on('messageCreate', function(message)
if message.author.bot then return end if message.author.bot then return end
local shouldReinit = false
if Tools.testModeDetection() == true and mode == "normal" then if Tools.testModeDetection() == true and mode == "normal" then
mode = "testMode" mode = "testMode"
shouldReinit = true
elseif Tools.testModeDetection() == false and mode == "testMode" then elseif Tools.testModeDetection() == false and mode == "testMode" then
mode = "normal" mode = "normal"
selfReinitialize() shouldReinit = false
end end
if mode == "testMode" then if mode == "testMode" then
Commands = Tools.initialize() shouldReinit = true
Tools = dofile("./API/tools.lua") end
if mode == "normal" and Tools.messageDectection(message, "reinitialize") == true then
p("reinitd at "..os.time()) 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
local args = message.content:split(" ") local args = message.content:split(" ")
local lowerArgs = args[1]:lower() local lowerArgs = args[1]:lower()
local command = Commands[lowerArgs] local command = Commands[lowerArgs]
if command then 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) 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
end) end)

@ -54,6 +54,20 @@ end
local echo = string.sub(message.content, 5+prefixLength) local echo = string.sub(message.content, 5+prefixLength)
local echoed = tools.echo(echo) local echoed = tools.echo(echo)
local result = "```fix" .. "\n" .. echoed .. "```" 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.channel:send(result)
message:delete() message:delete()
end end

@ -9,14 +9,12 @@ local commands = { -- Define commands its a table that will contain our commands
message.channel:send("Experimental mode works!") message.channel:send("Experimental mode works!")
end end
}; };
--[[
[prefix..'test'] = { -- Test Command. [prefix..'fumo'] = { -- To be implemented later..
exec = function (message) 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 end
}; };
]]
} }
function experimentalCommands.initialize() function experimentalCommands.initialize()

@ -2,15 +2,15 @@
Basic functions Basic functions
--------------- ---------------
-figlet -figlet
Converts text to ASCII art Converts text to ASCII art. Currently disabled due to security problems.
-cowsay -cowsay
Converts text to the speech of a cow Converts text to the speech of a cow. Currently disabled due to security problems.
-ping -ping
Pong! Pong!
-roll [Argument] -roll [Argument]
Rolls a dice, by default d20! Rolls a dice, by default d20!
-time -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 -helpme
^-^ ^-^
Basic Information Basic Information
@ -18,7 +18,7 @@ Basic Information
All functions start with '!' though this may change in the future 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!) Under construction! More or less from scratch(Only just got basic I/O working!)
May have secret functions! May have secret functions!
Mess with the code Mess with the code to your hearts content.
------------------ ------------------
The source code is freely availible at The source code is freely availible at
https://github.com/AstoriaFloyd/thembot https://github.com/AstoriaFloyd/thembot

@ -2,31 +2,29 @@
Basic functions Basic functions
--------------- ---------------
-figlet -figlet
Converts text to ASCII art Converts text to ASCII art. Currently disabled due to security problems.
-cowsay -cowsay
Converts text to the speech of a cow Converts text to the speech of a cow. Currently disabled due to security problems.
-ping -ping
Pong! Pong!
-roll [Argument] -roll [Argument]
Rolls a dice, by default d20! Rolls a dice, by default d20!
-time -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 -helpme
^-^ ^-^
Basic Information Basic Information
----------------- -----------------
All functions start with '!' though this may change in the future 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!) Under construction! More or less from scratch(Only just got basic I/O working!)
May have secret functions! May have secret functions!
Mess with the code Mess with the code to your hearts content.
------------------ ------------------
The source code is freely availible at The source code is freely availible at
https://github.com/AstoriaFloyd/thembot https://github.com/AstoriaFloyd/thembot
Feel free to modify, redistribute, whatever. Feel free to modify, redistribute, whatever.
If you want to monitise it, sure go ahead. If you want to monitise it, sure go ahead.
This code follows the WTFPL, in all 0 of its conditions. This code follows the WTFPL, in all 0 of its conditions.
Extra Information Extra Information
----------------- -----------------
This bot is currently in text mode. This bot is currently in text mode.

Loading…
Cancel
Save