Advertisement
Asioron

Discord_rip

Dec 6th, 2020
638
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.18 KB | None | 0 0
  1. local internet = require("internet")
  2. local json = require("json")
  3. local unicode = require("unicode")
  4. --require("component").gpu.setResolution(160,50)
  5.  
  6. local headers = {
  7.     ["User-Agent"]="Mozilla/5.0 (Linux; U; Android 2.3.5; ru-ru; Philips W632 Build/GRJ90) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
  8.     ["Content-Type"] = "application/json",
  9.     ["Accept"] = "*/*",
  10.     ["Accept-Encoding"]="identity",
  11.     ["Accept-Charset"]="UTF-8"
  12. }
  13. local email = "@yandex.ru" --тут заполнить!!!!!!
  14. local password = ""
  15. local token = ""
  16. local guilds = {}
  17. local guild_ids = {}
  18.  
  19. local function decode(text)
  20.   local text, line = text:gsub("u(%x+)", function(code) return unicode.char(tonumber(code, 16)) end)
  21.   return text
  22. end
  23. function doOnClick()
  24.   print(email,password)
  25.     local body = json.stringify({["email"]=email, ["password"]=password})
  26.     if email and password then
  27.       local handle = internet.request("https://discordapp.com/api/v6/auth/login", body, headers)
  28.       local res = ""
  29.       for chunk in handle do res=res..chunk end
  30.       token = json.parse(res)["token"]
  31.       headers["Authorization"]=token
  32.       res = ""
  33.       handle = internet.request("https://discordapp.com/api/v6/users/@me/guilds", nil, headers, 'GET')
  34.       for chunk in handle do res=res..chunk end
  35.       guilds = json.parse(res)
  36.       for i,guild in ipairs(guilds) do
  37.          print(decode(guild["name"]))
  38.          guild_ids[i] = guild["id"]
  39.       end
  40.     end
  41. end
  42.  
  43. function findEntry(t,val)
  44.     for k,v in ipairs(t) do
  45.         if v["name"] == val then return k end
  46.     end
  47. end
  48.  
  49. local channel_ids = {}
  50. function getChannel(item) --получить список всех каналов группы
  51.   local result = ""
  52.   headers["Authorization"]=token
  53.   local handle = internet.request("https://discordapp.com/api/v6/guilds/"..guild_ids[findEntry(guilds, item)].."/channels", nil, headers, 'GET')
  54.   for chunk in handle do result=result..chunk end
  55.   channels = json.parse(result)
  56.   for i, channel in ipairs(channels) do
  57.     print(decode(channel["name"]))
  58.     channel_ids[i] = channel["id"]
  59.   end
  60. end
  61.  
  62. function getChannelMessage(item, limit) --получить указанный лимит сообщений с активного канала
  63.   result = ""
  64.   handle = internet.request("https://discordapp.com/api/v6/channels/" .. channel_ids[findEntry(channels, item)] .. "/messages?limit="..limit, nil, headers, 'GET')
  65.   for part in handle do result = result..part end
  66.   messages = json.parse(result)
  67.   for j, message in ipairs(messages) do
  68.     print(message["author"]["username"] .. ": " .. decode(message["content"]))
  69.   end
  70. end
  71.  
  72. function setChannelMessage(item, message) --отправка сообщения
  73.   result = ""
  74.   local body = json.stringify({["content"]=message, ['tts']=true})
  75.   handle, err = internet.request("https://discordapp.com/api/v6/channels/" .. channel_ids[findEntry(channels, item)] .. "/messages", body, headers, 'POST')
  76.   for part in handle do result = result..part end
  77.   print(result)
  78. end
  79.  
  80.  
  81.  
  82. doOnClick()
  83. getChannel('Asioron')
  84. getChannelMessage('general', 5)
  85. setChannelMessage('general', '123текструсскийблядь')
  86.  
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement