Add more
This commit is contained in:
parent
b81149068b
commit
89a15d277f
5 changed files with 1026 additions and 0 deletions
56
mpp.lua
Normal file
56
mpp.lua
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
local connectionUrl = "wss://mppclone.com";
|
||||
|
||||
local ws, err = http.websocket(connectionUrl)
|
||||
|
||||
if not ws then
|
||||
return printError(err)
|
||||
end
|
||||
|
||||
function send(data)
|
||||
local message = {}
|
||||
message[1] = data;
|
||||
ws.send(textutils.serialiseJSON(message));
|
||||
end
|
||||
|
||||
local function tSender()
|
||||
while true do
|
||||
os.sleep(15)
|
||||
send({
|
||||
m = "t"
|
||||
})
|
||||
end
|
||||
end
|
||||
local function pollWebsocket()
|
||||
while true do
|
||||
|
||||
local _, url, response, isBinary = os.pullEvent("websocket_message");
|
||||
if url == connectionUrl then
|
||||
local json = textutils.unserializeJSON(response);
|
||||
if json[1].m == "b" then
|
||||
print("Connected to MPP!");
|
||||
send({
|
||||
m = "hi",
|
||||
token = "<no>"
|
||||
})
|
||||
end
|
||||
if json[1].m == "hi" then
|
||||
print("Authenicated!")
|
||||
send({
|
||||
m = "ch",
|
||||
_id = "The Roleplay Room"
|
||||
})
|
||||
end
|
||||
if json[1].m == "a" then
|
||||
print("["..json[1].p._id:sub(0, 6).."] "..json[1].p.name..": "..json[1].a)
|
||||
|
||||
end
|
||||
local g = json[1].m == "m" or json[1].m == "n"
|
||||
if not g then
|
||||
print(json[1].m)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
parallel.waitForAny(tSender,pollWebsocket)
|
||||
Loading…
Add table
Add a link
Reference in a new issue