diff --git a/API/fumoLines.sh b/API/fumoLines.sh new file mode 100755 index 0000000..c71c26e --- /dev/null +++ b/API/fumoLines.sh @@ -0,0 +1,3 @@ +fumoFileText=$(find fumoGif/* | grep -i .gif) +fumoFileNumbers=$(wc -l <<< "$fumoFileText") +echo "$fumoFileNumbers" > "docs/fumoFile" \ No newline at end of file diff --git a/API/fumoList.sh b/API/fumoList.sh new file mode 100755 index 0000000..b56f417 --- /dev/null +++ b/API/fumoList.sh @@ -0,0 +1,2 @@ +fumoFileText=$(find fumoGif/* | grep -i .gif) +echo "$fumoFileText" > "docs/fumoFile" \ No newline at end of file diff --git a/API/tools.lua b/API/tools.lua index 4e4333a..52c9916 100644 --- a/API/tools.lua +++ b/API/tools.lua @@ -118,6 +118,38 @@ function tools.tableMerge(t1, t2) return t1 end +--Work on this later, simplify fumo command, less hardcoding, please. +function tools.massDetection(folder, filetype) + local command = "find "..folder.." | grep -i "..filetype.." | grep -n "..filetype + local result = io.popen(command) + return(result) +end + +-- Checks fumoFile after running the fumoLine numbering script, to get the number of .gif files there are. +function tools.fumoLines() + os.execute("/bin/bash API/fumoLines.sh") + local file = io.open("./docs/fumoFile", "r") + local fumoFile = file:read() + file:close() + return(fumoFile) +end + +-- Creates a table of every gif in the /fumoGif folder. Uses the fumoList script to get their location, and the fumoLine script to get what line number they are, which is their key +function tools.fumoList() + local lineList = tools.fumoLines() + local fumoList = {} + os.execute("/bin/bash API/fumoList.sh") + local file = io.open("./docs/fumoFile", "r") + for i = lineList,1,-1 + do + local number = i + fumoList[number]=file:read() + end + file:close() + return(fumoList) +end + + --Message detection logic. If string.find detects both the desired string, and the key, starting at position 1, do the thing. --Now deprecated function tools.messageDectection(message, search) diff --git a/commands/complexCommands.lua b/commands/complexCommands.lua index 201edf8..83b07ed 100644 --- a/commands/complexCommands.lua +++ b/commands/complexCommands.lua @@ -25,6 +25,17 @@ local commands = { -- Define commands its a table that will contain our commands end }; +[prefix..'fumo'] = { -- Posts a random fumo gif from /fumoGif, fully reloads the list of gifs each run +exec = function (message) + local fumoLines = tools.fumoLines() + local fumoList = tools.fumoList() + tools.seed() + local fumo = fumoList[math.random(fumoLines)] + local msg = fumo + message.channel:send{file = msg} +end +}; + --[[ [prefix..'figlet'] = { -- Parrots input to figlet, then echos it to the same channel you are in. exec = function (message) diff --git a/commands/experimentalCommands.lua b/commands/experimentalCommands.lua index 619cbb0..fe84888 100644 --- a/commands/experimentalCommands.lua +++ b/commands/experimentalCommands.lua @@ -9,12 +9,7 @@ local commands = { -- Define commands its a table that will contain our commands message.channel:send("Experimental mode works!") end }; ---[[ -[prefix..'fumo'] = { -- To be implemented later.. -exec = function (message) -end -}; -]] + } function experimentalCommands.initialize() diff --git a/fumoGif/fumo-fumofumo.gif b/fumoGif/fumo-fumofumo.gif new file mode 100644 index 0000000..0f802ed Binary files /dev/null and b/fumoGif/fumo-fumofumo.gif differ diff --git a/fumoGif/fumo-shawarma.gif b/fumoGif/fumo-shawarma.gif new file mode 100644 index 0000000..d2aa96c Binary files /dev/null and b/fumoGif/fumo-shawarma.gif differ diff --git a/fumoGif/me-going-to-sleep-knowing-touhou.gif b/fumoGif/me-going-to-sleep-knowing-touhou.gif new file mode 100644 index 0000000..3f8424a Binary files /dev/null and b/fumoGif/me-going-to-sleep-knowing-touhou.gif differ diff --git a/fumoGif/remilia-scarlet.gif b/fumoGif/remilia-scarlet.gif new file mode 100644 index 0000000..f2b7b5d Binary files /dev/null and b/fumoGif/remilia-scarlet.gif differ diff --git a/fumoGif/sakuya-fumo.gif b/fumoGif/sakuya-fumo.gif new file mode 100644 index 0000000..3b40414 Binary files /dev/null and b/fumoGif/sakuya-fumo.gif differ diff --git a/fumoGif/touhou-cirno.gif b/fumoGif/touhou-cirno.gif new file mode 100644 index 0000000..0a80e73 Binary files /dev/null and b/fumoGif/touhou-cirno.gif differ diff --git a/fumoGif/touhou-fumo-touhou.gif b/fumoGif/touhou-fumo-touhou.gif new file mode 100644 index 0000000..359aab7 Binary files /dev/null and b/fumoGif/touhou-fumo-touhou.gif differ diff --git a/fumoGif/touhou-fumo.gif b/fumoGif/touhou-fumo.gif new file mode 100644 index 0000000..6fa2f55 Binary files /dev/null and b/fumoGif/touhou-fumo.gif differ diff --git a/fumoGif/touhou-fumomo.gif b/fumoGif/touhou-fumomo.gif new file mode 100644 index 0000000..96275b0 Binary files /dev/null and b/fumoGif/touhou-fumomo.gif differ diff --git a/fumoGif/touhou-fumomoment.gif b/fumoGif/touhou-fumomoment.gif new file mode 100644 index 0000000..7670853 Binary files /dev/null and b/fumoGif/touhou-fumomoment.gif differ