Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local internet = require("internet")
- local json = require("json")
- local unicode = require("unicode")
- require("component").gpu.setResolution(160,50)
- forms=require("forms")
- forms.ignoreAll()
- AuthForm=forms.addForm()
- AuthForm.border=1
- Label1=AuthForm:addLabel(50,3,[[
- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
- ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
- ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
- ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
- ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
- ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
- ▒▒▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒
- ▒▒▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░▒▒▓▓▓▓▓▓▒▒
- ▒▒▓▓▓▓▓▓▒▒░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓▓▒▒
- ▒▒▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓▓▒▒
- ▒▒▓▓▓▓▓▓░░░░░░▓▓▒▒░░▒▒▓▓▒▒░░░░▒▒▓▓▓▓▒▒
- ▒▒▓▓▓▓▓▓░░░░░░▓▓▒▒░░▒▒▓▓▒▒░░░░▒▒▓▓▓▓▒▒
- ▒▒▓▓▓▓▒▒░░░░░░░░░░░░░░░░░░░░░░▒▒▓▓▓▓▒▒
- ▒▒▓▓▓▓▓▓░░░░░░▒▒░░░░░░▒▒▒▒░░░░▒▒▓▓▓▓▒▒
- ▒▒▓▓▓▓▓▓▓▓▒▒░░▓▓▓▓▓▓▓▓▓▓▒▒▒▒▓▓▓▓▓▓▓▓▒▒
- ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
- ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
- ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▓▓▓▓▒▒
- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▓▓▒▒
- ▒▒▒▒
- ▒▒
- ]])
- Edit2=AuthForm:addEdit(60,28)
- Edit2.W=31
- Edit3=AuthForm:addEdit(60,31)
- Edit3.W=31
- Label2=AuthForm:addLabel(50,29,"Email")
- Label2.W=6
- Label3=AuthForm:addLabel(50,32,"Password")
- Label3.W=6
- local headers = {
- ["User-Agent"]="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.185 Safari/537.36",
- ["Content-Type"] = "application/json",
- ["Accept"] = "*/*",
- ["Accept-Encoding"]="identity",
- ["Accept-Charset"]="UTF-8"
- }
- local email = ""
- local password = ""
- local token = ""
- local guilds = {}
- local guild_ids = {}
- function doOnClick()
- email = Edit2.text
- password = Edit3.text
- local body = json.stringify({["email"]=email, ["password"]=password})
- if email and password then
- local handle = internet.request("https://discordapp.com/api/v6/auth/login", body, headers)
- local res = ""
- for chunk in handle do res=res..chunk end
- token = json.parse(res)["token"]
- headers["Authorization"]=token
- res = ""
- handle = internet.request("https://discordapp.com/api/v6/users/@me/guilds", nil, headers, 'GET')
- for chunk in handle do res=res..chunk end
- guilds = json.parse(res)
- for i,guild in ipairs(guilds) do
- List3:insert(1, guild["name"])
- guild_ids[i] = guild["id"]
- end
- Form1:setActive()
- end
- end
- function findEntry(t,val)
- for k,v in ipairs(t) do
- if v["name"] == val then return k end
- end
- end
- local channel_ids = {}
- function onSelGuild(line, item, user)
- List1:clear()
- List2:clear()
- local result = ""
- headers["Authorization"]=token
- local handle = internet.request("https://discordapp.com/api/v6/guilds/"..guild_ids[findEntry(guilds, item)].."/channels", nil, headers, 'GET')
- for chunk in handle do result=result..chunk end
- channels = json.parse(result)
- for i, channel in ipairs(channels) do
- List2:insert(1, channel["name"])
- channel_ids[i] = channel["id"]
- end
- function onSelChannel(line2, item2, user2)
- List1:clear()
- result = ""
- handle = internet.request("https://discordapp.com/api/v6/channels/" .. channel_ids[findEntry(channels, item2)] .. "/messages?limit=1", nil, headers, 'GET')
- for part in handle do result = result..part end
- messages = json.parse(result)
- for j, message in ipairs(messages) do
- List1:insert(1, message["author"]["username"] .. ": " .. message["content"])
- end
- end
- end
- Form1=forms.addForm()
- Form1.border=1
- List3=Form1:addList(3, 2, onSelGuild)
- List3.border=1
- List3.H=48
- List3.W=13
- List1=Form1:addList(31,2)
- List1.border=1
- List1.selColor=0x000000
- List1.sfColor=0xffffff
- List1.H=44
- List1.W=127
- List2=Form1:addList(17, 2, onSelChannel)
- List2.border=1
- List2.H=48
- List2.W=13
- Edit1=Form1:addEdit(31,46,function() List1:insert(1, token) end)
- Edit1.H=4
- Edit1.W=127
- Button1=AuthForm:addButton(71, 35, "Login", doOnClick)
- forms.run(AuthForm)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement