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)
- local headers = {
- ["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",
- ["Content-Type"] = "application/json",
- ["Accept"] = "*/*",
- ["Accept-Encoding"]="identity",
- ["Accept-Charset"]="UTF-8"
- }
- local email = "@yandex.ru" --тут заполнить!!!!!!
- local password = ""
- local token = ""
- local guilds = {}
- local guild_ids = {}
- local function decode(text)
- local text, line = text:gsub("u(%x+)", function(code) return unicode.char(tonumber(code, 16)) end)
- return text
- end
- function doOnClick()
- print(email,password)
- 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
- print(decode(guild["name"]))
- guild_ids[i] = guild["id"]
- end
- 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 getChannel(item) --получить список всех каналов группы
- 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
- print(decode(channel["name"]))
- channel_ids[i] = channel["id"]
- end
- end
- function getChannelMessage(item, limit) --получить указанный лимит сообщений с активного канала
- result = ""
- handle = internet.request("https://discordapp.com/api/v6/channels/" .. channel_ids[findEntry(channels, item)] .. "/messages?limit="..limit, nil, headers, 'GET')
- for part in handle do result = result..part end
- messages = json.parse(result)
- for j, message in ipairs(messages) do
- print(message["author"]["username"] .. ": " .. decode(message["content"]))
- end
- end
- function setChannelMessage(item, message) --отправка сообщения
- result = ""
- local body = json.stringify({["content"]=message, ['tts']=true})
- handle, err = internet.request("https://discordapp.com/api/v6/channels/" .. channel_ids[findEntry(channels, item)] .. "/messages", body, headers, 'POST')
- for part in handle do result = result..part end
- print(result)
- end
- doOnClick()
- getChannel('Asioron')
- getChannelMessage('general', 5)
- setChannelMessage('general', '123текструсскийблядь')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement