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
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)

@ -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

@ -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()

@ -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

@ -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.

Loading…
Cancel
Save