ALSO BIG SECURITY HOLE

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

@ -9,12 +9,25 @@ end
--Initializes commands.
function tools.initialize()
local simpleCommands = dofile("./commands/simpleCommands.lua")
local complexCommands = dofile("./commands/complexCommands.lua")
local complexCommands = complexCommands.initialize()
local simpleCommands = simpleCommands.initialize()
local commands = tools.tableMerge(simpleCommands, complexCommands)
return commands
if tools.testModeDetection() == false then
local simpleCommands = dofile("./commands/simpleCommands.lua")
local complexCommands = dofile("./commands/complexCommands.lua")
local complexCommands = complexCommands.initialize()
local simpleCommands = simpleCommands.initialize()
local commands = tools.tableMerge(simpleCommands, complexCommands)
return commands
end
if tools.testModeDetection() == true then
local simpleCommands = dofile("./commands/simpleCommands.lua")
local complexCommands = dofile("./commands/complexCommands.lua")
local experimentalCommands = dofile("./commands/experimentalCommands.lua")
local simpleCommands = simpleCommands.initialize()
local complexCommands = complexCommands.initialize()
local experimentalCommands = experimentalCommands.initialize()
local commandsP1 = tools.tableMerge(simpleCommands, complexCommands)
local commands = tools.tableMerge(commandsP1, experimentalCommands)
return commands
end
end
--Reads testmode.lua

@ -7,25 +7,39 @@ discordia.extensions()
client:once("ready", function()
client:setGame("Astoria's bot, very sad!")
print('Logged in as '.. client.user.username)
Commands = Tools.initialize()
Commands = Tools.initialize()
if Tools.testModeDetection() == true then
mode = "testMode"
else
mode = "normal"
end
end)
--Command handler
client:on('messageCreate', function(message)
if message.author.bot then return end
if Tools.testModeDetection() == true then
if Tools.testModeDetection() == true and mode == "normal" then
mode = "testMode"
elseif Tools.testModeDetection() == false and mode == "testMode" then
mode = "normal"
selfReinitialize()
end
if mode == "testMode" then
Commands = Tools.initialize()
Tools = dofile("./API/tools.lua")
p("reinitd at "..os.time())
end
local args = message.content:split(" ")
local lowerArgs = args[1]:lower()
local command = Commands[lowerArgs]
if command then
command.exec(message, args)
elseif Tools.testModeDetection() == false and Tools.messageDectection(message, "reinitialize") == true then
elseif mode == "normal" and Tools.messageDectection(message, "reinitialize") == true then
p("reinitd at "..os.time())
reinitialize(message)
elseif Tools.testModeDetection() == true and Tools.messageDectection(message, "reinitialize") == true then
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)
@ -42,6 +56,11 @@ function reinitialize(message)
end
end
function selfReinitialize()
Commands = Tools.initialize()
Tools = dofile("./API/tools.lua")
end
--When a user is banned, post a lenney.
client:on('userBan', function()
local banChannel, err = client:getChannel("872283716486066200")

@ -1,13 +1,16 @@
local tools = dofile("./API/tools.lua")
local rng = dofile("./API/rng.lua")
local complexCommands = {}
local prefix = dofile("./docs/key.lua")
local commands = { -- Define commands its a table that will contain our commands
[prefix..'helpme'] = { -- Dumps docs/help to chat, took me forever to figure out.
exec = function (message)
message.channel:send(tools.printFile("docs/help"))
if tools.testModeDetection() == true then
message.channel:send(tools.printFile("docs/helpTestMode"))
else
message.channel:send(tools.printFile("docs/help"))
end
end
};
@ -21,6 +24,7 @@ local commands = { -- Define commands its a table that will contain our commands
end
};
--[[
[prefix..'figlet'] = { -- Parrots input to figlet, then echos it to the same channel you are in.
exec = function (message)
local prefixLength = string.len(prefix)
@ -42,6 +46,7 @@ end
message:delete()
end
};
]]
[prefix..'echo'] = { -- Echo's what you said back out, in a fix codeblock. Could be against TOS.
exec = function (message)

@ -0,0 +1,29 @@
local tools = dofile("./API/tools.lua")
local rng = dofile("./API/rng.lua")
local experimentalCommands = {}
local prefix = dofile("./docs/key.lua")
local commands = { -- Define commands its a table that will contain our commands
[prefix..'experiment'] = {
exec = function (message)
message.channel:send("Experimental mode works!")
end
};
[prefix..'test'] = { -- Test Command.
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()
return commands
end
return experimentalCommands
-- This project is libre, and licenced under the terms of the
-- DO WHAT THE FUCK YOU WANT TO PUBLIC LICENCE, version 3.1,
-- as published by dtf on July 2019. See the COPYING file or
-- https://ph.dtf.wtf/w/wtfpl/#version-3-1 for more details.

@ -41,14 +41,7 @@ end
[prefix..'welsh'] = { -- Welsh.
exec = function (message)
message.channel:send("https://cdn.discordapp.com/attachments/748713417489252503/770289379586867231/image0.gif")
message:delete()
end
};
[prefix..'test'] = { -- Test Command.
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.channel:send("https://cdn.discordapp.com/attachments/748713417489252503/770289379586867231/image0.gif lol")
message:delete()
end
};

@ -0,0 +1,33 @@
```fix
Basic functions
---------------
-figlet
Converts text to ASCII art
-cowsay
Converts text to the speech of a cow
-ping
Pong!
-roll [Argument]
Rolls a dice, by default d20!
-time
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
------------------
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