Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Chat Bot
- OWOP.chat.send('Chat Bot by Nurutomo\nUse -help\n/tell ' + OWOP.net.protocol.id + " <commands>");
- defaultNick = localStorage.nick;
- OWOP.chat.recvModifier = function(msg) {
- if (chatType(msg) == "nickuser") {
- nick = msg.substr((msg.indexOf("]") + 2),(msg.indexOf(": ") - 4));
- }
- if (chatType(msg) == "tell" || chatType(msg) == "nickuser") {
- id = msg.substr(1,msg.indexOf("]") - 1);
- } else {
- if (chatType(msg) == "nonick") {
- id = msg.substr(0,msg.indexOf(": ") - 1);
- }
- }
- console.log(id + nick);
- realText = getRealChat(msg);
- realText = realText;
- if (realText == "-help") {
- sendHelp(msg);
- }
- if (realText.toLowerCase().split(' ')[0] == "-setpixel") {
- console.log(nick);
- x = realText.split(' ')[1];
- y = realText.split(' ')[2];
- r = realText.split(' ')[3];
- g = realText.split(' ')[4];
- b = realText.split(' ')[5];
- x = setMinMax(x, -16777215, 16777215);
- y = setMinMax(y, -16777215, 16777215);
- r = setMinMax(r, 0, 255);
- g = setMinMax(g, 0, 255);
- b = setMinMax(b, 0, 255);
- tp(x, y, false);
- sendChat(msg,'Placed! \nX: ' + x + ' Y: ' + y + '\nrgb( ' + r + ', ' + g + ', ' + b + ')');
- setTimeout(function() {
- console.log(OWOP.world.setPixel(x, y, [r, g, b], 0));
- }, 1000);
- }
- if (realText.toLowerCase() == "-about") {
- console.log(nick);
- sendChat(msg,'Nurutomo\'s Chat Bot v1 \nCredits:\nNurutomo - Commands \nOWOP Script - Get chat, split msg, etc...\nhttps:\/\/pastebin.com\/2UK70sn0');
- setTimeout(function() {
- sendChat(msg,'Discord:\nNurutomo #6541\nBottom-Right for OWOP\'s Discord');
- }, 1000);
- setTimeout(function() {
- sendChat(msg,'You can aslo do with \n/tell ' + myId);
- }, 2000);
- }
- if (realText.toLowerCase().split(' ')[0] == "-setadminnick") {
- console.log(nick);
- message = realText;
- fakeMessage = realText.toLowerCase();
- nick = message.substr(fakeMessage.indexOf('-setadminnick ') + 14,message.length);
- if (nick.length > 12) {
- sendChat(msg,"\nNickname too long! (Max: 12)\n Your nick length: " + nick.length);
- } else {
- sendChat(msg,"\nNickname set to: '" + nick + "'");
- OWOP.chat.send('/nick ' + nick);
- localStorage["nick"] = defaultNick;
- }
- }
- if (realText.toLowerCase() == "-resetnick") {
- OWOP.chat.send('/nick ' + defaultNick);
- sendChat(msg,"\nNickname set to: '" + defaultNick + "'");
- }
- if (realText.toLowerCase().split(' ')[0] == "-logintp") {
- duration = realText.split(' ')[1];
- pass = realText.split(' ')[2];
- if (pass = load("lol")) {
- save("?", "dont!");
- sendChat(msg,'Log Out in ' + (duration / 1000) + 'sec');
- setTimeout(function() { sendChat(msg,"You has been log out!");save("?", "ok..."); }, duration);
- } else {
- save("?", "ok...");
- }
- }
- if (realText.toLowerCase().split(' ')[0] == "-tp") {
- if (load("?") = "dont!") {
- console.log(nick);
- x = realText.split(' ')[1];
- y = realText.split(' ')[2];
- x = setMinMax(x, -16777215, 16777215);
- y = setMinMax(y, -16777215, 16777215);
- tp(x, y, false);
- sendChat(msg,'\ntp( ' + x + ', ' + y + ')');
- } else {
- sendChat(msg,'You not allowed to do this!\nAsk Owner to allow you!');
- }
- }
- return msg
- }
- function sendHelp(m) {
- helpNone = ['Help: \n-help\n-setPixel <x> <y> <r> <g> <b>\n-setAdminNick <nick>\n-resetNick\n-tp <x> <y> \/\/ You need permission to do this!\n-about','This works too\n/tell ' + OWOP.net.protocol.id + " <commands>"];
- helpLength = helpNone.length;
- for (i = 0; helpLength > i; i++) {
- duration = i * 500;
- setTimeout(sendChat,duration,m,helpNone[i]);
- }
- setTimeout(function() { OWOP.chat.local('Admin Commands:\n-logintp <duration-ms> <password> \n\/\/ Ask Nurutomo on Discord for the password!'); },200);
- }
- WorldOfPixels.camera.teleport = function(x, y) {
- var m = new ArrayBuffer(9);
- var dv = new DataView(m);
- dv.setUint8(0, 3);
- dv.setInt32(1, x, true);
- dv.setInt32(5, y, true);
- var messageEvent = new MessageEvent("message", {
- "data": m,
- "origin": "ws://ourworldofpixels.com:443"
- });
- return WorldOfPixels.net.connection.dispatchEvent(messageEvent);
- };
- function tp(x, y, log) {
- WorldOfPixels.camera.teleport(x, y);
- log = isEmpty(log);
- if (!log) {
- OWOP.chat.local('Teleporting to X: ' + x + ' Y: ' + y);
- }
- }
- function isEmpty(str) {
- return (!str || 0 === str.length);
- }
- function isUndefined(str) {
- return (undefined === str);
- }
- function setMinMax(variable, min, max) {
- if (variable > max) {
- return max;
- } else if (variable < min) {
- return min;
- } else if (isUndefined(variable)) {
- return Math.floor(Math.random() * (max - min));
- } else {
- return variable;
- }
- }
- function getRealChat(message) {
- var nickname = message.split(": ")[0] + ": ";
- var text = message.slice(nickname.length);
- var idIndex = text.indexOf(': ');
- var ntext = text.substr(0, idIndex);
- return ntext.replace(/\d+/g, '') + text.slice(idIndex + 1);
- }
- function save(name, value) {
- localStorage[name.toString()] = value;
- }
- function load(name) {
- return localStorage[name.toString()];
- }
- function sendChat(o,m) {
- if (chatType(o) == "tell") {
- id = o.split(' ')[1];
- OWOP.chat.send("/tell " + id + " "+ m);
- } else {
- OWOP.chat.send(m);
- }
- }
- function chatType(text) {
- text = text.toString();
- if (text.startsWith("[D]")) {
- return "discord";
- } else if (text.startsWith("Server]") || text.startsWith("Server:") || text.startsWith("Nickname set to") || text.startsWith("User: ")) {
- return "server";
- } else if (text.startsWith("->")) {
- return "tell";
- } else if (text.startsWith("(M)")) {
- return "moderator";
- } else if (isNaN(text.split(": ")[0]) && text.split(": ")[0].charAt(0) != "[") {
- return "admin";
- } else if (text.split(": ")[0].charAt(0) == "[") {
- return "nickuser";
- } else {
- return "nonick";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment