Notes
Notes - notes.io |
const tls = require("tls");
const WebSocket = require("ws");
const extractJson = require("extract-json-from-string");
const CONNECTION_OPTIONS = {
host: "canary.discord.com",
port: 443,
};
const API_TOKEN = "MTI3NDg2NTA0Nzg4NTMyMDMwNA.GjZT8H.PBVMebKG4EcK3dXbIt2BwJCwbkxxUEL9ufgz6Q"; // API_TOKEN'i buraya girin
const self = "MTE0Njg5NzYxMjY5NjQ2OTUzNQ.Gcv2A5.Jvkx0Z6gRFQK7TIYd19b5vN_ZNogBBtWEnJmV0"; // API_TOKEN'i buraya
const kanal = "1275774653318697033";
const sunucu = "1269439168107511808";
let vanity;
let tlsSocket;
let websocket;
let guilds = {};
let heartbeatInterval;
function sendRequest(socket, request) {
socket.write(request);
}
function handleData(data) {
const ext = extractJson(data.toString());
const find = ext.find((e) => e.code) || ext.find((e) => e.message);
if (find) {
console.log(find);
const requestBody = {
content: `@everyone UP ${vanity} n```jsonn${JSON.stringify(find)}````,
};
sendRequest(tlsSocket, createRequest("POST", `/api/v9/channels/${kanal}/messages`, requestBody));
}
}
function createRequest(method, path, body) {
const requestBody = body ? JSON.stringify(body) : "";
const contentLength = Buffer.byteLength(requestBody);
return [
`${method} ${path} HTTP/1.1`,
"Host: canary.discord.com",
`Authorization: ${API_TOKEN}`,
"Content-Type: application/json",
`Content-Length: ${contentLength}`,
"Connection: keep-alive",
"",
requestBody,
].join("rn");
}
function updateGuildVanityUrl(code) {
const patchRequest = createRequest("PATCH", `/api/v9/guilds/${sunucu}/vanity-url`, { code });
sendRequest(tlsSocket, patchRequest);
}
function handleGuildUpdate(data) {
const find = guilds[data.guild_id];
if (find && find !== data.vanity_url_code) {
const start = Date.now();
updateGuildVanityUrl(find);
const end = Date.now();
vanity = `${find} update `${end - start}ms``;
}
}
function handleWebSocketMessage(message) {
const { d, op, t } = JSON.parse(message.data);
if (t === "GUILD_UPDATE") {
handleGuildUpdate(d);
} else if (t === "READY") {
d.guilds.forEach(({ id, vanity_url_code, name }) => {
if (vanity_url_code) {
guilds[id] = vanity_url_code;
} else {
console.log(name);
}
});
console.log(guilds);
}
if (op === 10) {
const identifyPayload = {
op: 2,
d: {
token: self,
intents: 1,
properties: {
os: "macos",
browser: "firefox",
device: "mybot",
},
},
};
websocket.send(JSON.stringify(identifyPayload));
startHeartbeat(websocket, d.heartbeat_interval);
} else if (op === 7) {
process.exit();
}
}
function startHeartbeat(socket, interval) {
heartbeatInterval = setInterval(() => {
socket.send(JSON.stringify({ op: 1, d: null }));
}, interval);
}
function stopHeartbeat() {
if (heartbeatInterval) {
clearInterval(heartbeatInterval);
heartbeatInterval = null;
}
}
tlsSocket = tls.connect(CONNECTION_OPTIONS, () => {
websocket = new WebSocket("wss://gateway-us-east1-b.discord.gg");
websocket.onclose = (event) => {
console.log(`ws connection closed ${event.reason} ${event.code}`);
stopHeartbeat();
process.exit();
};
websocket.onmessage = handleWebSocketMessage;
tlsSocket.on("data", async (data) => {
handleData(data);
});
tlsSocket.on("error", (error) => {
console.log(`tls error`, error);
process.exit();
});
tlsSocket.on("end", () => {
console.log("tls connection closed");
stopHeartbeat();
process.exit();
});
tlsSocket.on("secureConnect", () => {
setInterval(() => {
sendRequest(tlsSocket, createRequest("GET", "/", null));
}, 600);
setInterval(() => {
if (websocket.readyState === WebSocket.OPEN) {
websocket.ping();
}
}, 30000);
});
});
module.exports = {
startHeartbeat,
stopHeartbeat
};
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team