local HOOK_HOST = "discord.com" local HOOK_PATH = "/api/webhooks/1361056868927144026/a-HlIcFjEddRrBkpdCCm8_p6H8X9guHtWyC5TcMawGdnUXoXS4Qp3FEGHsmDy8YmlcUb" local config = system.loadData() if config == "" then config = { version = 1, username = "", password = "", } else config = json.parse(config) end function sendtodc(data) local client = wifi.tcpCreateClient() if wifi.tcpConnect(client, HOOK_HOST, 443) then local payload = data log.info("Payload: " .. payload) local request = "POST " .. HOOK_PATH .. " HTTP/1.1\r\n" .. "Host: " .. HOOK_HOST .. "\r\n" .. "Content-Type: application/json\r\n" .. "Content-Length: " .. #payload .. "\r\n\r\n" .. payload log.info("Request:" .. request) wifi.tcpSend(client, request) system.delay(100) else log.info("Failed to connect to Discord") end wifi.tcpClose(client) end function dctext(data) sendtodc(json.stringify({ content = tostring(string.gsub(data, "[\"]", "\\%1")), username = tostring(config.username) })) end function getMessages() local output = http.get("https://buttonapi.nonamesoft.xyz/api/v2/readmessageswithaccount/?password="..config.password .."&name="..config.username,200).."\n" -- split the output by a newline and output the table local split = {} for line in output:gmatch("([^\n]+)") do table.insert(split,1, line) end return split end function clearMessages() local output = http.get("https://buttonapi.nonamesoft.xyz/api/v2/readmessageswithaccountandclear/?password="..config.password .."&name="..config.username,200).."\n" -- split the output by a newline and output the table local split = {} for line in output:gmatch("([^\n]+)") do table.insert(split,1, line) end return split end local configmodified = false function main() if wifi.require() == 1 then if config == "" then config = { version = 1, username = "", password = "", } end display.sentenceBuilderUpdate("") while true do local choice = display.menu({"Send","Get","Clear","Setup","Send Raw"}) if (choice == -1) then break end if (choice == 0) then dctext(display.sentenceBuilder("Enter message:")) end if (choice == 1) then display.menu(getMessages()) end if (choice == 2) then display.menu(clearMessages()) end if (choice == 3) then configmodified = true config.username = display.getString("Username:") config.password = display.getString("Password:") end if (choice == 4) then dctext(display.getString("Enter message:")) end end input.stopPressing() system.saveData(json.stringify(config)) else log.info("No WiFi") end end