daily pastebin goal
23%
SHARE
TWEET

[OWOP] Clock

DayDun Jan 22nd, 2019 2,035 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Sorry for ugly */
  2. const WebSocket = require("ws");
  3. const Canvas = require("canvas");
  4. const fs = require("fs");
  5. const schedule = require("node-schedule");
  6.  
  7. const adminPass = "[REDACTED]";
  8.  
  9. let pos = [55, 58];
  10.  
  11. function print(x, y, digit) {
  12.     let ii = digit * 16 * 4;
  13.     for (let chunkY=0; chunkY<2; chunkY++) {
  14.         let buffer = Buffer.alloc(8 + 256 * 3);
  15.         buffer.writeInt32LE(pos[0] + x, 0);
  16.         buffer.writeInt32LE(pos[1] + y + chunkY, 4);
  17.         let i = 8;
  18.         for (let yy=0; yy<16; yy++) {
  19.             for (let xx=0; xx<16; xx++) {
  20.                 buffer.writeUInt8(clockData[ii++], i++);
  21.                 buffer.writeUInt8(clockData[ii++], i++);
  22.                 buffer.writeUInt8(clockData[ii++], i++);
  23.                 ii++;
  24.             }
  25.             ii += (160 - 16) * 4;
  26.         }
  27.         owopBot.send(buffer);
  28.     }
  29. }
  30.  
  31. function update() {
  32.     let date = new Date();
  33.     let hour = date.getUTCHours();
  34.     let minutes = date.getUTCMinutes();
  35.    
  36.     print(0, 0, Math.floor(hour / 10));
  37.     print(1, 0, hour % 10);
  38.    
  39.     print(3, 0, Math.floor(minutes / 10));
  40.     print(4, 0, minutes % 10);
  41. }
  42.  
  43. function sendMove(x, y) {
  44.     let buffer = Buffer.alloc(12);
  45.     buffer.writeInt32LE(x || -(Math.pow(2, 31) - 1), 0);
  46.     buffer.writeInt32LE(y || -(Math.pow(2, 31) - 1), 4);
  47.     owopBot.send(buffer);
  48. }
  49.  
  50. let calc = new Canvas.Canvas(160, 32);
  51. let ctx = calc.getContext("2d");
  52. let clockData;
  53. let img = new Canvas.Image();
  54. img.src = fs.readFileSync("clock.png");;
  55. ctx.drawImage(img, 0, 0, 160, 32, 0, 0, 160, 32);
  56. clockData = ctx.getImageData(0, 0, 160, 32).data;
  57.  
  58. let botId = 0;
  59. let owopBot = new WebSocket("ws://ourworldofpixels.com:443", {
  60.     origin: "DayDun's clock"
  61. });
  62. owopBot.on("open", function() {
  63.     console.log("owop open!");
  64. });
  65. owopBot.on("message", function(data) {
  66.     if (typeof data == "string") {
  67.         return;
  68.     }
  69.     switch(data.readUInt8(0)) {
  70.         case 0: // Get id
  71.             botId = data.readUInt32LE(1);
  72.             console.log("owop ready!");
  73.             owopBot.send("/adminlogin " + adminPass + String.fromCharCode(10));
  74.             sendMove();
  75.             setInterval(sendMove, 600000);
  76.             break;
  77.         case 4: // Get admin
  78.             update();
  79.             break;
  80.         case 5: // Captcha
  81.             switch(data.readUInt8(1)) {
  82.                 case 0:
  83.                     owopBot.send("CaptchALETMEINPLS" + adminPass);
  84.                     break;
  85.                 case 3:
  86.                     owopBot.send(new Buffer([109, 97, 105, 110, 225, 16]));
  87.                     break;
  88.             }
  89.             break;
  90.     }
  91. });
  92. owopBot.on("close", function() {
  93.     console.log("owop close!!!");
  94. });
  95.  
  96. schedule.scheduleJob("0 * * * * *", function() {
  97.     update();
  98. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top