Advertisement
Guest User

ds.lua

a guest
Nov 18th, 2020
170
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.51 KB | None
  1. local internet = require("internet")
  2. local json = require("json")
  3. local unicode = require("unicode")
  4. require("component").gpu.setResolution(160,50)
  5. forms=require("forms")
  6. forms.ignoreAll()
  7.  
  8. AuthForm=forms.addForm()
  9. AuthForm.border=1
  10.  
  11. Label1=AuthForm:addLabel(50,3,[[
  12.           ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  13.         ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
  14.       ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
  15.       ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
  16.       ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
  17.       ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
  18.       ▒▒▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒
  19.       ▒▒▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░▒▒▓▓▓▓▓▓▒▒
  20.       ▒▒▓▓▓▓▓▓▒▒░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓▓▒▒
  21.       ▒▒▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓▓▒▒
  22.       ▒▒▓▓▓▓▓▓░░░░░░▓▓▒▒░░▒▒▓▓▒▒░░░░▒▒▓▓▓▓▒▒
  23.       ▒▒▓▓▓▓▓▓░░░░░░▓▓▒▒░░▒▒▓▓▒▒░░░░▒▒▓▓▓▓▒▒
  24.       ▒▒▓▓▓▓▒▒░░░░░░░░░░░░░░░░░░░░░░▒▒▓▓▓▓▒▒
  25.       ▒▒▓▓▓▓▓▓░░░░░░▒▒░░░░░░▒▒▒▒░░░░▒▒▓▓▓▓▒▒
  26.       ▒▒▓▓▓▓▓▓▓▓▒▒░░▓▓▓▓▓▓▓▓▓▓▒▒▒▒▓▓▓▓▓▓▓▓▒▒
  27.       ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
  28.       ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
  29.       ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
  30.         ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▓▓▓▓▒▒
  31.           ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒    ▒▒▓▓▒▒
  32.                                         ▒▒▒▒
  33.                                           ▒▒
  34. ]])
  35.  
  36. Edit2=AuthForm:addEdit(60,28)
  37. Edit2.W=31
  38.  
  39. Edit3=AuthForm:addEdit(60,31)
  40. Edit3.W=31
  41.  
  42. Label2=AuthForm:addLabel(50,29,"Email")
  43. Label2.W=6
  44.  
  45. Label3=AuthForm:addLabel(50,32,"Password")
  46. Label3.W=6
  47.  
  48. local headers = {
  49.     ["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",
  50.     ["Content-Type"] = "application/json",
  51.     ["Accept"] = "*/*",
  52.     ["Accept-Encoding"]="identity",
  53.     ["Accept-Charset"]="UTF-8"
  54. }
  55. local email = ""
  56. local password = ""
  57. local token = ""
  58. local guilds = {}
  59. local guild_ids = {}
  60. function doOnClick()
  61.     email = Edit2.text
  62.     password = Edit3.text
  63.     local body = json.stringify({["email"]=email, ["password"]=password})
  64.     if email and password then
  65.       local handle = internet.request("https://discordapp.com/api/v6/auth/login", body, headers)
  66.       local res = ""
  67.       for chunk in handle do res=res..chunk end
  68.       token = json.parse(res)["token"]
  69.       headers["Authorization"]=token
  70.       res = ""
  71.       handle = internet.request("https://discordapp.com/api/v6/users/@me/guilds", nil, headers, 'GET')
  72.       for chunk in handle do res=res..chunk end
  73.       guilds = json.parse(res)
  74.       for i,guild in ipairs(guilds) do
  75.          List3:insert(1, guild["name"])
  76.          guild_ids[i] = guild["id"]
  77.       end
  78.       Form1:setActive()
  79.     end
  80. end
  81.  
  82. function findEntry(t,val)
  83.     for k,v in ipairs(t) do
  84.         if v["name"] == val then return k end
  85.     end
  86. end
  87.  
  88. local channel_ids = {}
  89. function onSelGuild(line, item, user)
  90.   List1:clear()
  91.   List2:clear()
  92.   local result = ""
  93.   headers["Authorization"]=token
  94.   local handle = internet.request("https://discordapp.com/api/v6/guilds/"..guild_ids[findEntry(guilds, item)].."/channels", nil, headers, 'GET')
  95.   for chunk in handle do result=result..chunk end
  96.   channels = json.parse(result)
  97.   for i, channel in ipairs(channels) do
  98.     List2:insert(1, channel["name"])
  99.     channel_ids[i] = channel["id"]
  100.   end
  101.   function onSelChannel(line2, item2, user2)
  102.     List1:clear()
  103.     result = ""
  104.     handle = internet.request("https://discordapp.com/api/v6/channels/" .. channel_ids[findEntry(channels, item2)] .. "/messages?limit=1", nil, headers, 'GET')
  105.     for part in handle do result = result..part end
  106.     messages = json.parse(result)
  107.     for j, message in ipairs(messages) do
  108.       List1:insert(1, message["author"]["username"] .. ": " .. message["content"])
  109.     end
  110.   end
  111. end
  112.  
  113. Form1=forms.addForm()
  114. Form1.border=1
  115.  
  116. List3=Form1:addList(3, 2, onSelGuild)
  117. List3.border=1
  118. List3.H=48
  119. List3.W=13
  120.  
  121. List1=Form1:addList(31,2)
  122. List1.border=1
  123. List1.selColor=0x000000
  124. List1.sfColor=0xffffff
  125. List1.H=44
  126. List1.W=127
  127.  
  128. List2=Form1:addList(17, 2, onSelChannel)
  129. List2.border=1
  130. List2.H=48
  131. List2.W=13
  132.  
  133. Edit1=Form1:addEdit(31,46,function() List1:insert(1, token) end)
  134. Edit1.H=4
  135. Edit1.W=127
  136.  
  137. Button1=AuthForm:addButton(71, 35, "Login", doOnClick)
  138.  
  139. forms.run(AuthForm)
Advertisement
RAW Paste Data Copied
Advertisement