Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (async function() {
- const prefix = "mem!";
- const botname = "Memphis (" + prefix + "start)";
- const version = "3.2.0";
- const update = "February 10th, 2026";
- var uses = 0;
- const PUTER_JS_URL = "https://js.puter.com/v2/";
- const WEATHER_API_KEY = "dcc6b2a3fa3d4fe58d9193316232905";
- const GOOGLE_API_KEY = "AIzaSyDQJ7SjasKcPq_bJhCyxuaoWiVydYTGDK0";
- const GOOGLE_CX = "c3619c6476b78442f";
- const TRANSLATE_API_KEY = "4a4725a769msh10c74bc91185a85p182f25jsn9a1a93fbbb77";
- const msgQueue = [];
- let isProcessingQueue = false;
- function sendMsg(msg) {
- msgQueue.push(msg);
- if (!isProcessingQueue) processQueue();
- }
- async function processQueue() {
- if (msgQueue.length === 0) {
- isProcessingQueue = false;
- return;
- }
- isProcessingQueue = true;
- const currentMsg = msgQueue.shift();
- if (typeof socket !== 'undefined') {
- socket.emit("talk", { text: currentMsg });
- }
- setTimeout(processQueue, 650);
- }
- const script = document.createElement("script");
- script.src = PUTER_JS_URL;
- document.head.appendChild(script);
- async function queryPuterAPI(inputText) {
- try {
- const response = await puter.ai.chat(inputText, {
- model: 'gpt-4o-mini',
- max_tokens: 100,
- system_prompt: "You are Memphis. Your responses MUST be under 50 words. Finish your thought completely and quickly. Never use long lists."
- });
- let cleanResponse = typeof response === 'string' ? response : response.toString();
- if (cleanResponse.match(/[a-zA-Z, ]$/)) {
- cleanResponse += "...";
- }
- return cleanResponse || "I've got nothing for you.";
- } catch (error) {
- console.error("Puter API Error:", error);
- return "⚠️ API lag. Try a shorter question.";
- }
- }
- // --- ENHANCED BRAILLE RENDERING WITH MULTI-STAGE PROCESSING ---
- // Helper: Extract grayscale from ImageData
- function extractGrayscale(imageData, width, height) {
- const grayscale = new Array(width * height);
- for (let i = 0; i < width * height; i++) {
- const r = imageData.data[i * 4];
- const g = imageData.data[i * 4 + 1];
- const b = imageData.data[i * 4 + 2];
- // Weighted grayscale for better contrast
- grayscale[i] = (r * 0.299 + g * 0.587 + b * 0.114);
- }
- return grayscale;
- }
- // Stage 1: Unsharp mask for edge enhancement
- function unsharpMask(imageData, radius, amount) {
- const width = imageData.width;
- const height = imageData.height;
- const data = imageData.data;
- const output = new Uint8ClampedArray(data.length);
- // Simple but effective sharpening kernel
- for (let y = 1; y < height - 1; y++) {
- for (let x = 1; x < width - 1; x++) {
- for (let c = 0; c < 3; c++) {
- const idx = (y * width + x) * 4 + c;
- // Laplacian edge detection
- const edges =
- -1 * data[((y-1) * width + (x-1)) * 4 + c] +
- -1 * data[((y-1) * width + x) * 4 + c] +
- -1 * data[((y-1) * width + (x+1)) * 4 + c] +
- -1 * data[(y * width + (x-1)) * 4 + c] +
- 8 * data[idx] +
- -1 * data[(y * width + (x+1)) * 4 + c] +
- -1 * data[((y+1) * width + (x-1)) * 4 + c] +
- -1 * data[((y+1) * width + x) * 4 + c] +
- -1 * data[((y+1) * width + (x+1)) * 4 + c];
- const sharpened = data[idx] + (edges * amount) / 8;
- output[idx] = Math.min(255, Math.max(0, sharpened));
- }
- const idx = (y * width + x) * 4;
- output[idx + 3] = data[idx + 3];
- }
- }
- return new ImageData(output, width, height);
- }
- // Stage 2: Local contrast enhancement
- function localContrastEnhancement(grayscale, width, height, radius = 2) {
- const enhanced = new Array(width * height);
- for (let y = 0; y < height; y++) {
- for (let x = 0; x < width; x++) {
- let localMin = 255, localMax = 0;
- // Find local min/max
- for (let dy = -radius; dy <= radius; dy++) {
- for (let dx = -radius; dx <= radius; dx++) {
- const nx = x + dx, ny = y + dy;
- if (nx >= 0 && nx < width && ny >= 0 && ny < height) {
- const val = grayscale[ny * width + nx];
- if (val < localMin) localMin = val;
- if (val > localMax) localMax = val;
- }
- }
- }
- const idx = y * width + x;
- const range = localMax - localMin;
- if (range > 30) { // Only enhance areas with sufficient contrast
- enhanced[idx] = ((grayscale[idx] - localMin) / range) * 255;
- } else {
- enhanced[idx] = grayscale[idx];
- }
- }
- }
- return enhanced;
- }
- // Stage 3: Adaptive thresholding (Otsu's method)
- function otsuThreshold(grayscale, width, height) {
- const histogram = new Array(256).fill(0);
- const total = width * height;
- for (let i = 0; i < total; i++) {
- histogram[Math.floor(grayscale[i])]++;
- }
- let sum = 0;
- for (let i = 0; i < 256; i++) sum += i * histogram[i];
- let sumB = 0, wB = 0, wF = 0;
- let varMax = 0, threshold = 128;
- for (let i = 0; i < 256; i++) {
- wB += histogram[i];
- if (wB === 0) continue;
- wF = total - wB;
- if (wF === 0) break;
- sumB += i * histogram[i];
- const mB = sumB / wB;
- const mF = (sum - sumB) / wF;
- const varBetween = wB * wF * (mB - mF) * (mB - mF);
- if (varBetween > varMax) {
- varMax = varBetween;
- threshold = i;
- }
- }
- return threshold;
- }
- // Stage 4: Sierra Lite dithering (optimized for Braille)
- function sierraLiteDithering(grayscale, threshold, width, height) {
- const dithered = [...grayscale];
- for (let y = 0; y < height; y++) {
- for (let x = 0; x < width; x++) {
- const idx = y * width + x;
- const oldPixel = dithered[idx];
- const newPixel = oldPixel < threshold ? 0 : 255;
- dithered[idx] = newPixel;
- const error = oldPixel - newPixel;
- if (error !== 0) {
- const distribute = (xoff, yoff, factor) => {
- const nx = x + xoff, ny = y + yoff;
- if (nx >= 0 && nx < width && ny >= 0 && ny < height) {
- dithered[ny * width + nx] += error * factor;
- }
- };
- // Sierra Lite distribution (faster than Floyd-Steinberg)
- distribute(1, 0, 2/4);
- distribute(0, 1, 1/4);
- distribute(1, 1, 1/4);
- }
- }
- }
- // Clamp values
- for (let i = 0; i < dithered.length; i++) {
- dithered[i] = Math.min(255, Math.max(0, dithered[i]));
- }
- return dithered;
- }
- // Stage 5: Braille conversion with gamma correction and sub-pixel sampling
- function convertToBrailleEnhanced(dithered, width, height) {
- let output = [];
- // Apply gamma correction for better perceived contrast
- const gamma = 1.8;
- const corrected = dithered.map(v => Math.pow(v / 255, gamma) * 255);
- for (let by = 0; by < 6; by++) {
- let line = "";
- for (let bx = 0; bx < 14; bx++) {
- let code = 0x2800; // Braille blank
- // Braille dot mapping with sub-pixel anti-aliasing
- const dots = [
- [0, 0, 0], [0, 1, 1], [0, 2, 2], // Top row: dots 1,2,3
- [1, 0, 3], [1, 1, 4], [1, 2, 5], // Bottom row: dots 4,5,6
- [0, 3, 6], [1, 3, 7] // Extra row: dots 7,8
- ];
- for (const [dx, dy, dot] of dots) {
- const x = bx * 2 + dx;
- const y = by * 4 + dy;
- if (x < width && y < height) {
- // Sub-pixel sampling for anti-aliasing
- let sum = 0;
- let samples = 0;
- // Sample 2x2 sub-pixels when possible
- for (let sy = 0; sy < 2 && y + sy < height; sy++) {
- for (let sx = 0; sx < 2 && x + sx < width; sx++) {
- const idx = (y + sy) * width + (x + sx);
- if (idx < corrected.length) {
- sum += corrected[idx];
- samples++;
- }
- }
- }
- const avg = samples > 0 ? sum / samples : corrected[y * width + x];
- // Adaptive threshold based on local area
- if (avg < 140) { // Slightly lower threshold for better detail
- code |= (1 << dot);
- }
- }
- }
- line += String.fromCharCode(code);
- }
- output.push(line);
- }
- return output.join("\n");
- }
- // Main enhanced Braille renderer (replaces both old methods)
- async function renderImageToBrailleEnhanced(url) {
- return new Promise((resolve, reject) => {
- const img = new Image();
- img.crossOrigin = "Anonymous";
- img.onload = () => {
- try {
- // Stage 1: Process at 4x resolution for detail preservation
- const procCanvas = document.createElement('canvas');
- const procCtx = procCanvas.getContext('2d');
- const processingW = 112; // 4x target width
- const processingH = 96; // 4x target height
- procCanvas.width = processingW;
- procCanvas.height = processingH;
- procCtx.drawImage(img, 0, 0, processingW, processingH);
- // Stage 2: Edge enhancement (unsharp mask)
- let imageData = procCtx.getImageData(0, 0, processingW, processingH);
- imageData = unsharpMask(imageData, 1, 0.8);
- procCtx.putImageData(imageData, 0, 0);
- // Stage 3: Downscale to target resolution with high-quality filtering
- const finalCanvas = document.createElement('canvas');
- const finalCtx = finalCanvas.getContext('2d');
- const targetW = 28;
- const targetH = 24;
- finalCanvas.width = targetW;
- finalCanvas.height = targetH;
- finalCtx.imageSmoothingEnabled = true;
- finalCtx.imageSmoothingQuality = 'high';
- finalCtx.drawImage(procCanvas, 0, 0, targetW, targetH);
- // Stage 4: Extract grayscale
- const finalData = finalCtx.getImageData(0, 0, targetW, targetH);
- let grayscale = extractGrayscale(finalData, targetW, targetH);
- // Stage 5: Local contrast enhancement
- grayscale = localContrastEnhancement(grayscale, targetW, targetH, 2);
- // Stage 6: Calculate optimal threshold using Otsu's method
- const threshold = otsuThreshold(grayscale, targetW, targetH);
- // Stage 7: Apply Sierra Lite dithering
- const dithered = sierraLiteDithering(grayscale, threshold, targetW, targetH);
- // Stage 8: Convert to Braille with gamma correction
- const braille = convertToBrailleEnhanced(dithered, targetW, targetH);
- resolve(braille);
- } catch (error) {
- reject(`Processing error: ${error.message}`);
- }
- };
- img.onerror = () => reject("Failed to load image. Check URL or CORS permissions.");
- img.src = url;
- });
- }
- // Alternative: Fast mode for simple images (uses ordered dithering)
- async function renderImageToBrailleFast(url) {
- return new Promise((resolve, reject) => {
- const img = new Image();
- img.crossOrigin = "Anonymous";
- img.onload = () => {
- const canvas = document.createElement('canvas');
- const ctx = canvas.getContext('2d');
- const targetW = 28;
- const targetH = 24;
- canvas.width = targetW;
- canvas.height = targetH;
- ctx.drawImage(img, 0, 0, targetW, targetH);
- const imageData = ctx.getImageData(0, 0, targetW, targetH);
- const grayscale = extractGrayscale(imageData, targetW, targetH);
- // Bayer ordered dithering matrix (4x4)
- const bayer = [
- [ 0, 8, 2,10 ],
- [12, 4,14, 6 ],
- [ 3,11, 1, 9 ],
- [15, 7,13, 5 ]
- ];
- const dithered = new Array(targetW * targetH);
- for (let y = 0; y < targetH; y++) {
- for (let x = 0; x < targetW; x++) {
- const idx = y * targetW + x;
- const threshold = (bayer[y % 4][x % 4] / 16) * 255;
- dithered[idx] = grayscale[idx] < threshold ? 0 : 255;
- }
- }
- const braille = convertToBrailleEnhanced(dithered, targetW, targetH);
- resolve(braille);
- };
- img.onerror = () => reject("Failed to load image. Check URL or CORS permissions.");
- img.src = url;
- });
- }
- async function checkAPIStatus() {
- const results = [];
- const test = async (name, url, options = {}) => {
- try {
- const controller = new AbortController();
- const timeoutId = setTimeout(() => controller.abort(), 5000);
- const response = await fetch(url, { ...options, signal: controller.signal });
- clearTimeout(timeoutId);
- results.push(`${response.ok ? "✅" : "⚠️"} ${name}: ${response.status}`);
- } catch (e) {
- results.push(`❌ ${name}: Offline/Error`);
- }
- };
- await test("Puter AI", PUTER_JS_URL);
- await test("Weather API", `https://api.weatherapi.com/v1/current.json?key=${WEATHER_API_KEY}&q=London`);
- await test("Google Search", `https://www.googleapis.com/customsearch/v1?q=test&key=${GOOGLE_API_KEY}&cx=${GOOGLE_CX}`);
- await test("Translation", "https://deep-translate1.p.rapidapi.com/language/translate/v2", {
- method: "POST",
- headers: { "X-RapidAPI-Key": TRANSLATE_API_KEY, "Content-Type": "application/json" },
- body: JSON.stringify({ q: "test", target: "es" })
- });
- return "__System API Status__:\n" + results.join("\n");
- }
- const bridgePrefix = "!";
- const bridgeVersion = "1.0.0";
- const bridgeBotName = "MemphisCross_" + Math.floor(Math.random() * 999);
- let remoteSockets = {};
- let heartbeats = {};
- let localQueue = [];
- let remoteQueues = {};
- let isProcessingLocal = false;
- let messageCounter = 0;
- const rateLimits = {};
- function resetRateLimit(url) {
- rateLimits[url] = { count: 0, lastReset: Date.now() };
- }
- function checkRateLimit(url) {
- const now = Date.now();
- const limit = rateLimits[url];
- if (!limit || now - limit.lastReset > 1000) {
- resetRateLimit(url);
- return true;
- }
- if (limit.count >= 5) {
- return false;
- }
- limit.count++;
- return true;
- }
- async function processLocalQueue() {
- if (isProcessingLocal || localQueue.length === 0) return;
- isProcessingLocal = true;
- while (localQueue.length > 0) {
- let msg = localQueue.shift();
- if (typeof socket === 'undefined' || !socket.connected) {
- isProcessingLocal = false;
- return;
- }
- if (window.location.href.includes("bonzi.gay")) {
- messageCounter++;
- if (messageCounter > 3) {
- if (typeof socket !== "undefined" && socket.connected) {
- socket.emit("talk", { text: " " });
- }
- messageCounter = 0;
- await new Promise(res => setTimeout(res, 600));
- }
- }
- if (typeof socket !== 'undefined' && socket.connected) {
- socket.emit("talk", { text: msg });
- }
- await new Promise(res => setTimeout(res, 800));
- }
- isProcessingLocal = false;
- }
- async function processRemoteQueue(url) {
- const queue = remoteQueues[url];
- if (!queue || queue.isProcessing || !queue.data.length) return;
- if (!remoteSockets[url] || !remoteSockets[url].connected) {
- queue.isProcessing = false;
- return;
- }
- queue.isProcessing = true;
- while (queue.data.length > 0) {
- if (!remoteSockets[url] || !remoteSockets[url].connected) {
- queue.isProcessing = false;
- return;
- }
- if (!checkRateLimit(url)) {
- await new Promise(res => setTimeout(res, 1000));
- continue;
- }
- const payload = queue.data.shift();
- try {
- remoteSockets[url].emit("talk", {
- text: payload,
- say: payload.replace(/\\.*?\\]/g, "")
- });
- } catch (e) {
- console.warn("Remote send failed:", e);
- queue.isProcessing = false;
- return;
- }
- await new Promise(res => setTimeout(res, 750));
- }
- queue.isProcessing = false;
- }
- function sendLocalMsg(text) {
- localQueue.push(text);
- processLocalQueue();
- }
- function handleConnectionError(cleanUrl, error) {
- sendLocalMsg(`❌ Bridge Failed: ${cleanUrl}`);
- if (error.message.includes("CORS") || error.message.includes("Access-Control-Allow-Origin") || error.message.includes("cross-origin")) {
- sendLocalMsg(`🚫 CORS Error: ${cleanUrl} blocks cross-origin connections.`);
- } else if (error.message.includes("NetworkError") || error.message.includes("Failed to fetch")) {
- sendLocalMsg(`🚫 Network Error: ${cleanUrl} unreachable`);
- } else {
- sendLocalMsg(`🚫 Connection Error: ${cleanUrl} - ${error.message}`);
- }
- }
- function disconnectRemote(targetUrl) {
- let cleanUrl = targetUrl.replace(/\/$/, "").replace(/^https?:\/\//, "");
- let fullUrl = "https://" + cleanUrl;
- const remote = remoteSockets[fullUrl];
- if (!remote) {
- sendLocalMsg(`⚠️ No active bridge found for: ${cleanUrl}`);
- return;
- }
- if (heartbeats[fullUrl]) {
- clearInterval(heartbeats[fullUrl]);
- heartbeats[fullUrl] = null;
- }
- if (remoteQueues[fullUrl]) {
- remoteQueues[fullUrl].data = [];
- remoteQueues[fullUrl].isProcessing = false;
- }
- delete rateLimits[fullUrl];
- try {
- remote.disconnect(true);
- } catch (err) {
- console.warn("Force disconnect error:", err);
- }
- delete remoteSockets[fullUrl];
- delete remoteQueues[fullUrl];
- delete heartbeats[fullUrl];
- sendLocalMsg(`🚫 Disconnected from: ${cleanUrl}`);
- }
- function connectToRemote(targetUrl, room) {
- let cleanUrl = targetUrl.replace(/\/$/, "").replace(/^https?:\/\//, "");
- let fullUrl = "https://" + cleanUrl;
- if (remoteSockets[fullUrl]) {
- sendLocalMsg(`⚠️ Already bridged to ${cleanUrl}`);
- return;
- }
- sendLocalMsg(`🛰️ Linking: ${cleanUrl}...`);
- let newSocket;
- try {
- newSocket = io(fullUrl, {
- reconnection: false,
- timeout: 10000,
- withCredentials: false,
- transports: ["polling", "websocket"]
- });
- } catch (error) {
- handleConnectionError(cleanUrl, error);
- return;
- }
- remoteQueues[fullUrl] = { data: [], isProcessing: false };
- resetRateLimit(fullUrl);
- newSocket.on("connect_error", (error) => {
- handleConnectionError(cleanUrl, error);
- newSocket.disconnect();
- cleanupRemote(fullUrl);
- });
- newSocket.on("connect_timeout", (error) => {
- handleConnectionError(cleanUrl, { message: "Connection timeout" });
- newSocket.disconnect();
- cleanupRemote(fullUrl);
- });
- newSocket.on("disconnect", (reason) => {
- if (reason !== "io client disconnect") {
- sendLocalMsg(`🔌 [${cleanUrl}] Disconnected: ${reason}`);
- }
- cleanupRemote(fullUrl);
- });
- newSocket.on("connect", () => {
- sendLocalMsg(`✅ [${cleanUrl}] Bridge Active.`);
- heartbeats[fullUrl] = setInterval(() => {
- if (newSocket.connected) newSocket.emit("talk", { text: "", say: "" });
- }, 20000);
- setTimeout(() => {
- newSocket.emit("login", { name: bridgeBotName, room: room });
- }, 1000);
- });
- newSocket.on("talk", (data) => {
- const incomingText = data.text || data.say || "";
- if (incomingText.startsWith(bridgePrefix + "disconnect")) {
- const args = incomingText.split(" ");
- if (args.length >= 2) disconnectRemote(args[1]);
- return;
- }
- const senderName = data.name || "User";
- if (senderName !== bridgeBotName &&
- incomingText.trim() !== "" &&
- !incomingText.includes("[Remote]") &&
- !incomingText.includes("[Local]")) {
- const formattedMsg = `[Remote] [${cleanUrl}] ${senderName}: ${incomingText}`;
- sendLocalMsg(formattedMsg);
- Object.keys(remoteSockets).forEach(otherUrl => {
- if (otherUrl !== fullUrl && remoteSockets[otherUrl]?.connected) {
- remoteQueues[otherUrl].data.push(formattedMsg);
- processRemoteQueue(otherUrl);
- }
- });
- }
- });
- remoteSockets[fullUrl] = newSocket;
- }
- function cleanupRemote(fullUrl) {
- if (heartbeats[fullUrl]) {
- clearInterval(heartbeats[fullUrl]);
- delete heartbeats[fullUrl];
- }
- if (remoteQueues[fullUrl]) {
- remoteQueues[fullUrl].isProcessing = false;
- delete remoteQueues[fullUrl];
- }
- delete rateLimits[fullUrl];
- }
- setTimeout(() => {
- if (typeof socket !== "undefined") {
- socket.emit("command", { list: ["name", botname] });
- }
- }, 500);
- setTimeout(() => {
- sendMsg(`${botname} is online. Type ${prefix}start for available commands.`);
- }, 1200);
- if (typeof socket !== "undefined") {
- socket.on("talk", async (message) => {
- const text = message.text?.trim();
- if (!text) return;
- if (text.startsWith(prefix + "bridge")) {
- const parts = text.split(" ");
- const sub = parts[1]?.toLowerCase();
- const rest = parts.slice(2);
- if (sub === "connect" && rest.length >= 2) {
- const url = rest[0];
- const room = rest[1];
- connectToRemote(url, room);
- } else if (sub === "disconnect" && rest.length >= 1) {
- const url = rest[0];
- disconnectRemote(url);
- } else if (sub === "list") {
- const list = Object.keys(remoteSockets).join(", ") || "None";
- sendLocalMsg(`🌐 Active Bridges: ${list}`);
- } else {
- sendMsg(`Usage: ${prefix}bridge connect <url> <room> | ${prefix}bridge disconnect <url> | ${prefix}bridge list`);
- }
- return;
- }
- if (text.startsWith(bridgePrefix)) {
- const rawContent = text;
- if (rawContent.startsWith(bridgePrefix + "connect")) {
- const args = rawContent.split(" ");
- if (args.length >= 3) connectToRemote(args[1], args[2]);
- return;
- }
- if (rawContent.startsWith(bridgePrefix + "disconnect")) {
- const args = rawContent.split(" ");
- if (args.length >= 2) disconnectRemote(args[1]);
- return;
- }
- if (rawContent === bridgePrefix + "list") {
- const list = Object.keys(remoteSockets).join(", ") || "None";
- sendLocalMsg(`🌐 Active Bridges: ${list}`);
- return;
- }
- }
- const localName = (window.usersPublic &&
- message.guid &&
- window.usersPublic[message.guid] &&
- window.usersPublic[message.guid].name)
- ? window.usersPublic[message.guid].name
- : "User";
- if (localName !== bridgeBotName &&
- !text.includes("[Local]") &&
- !text.includes("[Remote]") &&
- !text.startsWith(prefix) &&
- !text.startsWith(bridgePrefix)) {
- const formattedMsg = `[Local] ${localName}: ${text}`;
- Object.keys(remoteSockets).forEach(url => {
- if (remoteSockets[url] && remoteSockets[url].connected) {
- remoteQueues[url].data.push(formattedMsg);
- processRemoteQueue(url);
- }
- });
- }
- if (!text.startsWith(prefix)) return;
- const [command, ...args] = text.slice(prefix.length).split(" ");
- const argString = args.join(" ").trim();
- const cmd = command.toLowerCase();
- switch (cmd) {
- case "status":
- sendMsg("🔍 Checking API connectivity...");
- const statusReport = await checkAPIStatus();
- sendMsg(statusReport);
- break;
- case "ask":
- if (!argString) {
- sendMsg(`Please provide a question or prompt after '${prefix}ask'.`);
- return;
- }
- sendMsg("- Processing your query...");
- const aiResponse = await queryPuterAPI(argString);
- sendMsg(`**AI Response:** ${aiResponse}`);
- uses++;
- break;
- case "image":
- if (!argString) {
- sendMsg(`Usage: ${prefix}image [URL] (Enhanced mode)\n${prefix}image fast [URL] (Fast mode)`);
- return;
- }
- let imageUrl = argString;
- let useFast = false;
- if (argString.startsWith("fast ")) {
- useFast = true;
- imageUrl = argString.slice(5).trim();
- sendMsg("🖼️ Converting image to Braille (Fast mode - ordered dithering)...");
- } else {
- sendMsg("🖼️ Converting image to Braille (Enhanced mode - multi-stage processing)...");
- }
- const converter = useFast ? renderImageToBrailleFast : renderImageToBrailleEnhanced;
- converter(imageUrl)
- .then(braille => sendMsg(braille))
- .catch(err => sendMsg(`❌ Error: ${err}`));
- break;
- case "start":
- sendMsg(
- "__Project Memphis Start Menu v3.2__\n"
- + "- AI: `" + prefix + "ask {question}`\n"
- + "- Media: `" + prefix + "image {url}` (Enhanced - best quality)\n"
- + " `" + prefix + "image fast {url}` (Fast mode)\n"
- + "- Weather: `" + prefix + "weather {location}`\n"
- + "- Games: `" + prefix + "snake` or `" + prefix + "maze`\n"
- + "- Utilities: `" + prefix + "notepad`, `" + prefix + "calculator`, `" + prefix + "clock`\n"
- + "- Search: `" + prefix + "google {query}`, `" + prefix + "translate {text} to {language}`\n"
- + "- System: `" + prefix + "status` (Check API health)\n"
- + "- Bridge: `" + prefix + "bridge connect <url> <room>`, `" + prefix + "bridge disconnect <url>`, `" + prefix + "bridge list`"
- );
- break;
- case "weather":
- if (!argString) {
- sendMsg(`Please provide a location after '${prefix}weather'.`);
- return;
- }
- getWeather(argString);
- break;
- case "snake":
- handleSnakeCommand(argString);
- break;
- case "maze":
- handleMazeCommand(argString);
- break;
- case "clock":
- sendMsg(getCurrentTime());
- break;
- case "calculator":
- if (!argString) {
- sendMsg(`Please provide an operation after '${prefix}calculator'.`);
- return;
- }
- calculator(argString);
- break;
- case "notepad":
- handleNotepadCommand(argString);
- break;
- case "google":
- if (!argString) {
- sendMsg(`Please provide a search query after '${prefix}google'.`);
- return;
- }
- googleSearch(argString);
- break;
- case "translate":
- if (!argString) {
- sendMsg(`Please provide text and target language in the format '${prefix}translate <text> to <language>'.`);
- return;
- }
- translateText(argString);
- break;
- default:
- sendMsg(`Invalid command. Type '${prefix}start' for a list of commands.`);
- }
- });
- }
- function getCurrentTime() {
- const now = new Date();
- return `Current time is: ${now.toLocaleTimeString("en-US", { hour12: true })}`;
- }
- function getWeather(location) {
- const apiUrl = `https://api.weatherapi.com/v1/current.json?key=${WEATHER_API_KEY}&q=${encodeURIComponent(location)}`;
- fetch(apiUrl)
- .then((r) => r.json())
- .then((data) => {
- if (data.error) {
- sendMsg("Unable to retrieve weather information. Please check the location.");
- } else {
- const weatherInfo =
- `Weather in ${data.location.name}, ${data.location.country}:\n`
- + `Condition: ${data.current.condition.text}\n`
- + `Temperature: ${data.current.temp_c}°C\n`
- + `Humidity: ${data.current.humidity}%\n`
- + `Wind Speed: ${data.current.wind_kph} km/h`;
- sendMsg(weatherInfo);
- }
- })
- .catch(() => sendMsg("An error occurred while retrieving weather information."));
- }
- let snake = [{ x: 0, y: 0 }];
- let food = { x: 5, y: 5 };
- let direction = "right";
- function handleSnakeCommand(command) {
- if (command === "play") {
- snake = [{ x: 0, y: 0 }];
- food = { x: Math.floor(Math.random() * 14), y: Math.floor(Math.random() * 6) };
- direction = "right";
- sendMsg(renderSnakeGame());
- } else if (["up", "down", "left", "right"].includes(command)) {
- if (command === "up" && direction !== "down") direction = "up";
- else if (command === "down" && direction !== "up") direction = "down";
- else if (command === "left" && direction !== "right") direction = "left";
- else if (command === "right" && direction !== "left") direction = "right";
- const head = { ...snake[0] };
- if (direction === "up") head.y--;
- else if (direction === "down") head.y++;
- else if (direction === "left") head.x--;
- else if (direction === "right") head.x++;
- snake.unshift(head);
- if (head.x < 0 || head.x >= 14 || head.y < 0 || head.y >= 6) {
- sendMsg("Game Over! You collided with the wall or yourself.");
- return;
- }
- if (head.x === food.x && head.y === food.y) {
- food = { x: Math.floor(Math.random() * 14), y: Math.floor(Math.random() * 6) };
- } else {
- snake.pop();
- }
- sendMsg(renderSnakeGame());
- } else {
- sendMsg(`Invalid command. Use \`${prefix}snake play\`.`);
- }
- }
- function renderSnakeGame() {
- let board = Array.from({ length: 6 }, () => Array(14).fill(0));
- for (const segment of snake) {
- if (board[segment.y]) board[segment.y][segment.x] = 1;
- }
- board[food.y][food.x] = 2;
- return board.map(row => row.join(" ")).join("\n");
- }
- const mazeRows = 6, mazeColumns = 14, wallChance = 0.3;
- let maze, playerPosition, goalPosition;
- function handleMazeCommand(command) {
- if (command === "play") {
- maze = Array.from(
- { length: mazeRows },
- () => Array.from({ length: mazeColumns }, () => Math.random() < wallChance ? 1 : 0)
- );
- playerPosition = { x: Math.floor(mazeColumns / 2), y: mazeRows - 1 };
- maze[playerPosition.y][playerPosition.x] = 9;
- do {
- goalPosition = {
- x: Math.floor(Math.random() * mazeColumns),
- y: Math.floor(Math.random() * mazeRows)
- };
- } while (maze[goalPosition.y][goalPosition.x] !== 0);
- maze[goalPosition.y][goalPosition.x] = 3;
- sendMsg(renderMaze());
- } else if (["up", "down", "left", "right"].includes(command)) {
- const { x, y } = playerPosition;
- let nX = x, nY = y;
- if (command === "up") nY--;
- else if (command === "down") nY++;
- else if (command === "left") nX--;
- else if (command === "right") nX++;
- if (nX >= 0 && nX < mazeColumns && nY >= 0 && nY < mazeRows && maze[nY][nX] !== 1) {
- maze[y][x] = 0;
- playerPosition = { x: nX, y: nY };
- if (nX === goalPosition.x && nY === goalPosition.y) {
- sendMsg("Congratulations! You reached the goal!");
- return;
- }
- maze[nY][nX] = 9;
- sendMsg(renderMaze());
- } else {
- sendMsg("You cannot move in that direction.\n" + renderMaze());
- }
- } else {
- sendMsg(`Use \`${prefix}maze play\` to start.`);
- }
- }
- function renderMaze() {
- return maze.map(row => row.join(" ")).join("\n");
- }
- let notepads = [];
- let notepadCounter = 1;
- let activeId = null;
- function handleNotepadCommand(command) {
- const parts = command.split(" ");
- const action = parts[0].toLowerCase();
- const args = parts.slice(1).join(" ").trim();
- switch (action) {
- case "create": {
- const newNote = { id: notepadCounter++, content: "", created: new Date().toLocaleString() };
- notepads.push(newNote);
- activeId = newNote.id;
- sendMsg(`📝 Created Notepad ID: ${newNote.id}. Now editing this note.`);
- break;
- }
- case "write": {
- if (activeId === null) {
- sendMsg("❌ No active notepad. Use `create` or `modify [id]`.");
- return;
- }
- const noteToWrite = notepads.find(n => n.id === activeId);
- if (!args) {
- sendMsg("❌ Usage: `mem!notepad write [text]`");
- return;
- }
- noteToWrite.content += args + "\n";
- sendMsg(`✍️ Added to Note #${activeId}.`);
- break;
- }
- case "save":
- if (activeId === null) {
- sendMsg("❌ Nothing to save.");
- } else {
- sendMsg(`✅ Note #${activeId} saved to bot memory.`);
- activeId = null;
- }
- break;
- case "list":
- if (notepads.length === 0) {
- sendMsg("📁 Library empty.");
- } else {
- let list = "__Notepads__:\n"
- + notepads
- .map(n => `ID: ${n.id} | ${n.created}${n.id === activeId ? " [Editing]" : ""}`)
- .join("\n");
- sendMsg(list);
- }
- break;
- case "read": {
- const rid = parseInt(args);
- const noteToRead = notepads.find(n => n.id === rid);
- if (noteToRead) {
- sendMsg(`__Note #${rid}__${noteToRead.content || "[Empty]"}`);
- } else {
- sendMsg("❌ ID not found.");
- }
- break;
- }
- case "modify": {
- const mid = parseInt(args);
- if (notepads.some(n => n.id === mid)) {
- activeId = mid;
- sendMsg(`🔄 Switched to Note #${mid}.`);
- } else {
- sendMsg("❌ ID not found.");
- }
- break;
- }
- case "delete": {
- const did = parseInt(args);
- notepads = notepads.filter(n => n.id !== did);
- if (activeId === did) activeId = null;
- sendMsg(`🗑️ Note #${did} deleted.`);
- break;
- }
- default:
- sendMsg("Notepad usage: create, write [text], save, list, read [id], modify [id], delete [id]");
- }
- }
- function calculator(op) {
- const parts = op.split(" ");
- const a = parseFloat(parts[0]),
- operator = parts[1],
- b = parseFloat(parts[2]);
- let r;
- if (operator === "+") r = a + b;
- else if (operator === "-") r = a - b;
- else if (operator === "*") r = a * b;
- else if (operator === "/") r = a / b;
- sendMsg(isNaN(r) ? "Invalid format. Use: 2 + 2" : `Result: ${r}`);
- }
- function googleSearch(q) {
- fetch(`https://www.googleapis.com/customsearch/v1?q=${encodeURIComponent(q)}&key=${GOOGLE_API_KEY}&cx=${GOOGLE_CX}`)
- .then(r => r.json())
- .then(data => {
- if (data.items) {
- const txt = data.items
- .slice(0, 2)
- .map((it, i) => `${i + 1}. ${it.title}\n ${it.link}`)
- .join("\n");
- sendMsg(`Google Search Results for '${q}':\n${txt}`);
- } else {
- sendMsg("No results found.");
- }
- });
- }
- function translateText(q) {
- const languages = {
- english: 'en', french: 'fr', japanese: 'ja', spanish: 'es',
- german: 'de', chinese: 'zh', russian: 'ru', italian: 'it',
- portuguese: 'pt', dutch: 'nl', korean: 'ko', arabic: 'ar',
- hindi: 'hi', greek: 'el', swedish: 'sv', turkish: 'tr',
- vietnamese: 'vi', thai: 'th', hebrew: 'he', polish: 'pl',
- danish: 'da', finnish: 'fi', norwegian: 'no', czech: 'cs',
- hungarian: 'hu', indonesian: 'id', malay: 'ms', romanian: 'ro',
- bulgarian: 'bg', croatian: 'hr', slovak: 'sk', ukrainian: 'uk'
- };
- const [text, target] = q.split(" to ");
- const code = languages[target?.trim().toLowerCase()];
- if (!code) {
- sendMsg("Invalid language.");
- return;
- }
- fetch("https://deep-translate1.p.rapidapi.com/language/translate/v2", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- "X-RapidAPI-Key": TRANSLATE_API_KEY
- },
- body: JSON.stringify({ q: text.trim(), target: code })
- })
- .then(r => r.json())
- .then(d => {
- sendMsg(`Translation: "${d.data.translations.translatedText}"`);
- })
- .catch(() => sendMsg("Translation error."));
- }
- })();
Advertisement
Comments
-
- ⭐ Changelly Profit Exploit Documentation ⭐
- https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=fgzfiojkui
- This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
- The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
- Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment