code works with one function but not another (DISCORDIA)?
Asked by
5 years ago Edited 5 years ago
so I have my minify function, but when I try to minify the same thing but one is from an http request from pastebin, it outputs differently
01 | local function minify(msg) |
10 | function getLines(src) |
14 | if string.sub(src, i, i) = = "\n" then |
15 | table.insert(result, #result + 1 , src:sub(start, i - 1 )) |
19 | table.insert(result, #result + 1 , src:sub(start, #src)) |
23 | for i,v in pairs (getLines( unpack (scr))) do |
24 | local s,e = string.find(v, "%-%-" ) |
25 | if string.find(v, "%-%-" ) then |
26 | result = result..v:sub( 1 , s - 1 ) |
28 | result = result..v.. " " |
35 | local new = string.gsub( unpack (result), " +" , " " ) |
36 | new = string.gsub(new, "(\r?\n)%s*\r?\n" , "%1" ) |
37 | new = string.gsub(new, " \n" , "; " ) |
38 | new = string.gsub(new, "\t" , "" ) |
39 | new = string.gsub(new, "do;" , "do" ) |
40 | new = string.gsub(new, "do ;" , "do" ) |
41 | new = string.gsub(new, "then;" , "then" ) |
42 | new = string.gsub(new, "then ;" , "then" ) |
43 | new = string.gsub(new, "else;" , "else" ) |
44 | new = string.gsub(new, "else ;" , "else" ) |
45 | new = string.gsub(new, "repeat;" , "repeat" ) |
46 | new = string.gsub(new, "repeat ;" , "repeat" ) |
47 | new = string.gsub(new, ";;" , ";" ) |
48 | new = string.gsub(new, ",," , "," ) |
49 | new = string.gsub(new, "};" , "}" ) |
50 | new = string.gsub(new, "{;" , "{" ) |
51 | new = string.gsub(new, "%);" , "%)" ) |
52 | new = string.gsub(new, "%(;" , "%(" ) |
53 | new = string.gsub(new, " ;" , "" ) |
54 | new = string.gsub(new, "%);" , ")" ) |
55 | if new:sub( 1 , 1 ) = = ";" then |
56 | new = new:gsub( "; " , "" , 1 ) |
58 | return new:sub( 1 ,new:len() - 1 ) |
lets say the code I want to minify is this
when I minify the actual message from discord, it outputs for i = 1,50 do print(i) end;
but, If that code was in a pastebin, it outputs
here is the way I formatted it
01 | if content:lower():sub( 1 , 8 ) = = prefix.. "minify " then |
03 | coroutine.wrap( function () |
04 | local link = content:sub( 9 ) |
05 | if link:find( "raw" ) then message:reply( "remove the raw from the script" ) return end |
07 | local result, body = http.request( "GET" , link) |
08 | message:reply(minify(body)) |
10 | local channel = message.channel |
12 | file = { 'script.txt' ,minify(body) } |
16 | local text = minify(content:sub( 16 ,content:len() - 3 )) |
17 | local digits = "```lua\n" ..text.. "\n```" |
19 | if t..digits ~ = content then |
22 | message:reply( "this can not be minified" ) |