Merge experimental with main. #1

Merged
AstoriaFloyd merged 5 commits from experimental into main 3 years ago

1
.gitignore vendored

@ -3,3 +3,4 @@ gateway.json
token.lua token.lua
launch.json launch.json
.vscode .vscode
interpreter.lua

@ -9,6 +9,7 @@ end
--Initializes commands. --Initializes commands.
function tools.initialize() function tools.initialize()
if tools.testModeDetection() == false then
local simpleCommands = dofile("./commands/simpleCommands.lua") local simpleCommands = dofile("./commands/simpleCommands.lua")
local complexCommands = dofile("./commands/complexCommands.lua") local complexCommands = dofile("./commands/complexCommands.lua")
local complexCommands = complexCommands.initialize() local complexCommands = complexCommands.initialize()
@ -16,6 +17,25 @@ function tools.initialize()
local commands = tools.tableMerge(simpleCommands, complexCommands) local commands = tools.tableMerge(simpleCommands, complexCommands)
return commands return commands
end 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
function tools.testModeDetection()
return dofile("./docs/testmode.lua")
end
--
--Reads an entire file, outputs as string. --Reads an entire file, outputs as string.
function tools.printFile(file) function tools.printFile(file)
@ -51,7 +71,7 @@ end
--Now deprecated --Now deprecated
function tools.messageDectection(message, search) function tools.messageDectection(message, search)
local distinctMessage = string.lower(message.content) local distinctMessage = string.lower(message.content)
local key = dofile("./docs/settings.lua") local key = dofile("./docs/key.lua")
local keyedSearch = key .. search local keyedSearch = key .. search
if string.find(distinctMessage, keyedSearch) == 1 then if string.find(distinctMessage, keyedSearch) == 1 then
return true return true

@ -8,21 +8,50 @@ client:once("ready", function()
client:setGame("Astoria's bot, very sad!") client:setGame("Astoria's bot, very sad!")
print('Logged in as '.. client.user.username) 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) 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
mode = "testMode"
shouldReinit = true
elseif Tools.testModeDetection() == false and mode == "testMode" then
mode = "normal"
shouldReinit = false
end
if mode == "testMode" then
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 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)
end end
end) end)
--Re-Init detector. Only command that itself cannot be fully re-initialized function reinitialize(message)
client:on('messageCreate', function(message)
local user = message.guild:getMember(message.author.id) local user = message.guild:getMember(message.author.id)
if Tools.messageDectection(message, "reinitialize") == true then if Tools.messageDectection(message, "reinitialize") == true then
if not user:hasPermission("administrator") then if not user:hasPermission("administrator") then
@ -33,7 +62,12 @@ client:on('messageCreate', function(message)
message:reply("Re-Initialized!") message:reply("Re-Initialized!")
end end
end end
end) end
function selfReinitialize()
Commands = Tools.initialize()
Tools = dofile("./API/tools.lua")
end
--When a user is banned, post a lenney. --When a user is banned, post a lenney.
client:on('userBan', function() client:on('userBan', function()

@ -1,15 +1,19 @@
local tools = dofile("./API/tools.lua") local tools = dofile("./API/tools.lua")
local rng = dofile("./API/rng.lua") local rng = dofile("./API/rng.lua")
local complexCommands = {} local complexCommands = {}
local prefix = dofile("./docs/key.lua")
local prefix = dofile("./docs/settings.lua")
local commands = { -- Define commands its a table that will contain our commands 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. [prefix..'helpme'] = { -- Dumps docs/help to chat, took me forever to figure out.
exec = function (message) exec = function (message)
if tools.testModeDetection() == true then
message.channel:send(tools.printFile("docs/helpTestMode"))
else
message.channel:send(tools.printFile("docs/help")) message.channel:send(tools.printFile("docs/help"))
end end
end
}; };
[prefix..'roll'] = { -- Rolls a d20, check RNG for more info. [prefix..'roll'] = { -- Rolls a d20, check RNG for more info.
exec = function (message, arg) exec = function (message, arg)
if not arg[2] then if not arg[2] then
@ -19,6 +23,7 @@ local commands = { -- Define commands its a table that will contain our commands
end end
end end
}; };
--[[ --[[
[prefix..'figlet'] = { -- Parrots input to figlet, then echos it to the same channel you are in. [prefix..'figlet'] = { -- Parrots input to figlet, then echos it to the same channel you are in.
exec = function (message) exec = function (message)
@ -30,6 +35,7 @@ local commands = { -- Define commands its a table that will contain our commands
message:delete() message:delete()
end end
}; };
[prefix..'cowsay'] = { -- Parrots input to cowsay, then echos it to the same channel you are in. [prefix..'cowsay'] = { -- Parrots input to cowsay, then echos it to the same channel you are in.
exec = function (message) exec = function (message)
local prefixLength = string.len(prefix) local prefixLength = string.len(prefix)
@ -47,10 +53,25 @@ local commands = { -- Define commands its a table that will contain our commands
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.channel:send(result)
message:delete() message:delete()
end 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
};
} }
function complexCommands.initialize() function complexCommands.initialize()

@ -0,0 +1,27 @@
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..'fumo'] = { -- To be implemented later..
exec = function (message)
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.

@ -1,5 +1,5 @@
local basicCommands = {} local basicCommands = {}
local prefix = dofile("./docs/settings.lua") local prefix = dofile("./docs/key.lua")
local commands = { -- Define commands its a table that will contain our commands local commands = { -- Define commands its a table that will contain our commands
[prefix..'lenny'] = { -- Creates a lenny face [prefix..'lenny'] = { -- Creates a lenny face
@ -7,16 +7,19 @@ local commands = { -- Define commands its a table that will contain our commands
message.channel:send('( ͡° ͜ʖ ͡°)') message.channel:send('( ͡° ͜ʖ ͡°)')
end end
}; };
[prefix..'glomp'] = { -- Posts an image of glomping, may add RNG later. [prefix..'glomp'] = { -- Posts an image of glomping, may add RNG later.
exec = function (message) exec = function (message)
message.channel:send('https://tenor.com/view/tv-shows-television-tackle-hug-hug-glomping-gif-14859564') message.channel:send('https://tenor.com/view/tv-shows-television-tackle-hug-hug-glomping-gif-14859564')
end end
}; };
[prefix..'ping'] = { -- Ping Pong function, generally just to see if its on or not without triggering a more complex function. Also tests if its really borked. [prefix..'ping'] = { -- Ping Pong function, generally just to see if its on or not without triggering a more complex function. Also tests if its really borked.
exec = function (message) exec = function (message)
message.channel:send("Pong!") message.channel:send("Pong!")
end end
}; };
[prefix..'fire'] = { -- Places elmo on fire in chat. [prefix..'fire'] = { -- Places elmo on fire in chat.
exec = function (message) exec = function (message)
message.channel:send("https://tenor.com/view/elmo-fire-burn-flame-gif-5042503") message.channel:send("https://tenor.com/view/elmo-fire-burn-flame-gif-5042503")
@ -28,18 +31,21 @@ local commands = { -- Define commands its a table that will contain our commands
message.channel:send('The current time in military time is ' .. os.date() .. ' atleast in Chicago!') message.channel:send('The current time in military time is ' .. os.date() .. ' atleast in Chicago!')
end end
}; };
[prefix..'analyze'] = { -- Prints contents and attachments to console. [prefix..'analyze'] = { -- Prints contents and attachments to console.
exec = function (message) exec = function (message)
p(message.content) p(message.content)
p(message.attachments) p(message.attachments)
end end
}; };
[prefix..'welsh'] = { -- Welsh. [prefix..'welsh'] = { -- Welsh.
exec = function (message) exec = function (message)
message.channel:send("https://cdn.discordapp.com/attachments/748713417489252503/770289379586867231/image0.gif") message.channel:send("https://cdn.discordapp.com/attachments/748713417489252503/770289379586867231/image0.gif lol")
message:delete() message:delete()
end end
}; };
} }

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

@ -0,0 +1,31 @@
```fix
Basic functions
---------------
-figlet
Converts text to ASCII art. Currently disabled due to security problems.
-cowsay
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.
-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 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.
```

@ -1,5 +1,5 @@
--Litterally just the prefix right now --Litterally just the prefix right now
return "!" return "exp!"
-- This project is libre, and licenced under the terms of the -- This project is libre, and licenced under the terms of the
-- DO WHAT THE FUCK YOU WANT TO PUBLIC LICENCE, version 3.1, -- DO WHAT THE FUCK YOU WANT TO PUBLIC LICENCE, version 3.1,
-- as published by dtf on July 2019. See the COPYING file or -- as published by dtf on July 2019. See the COPYING file or

@ -0,0 +1 @@
return false
Loading…
Cancel
Save