Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !async function() {
- "use strict";
- if ("undefined" == typeof w) console.error("TextWall API (w) not found! Make sure you're on tw.2s4.me");
- else {
- const o = {
- save: function(e, s) { try { return localStorage.setItem("diamondbot_" + e, JSON.stringify(s)), !0 } catch (e) { return console.error("Failed to save to storage:", e), !1 } },
- load: function(e, s = null) { try { var t = localStorage.getItem("diamondbot_" + e); return t ? JSON.parse(t) : s } catch (e) { return console.error("Failed to load from storage:", e), s } },
- remove: function(e) { try { return localStorage.removeItem("diamondbot_" + e), !0 } catch (e) { return console.error("Failed to remove from storage:", e), !1 } }
- },
- a = {
- version: "7.14.4",
- username: "diamondbot",
- color: 0,
- prefix: "\\",
- authorizedUsers: o.load("authorizedUsers", ["Diamond26", "KiwiTest"]),
- defaultAuthorities: o.load("defaultAuthorities", ["Diamond26", "KiwiTest"]),
- bannedUsers: o.load("bannedUsers", []),
- bannedIds: o.load("bannedIds", []),
- messageDelay: 150,
- position: { x: 0, y: 0 },
- heightSafetyEnabled: !0,
- lastAuthorityMessage: "",
- authorityEchoEnabled: !1,
- echoColorEnabled: !1
- },
- s = {
- wall: "", subwall: "", perms: 0, isRegistered: !1, isAdmin: !1, readonly: !1, hidecursors: !1, disablechat: !1, disablecolor: !1, disablebraille: !1, members: [], walllist: [], activeTimers: new Map, activeCounts: new Map, commandCooldowns: new Map, messageQueue: [], isProcessingQueue: !1, lastMessageTime: 0, cursors: new Map, adminUsers: new Set, processedMessages: new Set, lastSayUser: null, userPositions: new Map, userIds: new Map, isShuttingDown: !1, isTyping: !1, countdownActive: !1, clearingArea: !1
- },
- r = { "#000000": 0, "#ffffff": 1, "#ff0000": 2, "#00ff00": 3, "#0000ff": 4, "#ffff00": 5, "#ff00ff": 6, "#00ffff": 7, "#808080": 8, "#ff8800": 9, "#8800ff": 10, "#0088ff": 11, "#88ff00": 12, "#ff0088": 13, "#884400": 14, "#448800": 15 },
- n = ["to", "tp", "colorid", "addauth", "removeauth", "disablehs", "echoauth", "echocolor", "csay", "ban", "unban", "banid", "unbanid", "type", "cleararea", "wallwarp"],
- i = [
- { version: "7.14.4", changes: "Added \\rate command, addDefaultAuth/addAuth console cmds, invisible char in help" },
- { version: "7.14.3.1", changes: "Confirmed Diamond26 default authority, version bump" },
- { version: "7.14.3", changes: "Updated default authority Diamond25->Diamond26, added \\ping command" },
- { version: "7.14.2", changes: "Progress bar for tcountdown, stop option added" },
- { version: "7.14.1", changes: "Switched to getCharInfoXY for character detection" },
- { version: "7.14", changes: "\\cleararea only clears non-spaces, \\wallwarp command added" },
- { version: "7.13.4", changes: "Updated cursor detection using Array.from(w.cursors)" },
- { version: "7.13.3", changes: "10ms cleararea cooldown, w.cursors detection" },
- { version: "7.13.2", changes: "\\cleararea command, unbanName console command" },
- { version: "7.13.1", changes: "\\tcountdown and \\userlist commands added" },
- { version: "7.13", changes: "Cursor Y coordinate flipped, \\chl command added" },
- { version: "7.12", changes: "\\echocolor command, HEX-only colors, authority color echo" },
- { version: "7.11", changes: "Color syntax support with <start #HEX>text<end>" },
- { version: "7.10", changes: "\\tp command using w.tp() function" },
- { version: "7.9", changes: "Help cooldown 0.7s, thelp step 1, page command update" },
- { version: "7.8", changes: "Bug fixes and performance improvements" },
- { version: "7.7", changes: "Enhanced security and ban system" },
- { version: "7.6", changes: "Timer system improvements" },
- { version: "7.5", changes: "Authority system enhancements" },
- { version: "7.4", changes: "Added height safety toggle" },
- { version: "7.3", changes: "Colored say command (csay)" },
- { version: "7.2", changes: "Ban system with ID support" },
- { version: "7.1", changes: "Echo authority messages feature" },
- { version: "7.0", changes: "Major rewrite with improved architecture" }
- ],
- h = {
- 1: [
- { cmd: "help", desc: "Show command pages", auth: !1 },
- { cmd: "thelp", desc: "Type help on wall", auth: !1 },
- { cmd: "fullcmd", desc: "Get full command list location", auth: !1 },
- { cmd: "info", desc: "Show bot information", auth: !1 },
- { cmd: "chl", desc: "Show changelog", auth: !1 }
- ],
- 2: [
- { cmd: "ping", desc: "Responds with Pong!", auth: !1 },
- { cmd: "rate", desc: "Rate something out of 10", auth: !1 },
- { cmd: "calculate", desc: "Calculate p1^p2", auth: !1 },
- { cmd: "calc2", desc: "Calculate p1^^p2 (tetration)", auth: !1 },
- { cmd: "rng", desc: "Random number between min and max", auth: !1 }
- ],
- 3: [
- { cmd: "say", desc: "Make bot say something", auth: !1 },
- { cmd: "timer", desc: "Set a timer (h m s)", auth: !1 },
- { cmd: "count", desc: "Count from 1 to n with cooldown", auth: !1 },
- { cmd: "tcountdown", desc: "Type countdown with progress bar", auth: !1 },
- { cmd: "status", desc: "Show bot status", auth: !1 }
- ],
- 4: [
- { cmd: "pos", desc: "Show cursor position (x,y coordinates)", auth: !1 },
- { cmd: "type", desc: "Type characters on wall (Authority)", auth: !0 },
- { cmd: "page", desc: "Show detailed page info", auth: !1 },
- { cmd: "members", desc: "List wall members", auth: !1 },
- { cmd: "walls", desc: "List available subwalls", auth: !1 }
- ],
- 5: [
- { cmd: "authlist", desc: "Show authorized users", auth: !1 },
- { cmd: "userlist", desc: "Show all online users in wall", auth: !1 },
- { cmd: "to", desc: "Teleport bot to X Y (Authority)", auth: !0 },
- { cmd: "tp", desc: "Teleport to X Y using w.tp (Authority)", auth: !0 },
- { cmd: "colorid", desc: "Change bot color (Authority)", auth: !0 }
- ],
- 6: [
- { cmd: "cleararea", desc: "Clear non-space chars (Authority)", auth: !0 },
- { cmd: "csay", desc: "Say colored text (Authority)", auth: !0 },
- { cmd: "addauth", desc: "Add user to authority list (Authority)", auth: !0 },
- { cmd: "removeauth", desc: "Remove user from authority (Authority)", auth: !0 },
- { cmd: "ban", desc: "Ban user from using bot (Authority)", auth: !0 }
- ],
- 7: [
- { cmd: "unban", desc: "Unban user/ID (Authority)", auth: !0 },
- { cmd: "banid", desc: "Ban user by ID (Authority)", auth: !0 },
- { cmd: "unbanid", desc: "Unban user by ID (Authority)", auth: !0 },
- { cmd: "banlist", desc: "Show banned users (Authority)", auth: !0 },
- { cmd: "disableHS", desc: "Toggle height safety (Authority)", auth: !0 }
- ],
- 8: [
- { cmd: "echoauth", desc: "Toggle authority echo (Authority)", auth: !0 },
- { cmd: "echocolor", desc: "Toggle color echo (Authority)", auth: !0 },
- { cmd: "wallwarp", desc: "Warp to wall/subwall (Authority)", auth: !0 }
- ]
- };
- class t {
- constructor(e) {
- this.config = e;
- this.state = s;
- this.eventHandlers = {};
- this.running = !0;
- }
- async init() {
- console.log("===================================");
- console.log(` TextWall Bot v${this.config.version} Initializing `);
- console.log("===================================");
- await e();
- this.setupEventListeners();
- this.setUsername(this.config.username);
- this.setColor(this.config.color);
- this.teleportCursor(0, 0);
- setTimeout(() => {
- this.sendMessage(`${this.config.username} v${this.config.version} online! Type ${this.config.prefix}help for commands`);
- }, 2e3);
- console.log("[OK] Bot initialized successfully!");
- console.log("[OK] Prefix: " + this.config.prefix);
- console.log("[OK] Authorized users: " + this.config.authorizedUsers.join(", "));
- console.log("[OK] Default authorities: " + this.config.defaultAuthorities.join(", "));
- console.log("[OK] Banned users: " + this.config.bannedUsers.length);
- console.log("[OK] Banned IDs: " + this.config.bannedIds.length);
- console.log("[OK] Type window.showCommands() to see all commands in console");
- console.log("[OK] Color syntax: <start #HEXCOLOR>text<end>");
- console.log("[OK] Y coordinates are flipped (negated)");
- console.log("===================================");
- }
- setupEventListeners() {
- this.eventHandlers = {
- join: e => this.onJoin(e),
- alert: e => this.onAlert(e),
- msg: e => this.onMessage(e),
- edit: e => this.onEdit(e),
- protect: e => this.onProtect(e),
- clear: e => this.onClear(e),
- cursor: e => this.onCursor(e),
- cursorleft: e => this.onCursorLeft(e),
- perms: e => this.onPerms(e),
- memberadded: e => this.onMemberAdded(e),
- memberlist: e => this.onMemberList(e),
- walllist: e => this.onWallList(e),
- readonly: e => this.onReadonly(e),
- hidecursors: e => this.onHideCursors(e),
- disablechat: e => this.onDisableChat(e),
- disablecolor: e => this.onDisableColor(e),
- disablebraille: e => this.onDisableBraille(e),
- nametaken: () => this.onNameTaken(),
- passfail: () => this.onPassFail(),
- tokenfail: () => this.onTokenFail(),
- regclosed: () => this.onRegClosed(),
- namechanged: e => this.onNameChanged(e),
- accountdeleted: () => this.onAccountDeleted(),
- pong: e => this.onPong(e)
- };
- for (var [e, s] of Object.entries(this.eventHandlers)) w && w.on && w.on(e, s);
- console.log(`[OK] Registered ${Object.keys(this.eventHandlers).length} event listeners`);
- }
- cleanup() {
- this.running = !1;
- this.state.countdownActive = !1;
- this.state.clearingArea = !1;
- for (var [e, s] of Object.entries(this.eventHandlers)) w && w.off && w.off(e, s);
- this.state.activeTimers.forEach(e => { clearTimeout(e.timeout); e.intervalId && clearInterval(e.intervalId); });
- this.state.activeCounts.forEach(e => { e.intervalId && clearInterval(e.intervalId); });
- console.log("[OK] Bot cleaned up");
- }
- isAuthorized(e, s) { return s ? (this.state.adminUsers.add(e), !0) : this.config.authorizedUsers.includes(e); }
- isBanned(e) { return this.config.bannedUsers.includes(e); }
- isIdBanned(e) { return this.config.bannedIds.includes(e); }
- getUserId(e) {
- for (var [s, t] of this.state.cursors.entries())
- if (t.name === e) return s;
- return this.state.userIds.get(e) || null;
- }
- getCursorPosition(s) {
- if (this.state.userPositions.has(s)) return this.state.userPositions.get(s);
- try {
- if ("undefined" != typeof w && w.cursors)
- for (let e = 0; e < Array.from(w.cursors).length; e++) {
- var t = Array.from(w.cursors)[e][1];
- if (t && t.n === s && t.l) return [t.l[0], -t.l[1]];
- }
- } catch (e) { console.error("[CURSOR POS ERROR]", e); }
- for (var e of this.state.cursors.values())
- if (e.name === s) return e.location;
- return null;
- }
- containsAuthorityCommand(e) {
- var s, t = e.toLowerCase();
- for (s of n)
- if (t.includes("" + this.config.prefix + s)) return !0;
- return !1;
- }
- hasColorSyntax(e) { return /<start\s+#[0-9a-fA-F]{6}>([^<]*)<end>/i.test(e); }
- parseColoredMessage(e) {
- var s, t = /<start\s+(#[0-9a-fA-F]{6})>([^<]*)<end>/gi, o = [];
- let n = 0;
- for (; null !== (s = t.exec(e));) {
- s.index > n && o.push({ text: e.substring(n, s.index), color: null });
- var i = s[1].toLowerCase(), a = s[2], i = r[i];
- o.push({ text: a, color: void 0 !== i ? i : null });
- n = s.index + s[0].length;
- }
- return n < e.length && o.push({ text: e.substring(n), color: null }), 0 === o.length ? [{ text: e, color: null }] : o;
- }
- onJoin(e) { this.state.wall = e.wall || ""; this.state.subwall = e.subwall || ""; console.log(`[JOINED] ${this.state.wall}/` + this.state.subwall); }
- onAlert(e) { console.log("[ALERT] " + e.message); }
- onMessage(e) {
- var s, t, o, n;
- e && e.msg && (e.nick === this.config.username || (s = e.msg.trim(), t = e.nick || "Unknown", o = e.isAdmin || !1, (n = e.id || null) && t && this.state.userIds.set(t, n), n = t + `-${s}-` + Date.now(), this.state.processedMessages.has(n)) || (this.state.processedMessages.add(n), 100 < this.state.processedMessages.size && (n = Array.from(this.state.processedMessages)).slice(0, n.length - 100).forEach(e => { this.state.processedMessages.delete(e); }), o && this.state.adminUsers.add(t), this.isAuthorized(t, o) ? (console.log(`[AUTHORITY] ${t} ~ ` + s), this.config.echoColorEnabled && !s.startsWith(this.config.prefix) && !s.includes("[AUTHORITY COLOR]") && this.hasColorSyntax(s) ? this.sendMessage(`[AUTHORITY COLOR] ${t} ~ ` + s) : !this.config.authorityEchoEnabled || s.startsWith(this.config.prefix) || s.includes("[AUTHORITY]") || this.hasColorSyntax(s) || this.config.lastAuthorityMessage === t + ":" + s || (this.config.lastAuthorityMessage = t + ":" + s, this.sendMessage(`[AUTHORITY] ${t} ~ ` + s))) : console.log(`[MSG] ${t}${e.isRegistered ? " (R)" : ""}: ` + s), s.startsWith(this.config.prefix) && this.handleCommand(s, t, e)));
- }
- onEdit(e) { e.edits && 0 < e.edits.length && console.log(`[EDIT] ${e.edits.length} edit(s) made`); }
- onProtect(e) { console.log(`[PROTECT] Chunk ${e.cell} protection: ` + (e.protect ? "ON" : "OFF")); }
- onClear(e) { console.log(`[CLEAR] Area cleared: (${e.x1},${e.y1}) to (${e.x2},${e.y2})`); }
- onCursor(e) {
- var s;
- e.id && (s = e.l ? [e.l[0], -e.l[1]] : [0, 0], this.state.cursors.set(e.id, { name: e.n || "", location: s, color: e.c || 0 }), e.n && (this.state.userPositions.set(e.n, s), this.state.userIds.set(e.n, e.id)), e.n === this.config.username) && e.l && (this.config.position.x = e.l[0], this.config.position.y = -e.l[1]);
- }
- onCursorLeft(e) { var s = this.state.cursors.get(e); s && s.name && this.state.userPositions.delete(s.name); this.state.cursors.delete(e); }
- onPerms(e) { this.state.perms = e; console.log(`[PERMS] ${["User", "Member", "Owner"][e] || "Unknown"} (${e})`); }
- onMemberAdded(e) { console.log("[MEMBER+] " + e); this.state.members.includes(e) || this.state.members.push(e); }
- onMemberList(e) { this.state.members = e || []; console.log("[MEMBERS] " + (this.state.members.join(", ") || "None")); }
- onWallList(e) { this.state.walllist = e || []; console.log(`[WALLS] ${e.length / 2} wall(s) available`); }
- onReadonly(e) { (this.state.readonly = e) && console.log("[STATE] Wall is now READONLY"); }
- onHideCursors(e) { (this.state.hidecursors = e) && console.log("[STATE] Cursors are now HIDDEN"); }
- onDisableChat(e) { (this.state.disablechat = e) && console.log("[STATE] Chat is DISABLED"); }
- onDisableColor(e) { (this.state.disablecolor = e) && console.log("[STATE] Colors are DISABLED"); }
- onDisableBraille(e) { (this.state.disablebraille = e) && console.log("[STATE] Braille is DISABLED"); }
- onNameTaken() { console.log("[ERROR] Name is already taken!"); }
- onPassFail() { console.log("[ERROR] Invalid password!"); }
- onTokenFail() { console.log("[ERROR] Invalid token!"); }
- onRegClosed() { console.log("[ERROR] Registration is closed!"); }
- onNameChanged(e) { console.log("[OK] Name changed to: " + e); this.config.username = e; }
- onAccountDeleted() { console.log("[ERROR] Account has been deleted!"); }
- onPong(e) {}
- handleCommand(e, s, t) {
- var o, n, i, a, r = t.id || this.getUserId(s);
- r && this.isIdBanned(r) ? this.sendMessage("ERR: your id banned from using bot.") : this.isBanned(s) ? this.sendMessage("You're banned.") : ([r, ...e] = e.slice(this.config.prefix.length).split(/\s+/), o = (r = r.toLowerCase()) + "-" + (this.state.lastSayUser = s), n = this.state.commandCooldowns.get(o) || 0, i = Date.now(), a = this.isAuthorized(s, t.isAdmin), i - n < 2e3 && !a || (this.state.commandCooldowns.set(o, i), this.executeCommand(r, e, s, t)));
- }
- executeCommand(e, s, t, o) {
- const n = this.isAuthorized(t, o.isAdmin);
- e = {
- ping: () => this.cmdPing(),
- rate: () => this.cmdRate(s),
- help: () => this.cmdHelp(s),
- thelp: () => this.cmdTypeHelp(s),
- fullcmd: () => this.cmdFullcmd(),
- info: () => this.cmdInfo(),
- chl: () => this.cmdChangelog(s),
- calculate: () => this.cmdCalculate(s),
- calc2: () => this.cmdTetration(s),
- rng: () => this.cmdRandom(s),
- timer: () => this.cmdTimer(s),
- say: () => this.cmdSay(s, t, o.isAdmin),
- count: () => this.cmdCount(s),
- tcountdown: () => this.cmdTypeCountdown(s),
- status: () => this.cmdStatus(),
- pos: () => this.cmdPosition(s, t),
- page: () => this.cmdPage(s),
- members: () => this.cmdMembers(),
- walls: () => this.cmdWalls(),
- authlist: () => this.cmdAuthList(),
- userlist: () => this.cmdUserList(),
- to: () => n ? this.cmdTeleport(s) : this.sendMessage("Permission invalid - Authority required"),
- tp: () => n ? this.cmdTp(s) : this.sendMessage("Permission invalid - Authority required"),
- type: () => n ? this.cmdType(s) : this.sendMessage("Permission invalid - Authority required"),
- colorid: () => n ? this.cmdColor(s) : this.sendMessage("Permission invalid"),
- cleararea: () => n ? this.cmdClearArea(s) : this.sendMessage("Permission invalid - Authority required"),
- csay: () => n ? this.cmdColoredSay(s) : this.sendMessage("Permission invalid - Authority required"),
- addauth: () => n ? this.cmdAddAuth(s) : this.sendMessage("Permission invalid - Authority required"),
- removeauth: () => n ? this.cmdRemoveAuth(s) : this.sendMessage("Permission invalid - Authority required"),
- ban: () => n ? this.cmdBan(s) : this.sendMessage("Permission invalid - Authority required"),
- unban: () => n ? this.cmdUnban(s) : this.sendMessage("Permission invalid - Authority required"),
- banid: () => n ? this.cmdBanId(s) : this.sendMessage("Permission invalid - Authority required"),
- unbanid: () => n ? this.cmdUnbanId(s) : this.sendMessage("Permission invalid - Authority required"),
- banlist: () => n ? this.cmdBanList() : this.sendMessage("Permission invalid - Authority required"),
- disablehs: () => n ? this.cmdDisableHeightSafety() : this.sendMessage("Permission invalid - Authority required"),
- echoauth: () => n ? this.cmdToggleEcho() : this.sendMessage("Permission invalid - Authority required"),
- echocolor: () => n ? this.cmdToggleEchoColor() : this.sendMessage("Permission invalid - Authority required"),
- wallwarp: () => n ? this.cmdWallWarp(s) : this.sendMessage("Permission invalid - Authority required")
- }[e];
- e && e();
- }
- cmdPing() {
- this.sendMessage("Pong!");
- }
- cmdRate(e) {
- if (e.length < 1) this.sendMessage(`Usage: ${this.config.prefix}rate [something]`);
- else {
- var s = e.join(" "),
- t = Math.floor(Math.random() * 11);
- this.sendMessage(`I rate ${s} as ${t}/10`);
- }
- }
- cmdHelp(e) {
- var s, e = e[0];
- void 0 === e || !isNaN(e) && Number.isInteger(Number(e)) ? (e = parseInt(e) || 1, s = Object.keys(h).length, e < 1 || s < e ? this.sendMessage(`Invalid number. Use ${this.config.prefix}help 1-` + s) : (this.sendMessage(`Commands Page ${e}/${s}:`), h[e].forEach((e, s) => { setTimeout(() => { this.sendMessage(`${this.config.prefix}\u200B${e.cmd}${e.auth ? " [A]" : ""} - ` + e.desc); }, 700 * (s + 1)); }))) : this.sendMessage("Invalid number.");
- }
- cmdChangelog(e) {
- var s, t, o, e = e[0];
- void 0 === e || !isNaN(e) && Number.isInteger(Number(e)) ? (s = Math.ceil(i.length / 5), (e = parseInt(e) || 1) < 1 || s < e ? this.sendMessage(`Invalid number. Use ${this.config.prefix}chl 1-` + s) : (o = 5 * (e - 1), t = Math.min(5 + o, i.length), o = i.slice(o, t), this.sendMessage(`Changelog Page ${e}/${s}:`), o.forEach((e, s) => { setTimeout(() => { this.sendMessage(`v${e.version}: ` + e.changes); }, 700 * (s + 1)); }))) : this.sendMessage("Invalid number.");
- }
- cmdTypeCountdown(e) {
- if (0 < e.length && "stop" === e[0].toLowerCase()) return this.state.countdownActive ? (this.state.countdownActive = !1, this.sendMessage("Countdown stopped."), void console.log("[TCOUNTDOWN] Countdown stopped by user")) : void this.sendMessage("No countdown is currently active.");
- if (this.state.countdownActive) this.sendMessage("Countdown already active! Use \\tcountdown stop to stop it.");
- else if (e.length < 1) this.sendMessage(`Usage: ${this.config.prefix}tcountdown [seconds] or ${this.config.prefix}tcountdown stop`);
- else {
- e = parseInt(e[0]);
- if (isNaN(e) || e <= 0) this.sendMessage("Error: seconds must be a positive integer");
- else if (86400 < e) this.sendMessage("Error: seconds cannot exceed 86400 (24 hours)");
- else if ("function" != typeof w.tp || "function" != typeof w.typeChar) this.sendMessage("Error: w.tp or w.typeChar function not available");
- else {
- this.state.countdownActive = !0;
- const r = e;
- let a = e;
- const l = 6, h = -4, c = 14,
- d = (this.sendMessage(`Starting countdown from ${e}s at (0, -5)...`), setInterval(() => {
- if (!this.running || !this.state.countdownActive || a < 0) clearInterval(d), this.state.countdownActive = !1, a < 0 && this.sendMessage("Countdown complete!");
- else {
- try {
- w.tp(0, -5);
- var s, t = Math.floor(a / 3600), o = Math.floor(a % 3600 / 60), n = a % 60;
- let e = "";
- 0 < t && (e += t + "h "), 0 < o && (e += o + "m "), (0 < n || "" === e) && (e += n + "s");
- for (s of e = e.trim()) w.typeChar(s, 1);
- var i = 25 - e.length;
- for (let e = 0; e < i; e++) w.typeChar(" ", 1);
- ((e, s) => {
- var t = e / s * c;
- let o = "";
- for (let e = 0; e < c; e++) { var n = t - e; o += 1 <= n ? "█" : .75 <= n ? "▓" : .5 <= n ? "▒" : .25 <= n ? "░" : "•"; }
- try { w.tp(l, h); for (var i of o) w.typeChar(i, 1); } catch (e) { console.error("[TCOUNTDOWN] Failed to update progress bar:", e); }
- })(r - a, r);
- console.log(`[TCOUNTDOWN] Typed "${e}" at (0, -5)`);
- } catch (e) { return console.error("[TCOUNTDOWN ERROR] Failed to type countdown:", e), clearInterval(d), void (this.state.countdownActive = !1); }
- a--;
- }
- }, 1e3));
- }
- }
- }
- async cmdClearArea(e) {
- if (this.state.clearingArea) this.sendMessage("Already clearing area! Please wait.");
- else if (2 !== e.length && 4 !== e.length) this.sendMessage(`Usage: ${this.config.prefix}cleararea x y OR x1 y1 x2 y2`);
- else if ("function" != typeof w.tp || "function" != typeof w.typeChar || "function" != typeof getCharInfoXY) this.sendMessage("Error: w.tp, w.typeChar or getCharInfoXY function not available");
- else if (2 === e.length) {
- var s = parseInt(e[0]), t = parseInt(e[1]);
- if (isNaN(s) || isNaN(t)) this.sendMessage("Invalid coordinates. Please provide integers.");
- else {
- var o = -t;
- try {
- this.state.clearingArea = !0;
- var n = getCharInfoXY(s, o);
- n && n.char && " " !== n.char ? (w.tp(s, o), w.typeChar(" ", 1), this.sendMessage(`Cleared position (${s}, ${t})`), console.log(`[CLEARAREA] Cleared single point at (${s}, ${o})`)) : this.sendMessage(`Position (${s}, ${t}) is already empty`);
- } catch (e) { this.sendMessage("Error clearing area: " + (e.message || "Unknown error")); console.error("[CLEARAREA ERROR]", e); } finally { this.state.clearingArea = !1; }
- }
- } else {
- n = parseInt(e[0]); o = parseInt(e[1]); s = parseInt(e[2]); t = parseInt(e[3]);
- if (isNaN(n) || isNaN(o) || isNaN(s) || isNaN(t)) this.sendMessage("Invalid coordinates. Please provide integers.");
- else {
- var e = -o, i = -t,
- a = Math.min(n, s), r = Math.max(n, s),
- l = Math.min(e, i), h = Math.max(e, i),
- e = r - a + 1, i = h - l + 1;
- if (1e4 < e * i) this.sendMessage("Error: Area too large (max 10000 characters)");
- else {
- this.sendMessage(`Clearing non-space chars from (${n}, ${o}) to (${s}, ${t})...`);
- this.state.clearingArea = !0;
- try {
- let t = 0;
- for (let s = l; s <= h && (this.running && this.state.clearingArea); s++)
- for (let e = a; e <= r && (this.running && this.state.clearingArea); e++) {
- var c = getCharInfoXY(e, s);
- c && c.char && " " !== c.char && (w.tp(e, s), w.typeChar(" ", 1), t++, await new Promise(e => setTimeout(e, 10)));
- }
- this.sendMessage(`Cleared ${t} non-space chars in ${e}x${i} area`);
- console.log(`[CLEARAREA] Cleared ${t} chars from (${a}, ${l}) to (${r}, ${h})`);
- } catch (e) { this.sendMessage("Error clearing area: " + (e.message || "Unknown error")); console.error("[CLEARAREA ERROR]", e); } finally { this.state.clearingArea = !1; }
- }
- }
- }
- }
- cmdWallWarp(e) {
- if (2 !== e.length) this.sendMessage(`Usage: ${this.config.prefix}wallwarp wall subwall`);
- else if ("function" != typeof w.goto) this.sendMessage("Error: w.goto function not available");
- else {
- var s = e[0], e = e[1];
- try { w.goto(s, e); this.sendMessage(`Warping to ${s}/${e}...`); console.log(`[WALLWARP] Warping to ${s}/` + e); } catch (e) { this.sendMessage("Error warping to wall: " + (e.message || "Unknown error")); console.error("[WALLWARP ERROR]", e); }
- }
- }
- cmdUserList() {
- var s = [];
- try {
- if ("undefined" != typeof w && w.cursors)
- for (let e = 0; e < Array.from(w.cursors).length; e++) s.push(Array.from(w.cursors)[e][1].n);
- else for (var e of this.state.cursors.values()) e.name && !s.includes(e.name) && s.push(e.name);
- } catch (e) { console.error("[USERLIST ERROR]", e); for (var t of this.state.cursors.values()) t.name && !s.includes(t.name) && s.push(t.name); }
- s.sort();
- 0 === s.length ? this.sendMessage("Online Users: None") : this.sendMessage("Online Users: " + s.join(", "));
- console.log("Userlist: " + s.join(", "));
- }
- cmdTypeHelp(e) {
- if (this.state.isTyping) this.sendMessage("Bot is already typing. Please wait.");
- else {
- e = e[0];
- if (e && !isNaN(e) && Number.isInteger(Number(e))) {
- const i = parseInt(e);
- e = Object.keys(h).length;
- if (i < 1 || i > e) this.sendMessage(`Invalid page. Use ${this.config.prefix}thelp 1-` + e);
- else if ("function" != typeof w.typeChar) this.sendMessage("Error: typeChar function not available");
- else {
- e = h[i];
- const a = [`Commands [PAGE: ${i}]`],
- r = (e.forEach(e => { a.push("" + this.config.prefix + e.cmd + (e.auth ? " [A]" : "") + " - " + e.desc); }), this.state.isTyping = !0, this.config.position.x);
- let t = this.config.position.y, o = 0, n = 0;
- this.sendMessage(`Typing help page ${i} on wall...`);
- const l = () => {
- if (this.running && this.state.isTyping)
- if (o >= a.length) this.state.isTyping = !1, console.log("[THELP] Finished typing help page " + i);
- else {
- var e = a[o];
- if (n >= e.length) this.teleportCursor(r, t + 1), t++, o++, n = 0, o < a.length ? setTimeout(l, 100) : (this.state.isTyping = !1, console.log("[THELP] Finished typing help page " + i));
- else try { var s = e[n]; w.typeChar(s, 1); n++; setTimeout(l, 30); } catch (e) { console.error("[THELP ERROR] Failed to type character:", e); this.state.isTyping = !1; }
- }
- else this.state.isTyping = !1;
- };
- this.teleportCursor(r, t);
- l();
- }
- } else this.sendMessage(`Usage: ${this.config.prefix}thelp [page number]`);
- }
- }
- cmdFullcmd() { this.sendMessage("if you wanna see all the commands, head to ~KiwiTest/diamondbot"); }
- cmdInfo() { this.sendMessage("This bot was made by KiwiTest, version " + this.config.version); }
- cmdPage(e) {
- var e = parseInt(e[0]) || 1, s = Object.keys(h).length;
- e < 1 || s < e ? this.sendMessage("Invalid page. Pages: 1-" + s) : (this.sendMessage(`Page ${e} Detailed Info:`), h[e].forEach((e, s) => { setTimeout(() => { this.sendMessage(`${s + 1}. ${this.config.prefix}\u200B${e.cmd} - ` + e.desc); }, 700 * (s + 1)); }));
- }
- cmdSay(e, s, t) {
- if (e.length < 1) this.sendMessage(`Usage: ${this.config.prefix}say [message]`);
- else {
- e = e.join(" ");
- if (this.containsAuthorityCommand(e))
- if (!this.isAuthorized(s, t)) return this.sendMessage("ERR: trying to bypass authority!"), void console.log(`[SECURITY] User ${s} attempted to bypass authority with say command!`);
- this.sendMessage(e);
- }
- }
- cmdType(e) {
- if (e.length < 2) this.sendMessage(`Usage: ${this.config.prefix}type text step (step can be number or 'all')`);
- else {
- var t = e.slice(0, -1).join(" "), e = e[e.length - 1].toLowerCase();
- if (0 === t.length) this.sendMessage("Error: No text provided");
- else if ("function" != typeof w.typeChar) this.sendMessage("Error: typeChar function not available");
- else if ("all" === e) {
- let e = 0;
- for (let s = 0; s < t.length; s++) {
- const n = t[s];
- setTimeout(() => { try { w.typeChar(n, s); console.log(`[TYPE] Typed '${n}' at step ` + s); } catch (e) { console.error(`[TYPE ERROR] Failed to type '${n}' at step ${s}:`, e); } }, e);
- e += 50;
- }
- void this.sendMessage(`Typing "${t}" across ${t.length} steps`);
- } else {
- var s = parseInt(e);
- if (isNaN(s)) this.sendMessage("Error: Step must be a number or 'all'");
- else if (s < 0) this.sendMessage("Error: Step must be non-negative");
- else try { for (var o of t) w.typeChar(o, s); this.sendMessage(`Typed "${t}" at step ` + s); console.log(`[TYPE] Typed "${t}" at step ` + s); } catch (e) { this.sendMessage("Error typing text: " + (e.message || "Unknown error")); console.error("[TYPE ERROR]", e); }
- }
- }
- }
- cmdCount(s) {
- if (s.length < 2) this.sendMessage(`Usage: ${this.config.prefix}count n cooldown`);
- else {
- const t = parseInt(s[0]);
- s = parseInt(s[1]);
- if (isNaN(t) || !Number.isInteger(t) || t <= 0) this.sendMessage("Error: n must be a positive integer");
- else if (isNaN(s) || !Number.isInteger(s) || s < 100) this.sendMessage("Error: cooldown must be an integer >= 100 (milliseconds)");
- else if (100 < t) this.sendMessage("Error: n cannot exceed 100");
- else {
- const o = Date.now();
- let e = 1;
- this.sendMessage(`Starting count to ${t} with ${s}ms delay...`);
- const n = setInterval(() => {
- e > t || !this.running ? (clearInterval(n), this.state.activeCounts.delete(o), e > t && this.sendMessage("Count complete!")) : (this.sendMessage(e.toString()), e++);
- }, s);
- this.state.activeCounts.set(o, { intervalId: n, max: t });
- }
- }
- }
- cmdColoredSay(s) {
- if (s.length < 2) this.sendMessage(`Usage: ${this.config.prefix}csay [colorid] [text]`);
- else {
- var t = s[0].toLowerCase();
- let e;
- if (isNaN(t)) { if (!t.startsWith("#")) return void this.sendMessage("Invalid colorid"); if (void 0 === (e = r[t])) return void this.sendMessage("Invalid colorid"); }
- else if ((e = parseInt(t)) < 0 || 15 < e) return void this.sendMessage("Invalid colorid");
- const o = s.slice(1).join(" ");
- if (o && 0 !== o.trim().length) {
- const n = this.config.color;
- this.setColor(e);
- setTimeout(() => { this.sendMessage(o); setTimeout(() => { this.setColor(n); }, 100); }, 100);
- } else this.sendMessage("Invalid text characters");
- }
- }
- cmdCalculate(e) {
- if (e.length < 2) this.sendMessage(`Usage: ${this.config.prefix}calculate base exponent`);
- else try {
- var s = e[0], t = e[1], o = window.Decimal.pow(new window.Decimal(s), new window.Decimal(t));
- this.sendMessage(s + `^${t} = ` + o.toString());
- } catch (e) { this.sendMessage("Error: Invalid input for calculation"); }
- }
- cmdTetration(e) {
- if (e.length < 2) this.sendMessage(`Usage: ${this.config.prefix}calc2 base height`);
- else try {
- var s, t = e[0], o = parseInt(e[1]);
- o < 0 || !Number.isInteger(o) ? this.sendMessage("Height must be a non-negative integer") : this.config.heightSafetyEnabled && 5 < o ? this.sendMessage("Height too large! Maximum is 5 (Height Safety ON)") : (s = window.Decimal.tetrate(new window.Decimal(t), o), this.sendMessage(t + `^^${o} = ` + s.toString()));
- } catch (e) { this.sendMessage("Error: Invalid input for tetration"); }
- }
- cmdRandom(e) {
- var s, t;
- e.length < 2 ? this.sendMessage(`Usage: ${this.config.prefix}rng min max`) : (s = parseFloat(e[0]), e = parseFloat(e[1]), isNaN(s) || isNaN(e) ? this.sendMessage("Invalid input. Please provide valid numbers.") : e < s ? this.sendMessage("Min must be less than or equal to max.") : (t = Math.random() * (e - s) + s, this.sendMessage(`Random number between ${s} and ${e}: ` + t.toFixed(2))));
- }
- cmdTimer(s) {
- if (s.length < 3) this.sendMessage(`Usage: ${this.config.prefix}timer hours minutes seconds (use 0 to skip)`);
- else {
- var t = Math.max(0, parseInt(s[0]) || 0), o = Math.max(0, parseInt(s[1]) || 0), s = Math.max(0, parseInt(s[2]) || 0);
- if (0 === t && 0 === o && 0 === s) this.sendMessage("Timer must have at least one non-zero value");
- else if (24 < t) this.sendMessage("Maximum timer is 24 hours");
- else {
- var i = 1e3 * (3600 * t + 60 * o + s);
- let e = [];
- 0 < t && e.push(t + "h"), 0 < o && e.push(o + "m"), 0 < s && e.push(s + "s");
- const a = Date.now();
- this.sendMessage(`Timer set for ${e.join(" ")} (ID: ${a})`);
- t = setTimeout(() => { this.sendMessage(`TIMER COMPLETE! ${e.join(" ")} has elapsed (ID: ${a})`); this.state.activeTimers.delete(a); }, i);
- if (this.state.activeTimers.set(a, { timeout: t, duration: e.join(" "), startTime: Date.now(), endTime: Date.now() + i }), 6e4 < i) {
- let n = 0;
- o = Math.max(3e4, i / 4);
- const r = setInterval(() => {
- var e, s, t, o = this.state.activeTimers.get(a);
- !o || 3 <= n ? clearInterval(r) : 1e3 < (o = o.endTime - Date.now()) && (e = Math.floor(o / 36e5), s = Math.floor(o % 36e5 / 6e4), o = Math.floor(o % 6e4 / 1e3), t = [], 0 < e && t.push(e + "h"), 0 < s && t.push(s + "m"), 0 < o && t.push(o + "s"), this.sendMessage(`Timer ${a}: ${t.join(" ")} remaining`), n++);
- }, o);
- this.state.activeTimers.get(a).intervalId = r;
- }
- }
- }
- }
- cmdStatus() {
- var e = [
- `Wall: ${this.state.wall}/` + this.state.subwall,
- "Perms: " + ["User", "Member", "Owner"][this.state.perms],
- `Pos: (${this.config.position.x}, ${this.config.position.y})`,
- "Timers: " + this.state.activeTimers.size,
- "Color: " + this.config.color,
- "HS: " + (this.config.heightSafetyEnabled ? "ON" : "OFF"),
- "Echo: " + (this.config.authorityEchoEnabled ? "ON" : "OFF"),
- "EchoColor: " + (this.config.echoColorEnabled ? "ON" : "OFF"),
- "Auth: " + this.config.authorizedUsers.length,
- `Banned: ${this.config.bannedUsers.length}/` + this.config.bannedIds.length
- ];
- this.sendMessage(e.join(" | "));
- }
- cmdPosition(e, s) {
- if (0 === e.length) {
- const t = this.getCursorPosition(s);
- void (t ? this.sendMessage(`Cursor position of ${s}: (${t[0]}, ${t[1]})`) : this.sendMessage(`Cursor position of ${s}: Not found in wall`));
- } else {
- s = e[0];
- const t = this.getCursorPosition(s);
- t ? this.sendMessage(`Cursor position of ${s}: (${t[0]}, ${t[1]})`) : this.sendMessage(`Cursor position of ${s}: Not found in wall`);
- }
- }
- cmdMembers() { 0 === this.state.members.length ? this.sendMessage("No members in this wall") : this.sendMessage("Members: " + this.state.members.join(", ")); }
- cmdWalls() {
- if (0 === this.state.walllist.length) this.sendMessage("No subwalls available");
- else {
- var s = [];
- for (let e = 0; e < this.state.walllist.length; e += 2) { var t = this.state.walllist[e], o = this.state.walllist[e + 1]; s.push(t + (o ? " (private)" : "")); }
- this.sendMessage("Subwalls: " + s.join(", "));
- }
- }
- cmdTeleport(e) {
- var s;
- e.length < 2 ? this.sendMessage(`Usage: ${this.config.prefix}to X Y`) : (s = parseInt(e[0]), e = parseInt(e[1]), isNaN(s) || isNaN(e) ? this.sendMessage("Invalid coordinates. Please provide integers.") : 1e4 < Math.abs(s) || 1e4 < Math.abs(e) ? this.sendMessage("Coordinates out of range (max +-10000)") : (this.teleportCursor(s, e), this.sendMessage(`Teleported to (${s}, ${e})`)));
- }
- cmdTp(e) {
- if (e.length < 2) this.sendMessage(`Usage: ${this.config.prefix}tp X Y`);
- else {
- var s = parseInt(e[0]), e = parseInt(e[1]);
- if (isNaN(s) || isNaN(e)) this.sendMessage("Invalid coordinates. Please provide integers.");
- else if (1e4 < Math.abs(s) || 1e4 < Math.abs(e)) this.sendMessage("Coordinates out of range (max +-10000)");
- else if ("function" != typeof w.tp) this.sendMessage("Error: w.tp function not available");
- else try { w.tp(s, e); this.config.position.x = s; this.config.position.y = e; this.sendMessage(`Teleported to (${s}, ${e}) using w.tp`); console.log(`[TP] Teleported to (${s}, ${e}) using w.tp`); } catch (e) { this.sendMessage("Error using w.tp: " + (e.message || "Unknown error")); console.error("[TP ERROR]", e); }
- }
- }
- cmdColor(s) {
- if (s.length < 1) this.sendMessage(`Usage: ${this.config.prefix}colorid #hex or 0-15`);
- else {
- s = s[0].toLowerCase();
- let e;
- if (isNaN(s)) { if (!s.startsWith("#")) return void this.sendMessage("Invalid colot"); if (void 0 === (e = r[s])) return void this.sendMessage("Invalid colot"); }
- else if ((e = parseInt(s)) < 0 || 15 < e) return void this.sendMessage("Invalid colot");
- this.setColor(e);
- this.sendMessage("Color changed to " + e);
- }
- }
- cmdBan(e) {
- e.length < 1 ? this.sendMessage(`Usage: ${this.config.prefix}ban username`) : this.config.authorizedUsers.includes(e = e[0]) ? this.sendMessage("Cannot ban authority user " + e) : this.config.bannedUsers.includes(e) ? this.sendMessage(e + " is already banned") : (this.config.bannedUsers.push(e), o.save("bannedUsers", this.config.bannedUsers), this.sendMessage(`Banned ${e} from using bot`), console.log(`[BAN] ${e} has been banned`));
- }
- cmdUnban(e) {
- var s, t;
- e.length < 1 ? this.sendMessage(`Usage: ${this.config.prefix}unban username or ID`) : (e = e[0], isNaN(e) ? -1 === (s = this.config.bannedUsers.indexOf(t = e)) ? this.sendMessage(`Error: ${t} is not banned`) : (this.config.bannedUsers.splice(s, 1), o.save("bannedUsers", this.config.bannedUsers), this.sendMessage("Unbanned " + t), console.log(`[UNBAN] ${t} has been unbanned`)) : -1 === (t = this.config.bannedIds.indexOf(s = e)) ? this.sendMessage(`Error: ID ${s} is not banned`) : (this.config.bannedIds.splice(t, 1), o.save("bannedIds", this.config.bannedIds), this.sendMessage("Unbanned ID " + s), console.log(`[UNBAN] ID ${s} has been unbanned`)));
- }
- cmdBanId(e) {
- var s;
- e.length < 1 ? this.sendMessage(`Usage: ${this.config.prefix}banid username`) : (s = this.getUserId(e = e[0])) ? this.config.authorizedUsers.includes(e) ? this.sendMessage("Cannot ban authority user " + e) : this.config.bannedIds.includes(s) ? this.sendMessage(`User ID ${s} is already banned`) : (this.config.bannedIds.push(s), o.save("bannedIds", this.config.bannedIds), this.sendMessage(`Banned user ID for ${e} (ID: ${s})`), console.log(`[BANID] ${e} (ID: ${s}) has been banned`)) : this.sendMessage(`Cannot find user ID for ${e}. User must be in wall.`);
- }
- cmdUnbanId(e) {
- var s;
- e.length < 1 ? this.sendMessage(`Usage: ${this.config.prefix}unbanid userid`) : -1 === (s = this.config.bannedIds.indexOf(e = e[0])) ? this.sendMessage(`ID ${e} is not banned`) : (this.config.bannedIds.splice(s, 1), o.save("bannedIds", this.config.bannedIds), this.sendMessage("Unbanned ID " + e), console.log(`[UNBANID] ID ${e} has been unbanned`));
- }
- cmdBanList() {
- var e = 0 === this.config.bannedUsers.length ? "None" : this.config.bannedUsers.join(", "),
- s = 0 === this.config.bannedIds.length ? "None" : this.config.bannedIds.length + " IDs";
- this.sendMessage(`Banned users: ${e} | Banned IDs: ` + s);
- }
- cmdAddAuth(e) {
- var s;
- e.length < 1 ? this.sendMessage(`Usage: ${this.config.prefix}addauth username`) : this.config.authorizedUsers.includes(e = e[0]) ? this.sendMessage(e + " already has authority") : (-1 !== (s = this.config.bannedUsers.indexOf(e)) && (this.config.bannedUsers.splice(s, 1), o.save("bannedUsers", this.config.bannedUsers)), this.config.authorizedUsers.push(e), o.save("authorizedUsers", this.config.authorizedUsers), this.sendMessage(`Added ${e} to authority list`), console.log("[AUTH+] Authority granted to: " + e));
- }
- cmdRemoveAuth(e) {
- var s;
- e.length < 1 ? this.sendMessage(`Usage: ${this.config.prefix}removeauth username`) : this.config.defaultAuthorities.includes(e = e[0]) ? this.sendMessage("Cannot remove default authority from " + e) : -1 === (s = this.config.authorizedUsers.indexOf(e)) ? this.sendMessage(e + " doesn't have authority") : (this.config.authorizedUsers.splice(s, 1), o.save("authorizedUsers", this.config.authorizedUsers), this.sendMessage(`Removed ${e} from authority list`), console.log("[AUTH-] Authority revoked from: " + e));
- }
- cmdDisableHeightSafety() {
- this.config.heightSafetyEnabled = !this.config.heightSafetyEnabled;
- var e = this.config.heightSafetyEnabled ? "ENABLED" : "DISABLED",
- s = this.config.heightSafetyEnabled ? "(Max height: 5)" : "(No height limit)";
- this.sendMessage(`Height safety is now ${e} ` + s);
- console.log("Height safety: " + e);
- }
- cmdToggleEcho() {
- this.config.authorityEchoEnabled ? (this.config.authorityEchoEnabled = !1, this.sendMessage("Authority echo is now DISABLED")) : (this.config.authorityEchoEnabled = !0, this.sendMessage("Authority echo is now ENABLED (with recursion protection)"));
- console.log("Authority echo: " + (this.config.authorityEchoEnabled ? "ENABLED" : "DISABLED"));
- }
- cmdToggleEchoColor() {
- this.config.echoColorEnabled ? (this.config.echoColorEnabled = !1, this.sendMessage("Color echo is now DISABLED")) : (this.config.echoColorEnabled = !0, this.sendMessage("Color echo is now ENABLED (echoes authority messages with color syntax)"));
- console.log("Color echo: " + (this.config.echoColorEnabled ? "ENABLED" : "DISABLED"));
- }
- cmdAuthList() {
- var e = [...this.config.authorizedUsers], s = Array.from(this.state.adminUsers), e = [...new Set([...e, ...s])];
- this.sendMessage(`Authorized users (${e.length}): ` + e.join(", "));
- }
- setUsername(e) { "undefined" != typeof api && api.nick ? api.nick(e) : "function" == typeof setNick ? setNick(e) : "function" == typeof changeNick && changeNick(e); console.log("[USERNAME] " + e); }
- setColor(e) { "undefined" != typeof api && api.color ? api.color(e) : "function" == typeof setColor && setColor(e); this.config.color = e; console.log("[COLOR] Set to: " + e); }
- teleportCursor(e, s) { "undefined" != typeof api && api.cursor ? api.cursor(e, s) : "function" == typeof moveCursor ? moveCursor(e, s) : "object" == typeof cursor && cursor.move && cursor.move(e, s); this.config.position.x = e; this.config.position.y = s; }
- sendMessage(e) {
- if (this.state.disablechat && !this.state.isShuttingDown) console.log("Chat is disabled, cannot send message");
- else {
- const o = this.parseColoredMessage(e);
- if (1 < o.length || 1 === o.length && null !== o[0].color) {
- const n = this.config.color;
- let t = 0;
- void o.forEach((e, s) => {
- setTimeout(() => {
- null !== e.color ? this.setColor(e.color) : 0 < s && this.setColor(n);
- setTimeout(() => { this.state.messageQueue.push(e.text); this.state.isProcessingQueue || this.processMessageQueue(); s === o.length - 1 && setTimeout(() => { this.setColor(n); }, 100); }, 50);
- }, t);
- t += 200;
- });
- } else { this.state.messageQueue.push(e); this.state.isProcessingQueue || this.processMessageQueue(); }
- }
- }
- async processMessageQueue() {
- if (0 === this.state.messageQueue.length || !this.running && !this.state.isShuttingDown) this.state.isProcessingQueue = !1;
- else {
- this.state.isProcessingQueue = !0;
- var e = this.state.messageQueue.shift();
- const s = Date.now() - this.state.lastMessageTime;
- s < this.config.messageDelay && await new Promise(e => setTimeout(e, this.config.messageDelay - s));
- this.state.lastMessageTime = Date.now();
- try { w && w.chat && w.chat.send ? (w.chat.send(e), console.log("[SENT] " + e)) : "function" == typeof sendChat ? sendChat(e) : "undefined" != typeof api && api.chat ? api.chat(e) : console.error("No chat send method available!"); } catch (e) { console.error("Failed to send message:", e); }
- setTimeout(() => this.processMessageQueue(), this.config.messageDelay);
- }
- }
- }
- console.clear();
- console.log(`Starting TextWall Bot v${a.version}...`);
- const l = new t(a);
- async function e() {
- if (void 0 !== window.Decimal) console.log("[OK] Break Eternity already loaded");
- else {
- var s;
- for (s of ["https://cdn.jsdelivr.net/npm/break_eternity.js@latest/break_eternity.min.js", "https://unpkg.com/break_eternity.js@latest/dist/break_eternity.min.js", "https://cdnjs.cloudflare.com/ajax/libs/break_eternity.js/1.3.0/break_eternity.min.js"]) try {
- if (await function(o) { return new Promise((e, s) => { var t = document.createElement("script"); t.src = o; t.onload = e; t.onerror = s; document.head.appendChild(t); }); }(s), void 0 !== window.Decimal) return console.log("[OK] Break Eternity loaded from: " + s), !0;
- } catch (e) { console.warn("Failed to load from " + s); }
- window.Decimal = class i {
- constructor(e) { this.value = "string" == typeof e || "number" == typeof e ? parseFloat(e) || 0 : e?.value || 0; }
- static pow(e, s) { e = e instanceof i ? e.value : parseFloat(e); s = s instanceof i ? s.value : parseFloat(s); if (0 === s) return new i(1); if (0 === e) return new i(0); let t; return t = 308 < Math.abs(s) ? 0 < s ? 1 / 0 : 0 : Math.pow(e, s), new i(t); }
- static tetrate(e, s) { var t = e instanceof i ? e.value : parseFloat(e), o = parseInt(s); if (0 === o) return new i(1); if (1 === o) return new i(t); if (0 === t) return new i(0); if (!a.heightSafetyEnabled) { let s = t; for (let e = 1; e < o && (s = Math.pow(t, s), isFinite(s)); e++); return new i(s); } let n = t; for (let e = 1; e < o && e < 5 && (n = Math.pow(t, n), isFinite(n)); e++); return new i(n); }
- toString() { return isFinite(this.value) ? Math.abs(this.value) < 1e-6 ? "0" : Math.abs(this.value) < 1e6 && .001 < Math.abs(this.value) ? this.value.toString() : this.value.toExponential(2) : 0 < this.value ? "Infinity" : "-Infinity"; }
- };
- console.log("[OK] Using fallback Decimal implementation");
- }
- return !0;
- }
- await l.init();
- window.diamondBot = l;
- window.sendMessage = function(e) { e ? (l.sendMessage("[SYSTEM]: " + e), console.log("[SYSTEM MESSAGE SENT]: " + e)) : console.error("Error: No message provided. Usage: sendMessage('your message')"); };
- window.unbanName = function(e) {
- var s;
- e ? -1 === (s = l.config.bannedUsers.indexOf(e)) ? console.error(`Error: ${e} is not in the ban list`) : (l.config.bannedUsers.splice(s, 1), o.save("bannedUsers", l.config.bannedUsers), console.log(`[CONSOLE UNBAN] ${e} has been unbanned from the ban list`), console.log("Current banned users: " + (0 < l.config.bannedUsers.length ? l.config.bannedUsers.join(", ") : "None"))) : console.error("Error: No username provided. Usage: unbanName('username')");
- };
- window.addDefaultAuth = function(e) {
- if (!e) return void console.error("Error: No username provided. Usage: addDefaultAuth('username')");
- if (l.config.defaultAuthorities.includes(e)) return void console.error(`Error: ${e} is already a default authority`);
- l.config.defaultAuthorities.push(e);
- o.save("defaultAuthorities", l.config.defaultAuthorities);
- if (!l.config.authorizedUsers.includes(e)) {
- l.config.authorizedUsers.push(e);
- o.save("authorizedUsers", l.config.authorizedUsers);
- }
- var s = l.config.bannedUsers.indexOf(e);
- -1 !== s && (l.config.bannedUsers.splice(s, 1), o.save("bannedUsers", l.config.bannedUsers));
- console.log(`[DEFAULT AUTH+] ${e} has been added as a default authority`);
- console.log("Default authorities: " + l.config.defaultAuthorities.join(", "));
- console.log("Authorized users: " + l.config.authorizedUsers.join(", "));
- };
- window.addAuth = function(e) {
- if (!e) return void console.error("Error: No username provided. Usage: addAuth('username')");
- if (l.config.authorizedUsers.includes(e)) return void console.error(`Error: ${e} already has authority`);
- l.config.authorizedUsers.push(e);
- o.save("authorizedUsers", l.config.authorizedUsers);
- var s = l.config.bannedUsers.indexOf(e);
- -1 !== s && (l.config.bannedUsers.splice(s, 1), o.save("bannedUsers", l.config.bannedUsers));
- console.log(`[AUTH+] ${e} has been added to the authority list`);
- console.log("Authorized users: " + l.config.authorizedUsers.join(", "));
- };
- window.stopBot = async function() {
- console.log("Initiating shutdown sequence...");
- l.state.isShuttingDown = !0; l.state.isTyping = !1; l.state.countdownActive = !1; l.state.clearingArea = !1;
- l.sendMessage("Closing bot..");
- await new Promise(e => setTimeout(e, 500));
- l.running = !1;
- l.state.activeTimers.forEach(e => { clearTimeout(e.timeout); e.intervalId && clearInterval(e.intervalId); });
- l.state.activeCounts.forEach(e => { e.intervalId && clearInterval(e.intervalId); });
- for (var [e, s] of Object.entries(l.eventHandlers)) w && w.off && w.off(e, s);
- l.sendMessage("Bot successfully shutdown.");
- await new Promise(e => setTimeout(e, 500));
- l.state.isProcessingQueue = !1; l.state.messageQueue = [];
- console.log("[OK] Bot stopped completely");
- };
- window.restartBot = async function() {
- console.log("Restarting bot...");
- await window.stopBot();
- await new Promise(e => setTimeout(e, 1e3));
- var e = new t(a);
- await e.init();
- window.diamondBot = e;
- console.log("[OK] Bot restarted");
- };
- window.botStatus = function() {
- console.table({
- Username: l.config.username, Version: l.config.version, Prefix: l.config.prefix,
- Wall: l.state.wall + "/" + l.state.subwall,
- Position: `(${l.config.position.x}, ${l.config.position.y})`,
- Color: l.config.color,
- Permissions: ["User", "Member", "Owner"][l.state.perms] || "Unknown",
- "Active Timers": l.state.activeTimers.size, "Active Counts": l.state.activeCounts.size,
- "Countdown Active": l.state.countdownActive ? "YES" : "NO",
- "Clearing Area": l.state.clearingArea ? "YES" : "NO",
- "Authorized Users": l.config.authorizedUsers.length,
- "Default Authorities": l.config.defaultAuthorities.length,
- "Banned Users": l.config.bannedUsers.length, "Banned IDs": l.config.bannedIds.length,
- "Height Safety": l.config.heightSafetyEnabled ? "ON" : "OFF",
- "Authority Echo": l.config.authorityEchoEnabled ? "ON" : "OFF",
- "Color Echo": l.config.echoColorEnabled ? "ON" : "OFF",
- "Is Typing": l.state.isTyping ? "YES" : "NO",
- "Queue Size": l.state.messageQueue.length
- });
- };
- window.showCommands = function() {
- for (var e in console.log("\n===================================="), console.log(` ALL BOT COMMANDS (v${a.version}) `), console.log("====================================\n"), h)
- console.log(`\nPAGE ${e}:`), console.log("-".repeat(50)), h[e].forEach(e => {
- var s = e.auth ? "[A]" : " ", t = ("\\" + e.cmd).padEnd(15);
- console.log(s + ` ${t} - ` + e.desc);
- });
- console.log("\n" + "=".repeat(50));
- console.log("[A] = Authority Required");
- console.log("Default Authorities: " + l.config.defaultAuthorities.join(", "));
- console.log("Admins (ADMIN tag) have automatic authority");
- console.log("\nCONSOLE COMMANDS:");
- console.log(" addDefaultAuth('username') - Add default authority");
- console.log(" addAuth('username') - Add authority");
- console.log(" unbanName('username') - Unban user from ban list");
- console.log("=".repeat(50) + "\n");
- };
- window.showColors = function() {
- console.log("\n====================================");
- console.log(" COLOR SYNTAX GUIDE (v7.14.4) ");
- console.log("====================================\n");
- console.log("Use: <start #HEXCOLOR>text<end>");
- console.log("Example: <start #ff0000>Hello<end> World\n");
- console.log("Available colors (HEX only):");
- console.log("-".repeat(50));
- console.log(" 0 - #000000 (black)");
- console.log(" 1 - #ffffff (white)");
- console.log(" 2 - #ff0000 (red)");
- console.log(" 3 - #00ff00 (green)");
- console.log(" 4 - #0000ff (blue)");
- console.log(" 5 - #ffff00 (yellow)");
- console.log(" 6 - #ff00ff (magenta)");
- console.log(" 7 - #00ffff (cyan)");
- console.log(" 8 - #808080 (gray)");
- console.log(" 9 - #ff8800 (orange)");
- console.log(" 10 - #8800ff (purple)");
- console.log(" 11 - #0088ff (light blue)");
- console.log(" 12 - #88ff00 (lime)");
- console.log(" 13 - #ff0088 (pink)");
- console.log(" 14 - #884400 (brown)");
- console.log(" 15 - #448800 (dark green)");
- console.log("=".repeat(50) + "\n");
- };
- window.botHelp = function() {
- console.log("====================================");
- console.log(` TextWall Bot v${a.version} - Help `);
- console.log("====================================");
- console.log(" PREFIX: \\ ");
- console.log(" ");
- console.log(" NEW IN v7.14.4: ");
- console.log(" - \\rate command (random rating) ");
- console.log(" - addDefaultAuth() console cmd ");
- console.log(" - addAuth() console cmd ");
- console.log(" - Invisible char in help display ");
- console.log(" ");
- console.log(" CONSOLE COMMANDS: ");
- console.log(" window.showCommands() - List cmds ");
- console.log(" window.showColors() - Color list");
- console.log(" window.sendMessage(msg) - System ");
- console.log(" window.addDefaultAuth(n) - DefAuth");
- console.log(" window.addAuth(name) - Add auth ");
- console.log(" window.unbanName(name) - Unban ");
- console.log(" window.stopBot() - Stop bot ");
- console.log(" window.restartBot() - Restart ");
- console.log(" window.botStatus() - Status ");
- console.log(" window.botHelp() - This help ");
- console.log("====================================");
- };
- window.botHelp();
- }
- }();
Advertisement
Comments
-
- I love the update to the \cleararea command, would it be possible to make a \protectarea commmand that would protect text only and skip spaces like the \cleararea command does, if possible when the tw.2s4.me v.3.0 update happens?
Add Comment
Please, Sign In to add comment