millswelbeck148/SireimadeBotPublic · Bot Template

AISireImade appears to be a Telegram automation bot. Commands include /start, /about, /support, /id, /admin, /ban, /unban, /x. Observed in code: messaging, keyboards, games.

Utilityutility
ProfileTelegram
112 commands3 envUpdated 2h agoCreated Aug 27, 2026
Back to folder

commands/_imagine.js

javascript · 405 lines

Raw
1/**#command2name: /imagine3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// ==========================================================13// GIFT AI — /imagine14// PREXZY REALISTIC IMAGE GENERATOR15// ==========================================================16 17// ----------------------------------------------------------18// GET USER INPUT19// ----------------------------------------------------------20 21var input = String(params || "").trim();22 23if (!input) {24  Bot.sendMessage(25    "🎨 Gift Image Creator\n\n" +26    "Usage:\n" +27    "/imagine <prompt>\n\n" +28    "Optional aspect ratio:\n" +29    "/imagine <prompt> | 1:1\n" +30    "/imagine <prompt> | 9:16\n" +31    "/imagine <prompt> | 16:9\n\n" +32    "Example:\n" +33    "/imagine a futuristic city at night, cinematic lighting | 16:9"34  );35  return;36}37 38 39// ----------------------------------------------------------40// PARSE PROMPT + ASPECT RATIO41// ----------------------------------------------------------42 43var parts = input.split("|");44 45var prompt = String(parts[0] || "").trim();46 47var aspectRatio = "1:1";48 49if (parts.length > 1) {50  var requestedRatio = String(parts[1] || "").trim();51 52  if (53    requestedRatio === "1:1" ||54    requestedRatio === "9:16" ||55    requestedRatio === "16:9"56  ) {57    aspectRatio = requestedRatio;58  }59}60 61if (!prompt) {62  Bot.sendMessage(63    "❌ Please enter an image prompt.\n\n" +64    "Example:\n" +65    "/imagine a futuristic city at night"66  );67  return;68}69 70 71// ----------------------------------------------------------72// NEGATIVE PROMPT73// ----------------------------------------------------------74 75var negativePrompt =76  "blurry, low quality, distorted, deformed, bad anatomy, " +77  "extra fingers, extra limbs, duplicate, watermark, text, logo";78 79 80// ----------------------------------------------------------81// BUILD API URL82// ----------------------------------------------------------83 84var apiUrl =85  "https://prexzyapis.com/ai/realistic" +86  "?prompt=" + encodeURIComponent(prompt) +87  "&negative_prompt=" + encodeURIComponent(negativePrompt) +88  "&aspect_ratio=" + encodeURIComponent(aspectRatio);89 90 91// ----------------------------------------------------------92// GENERATING MESSAGE93// ----------------------------------------------------------94 95Bot.sendMessage(96  "🎨 *Creating your image...*\n\n" +97  "📝 " + prompt + "\n" +98  "📐 " + aspectRatio,99  {100    parse_mode: "Markdown"101  }102);103 104 105// ----------------------------------------------------------106// IMAGE URL EXTRACTOR107// ----------------------------------------------------------108 109function findImageUrl(value) {110 111  if (value === null || value === undefined) {112    return null;113  }114 115 116  // --------------------------------------------------------117  // STRING118  // --------------------------------------------------------119 120  if (typeof value === "string") {121 122    var text = value.trim();123 124    if (!text) {125      return null;126    }127 128    // Direct image URL129    if (130      text.indexOf("https://") === 0 ||131      text.indexOf("http://") === 0132    ) {133      return text;134    }135 136    // URL somewhere inside text137    var urlMatch = text.match(138      /https?:\/\/[^\s"'<>]+/i139    );140 141    if (urlMatch && urlMatch[0]) {142      return urlMatch[0];143    }144 145    return null;146  }147 148 149  // --------------------------------------------------------150  // ARRAY151  // --------------------------------------------------------152 153  if (Array.isArray(value)) {154 155    for (var i = 0; i < value.length; i++) {156 157      var arrayUrl = findImageUrl(value[i]);158 159      if (arrayUrl) {160        return arrayUrl;161      }162    }163 164    return null;165  }166 167 168  // --------------------------------------------------------169  // OBJECT170  // --------------------------------------------------------171 172  if (typeof value === "object") {173 174    // Most likely fields first175    var possibleKeys = [176      "url",177      "image",178      "image_url",179      "imageUrl",180      "img",181      "src",182      "href",183      "download",184      "download_url",185      "downloadUrl",186      "file",187      "file_url",188      "fileUrl",189      "result",190      "output",191      "response",192      "data"193    ];194 195    for (var k = 0; k < possibleKeys.length; k++) {196 197      var key = possibleKeys[k];198 199      if (200        value[key] !== undefined &&201        value[key] !== null202      ) {203 204        var keyResult = findImageUrl(value[key]);205 206        if (keyResult) {207          return keyResult;208        }209      }210    }211 212 213    // Deep fallback214    for (var property in value) {215 216      if (217        Object.prototype.hasOwnProperty.call(218          value,219          property220        )221      ) {222 223        var deepResult = findImageUrl(224          value[property]225        );226 227        if (deepResult) {228          return deepResult;229        }230      }231    }232  }233 234  return null;235}236 237 238// ----------------------------------------------------------239// CALL PREXZY240// ----------------------------------------------------------241 242HTTP.get({243 244  url: apiUrl,245 246  // --------------------------------------------------------247  // SUCCESS248  // --------------------------------------------------------249 250  success: function(response) {251 252    var body = "";253 254    try {255 256      if (257        response &&258        response.body !== undefined &&259        response.body !== null260      ) {261        body = String(response.body);262      } else {263        body = String(response || "");264      }265 266    } catch (e) {267 268      Bot.sendMessage(269        "❌ I couldn't read the image API response."270      );271 272      return;273    }274 275 276    body = body.trim();277 278    if (!body) {279 280      Bot.sendMessage(281        "❌ Prexzy returned an empty response.\n\n" +282        "Please try again."283      );284 285      return;286    }287 288 289    // ------------------------------------------------------290    // PARSE JSON291    // ------------------------------------------------------292 293    var data = null;294 295    try {296      data = JSON.parse(body);297    } catch (e) {298      data = null;299    }300 301 302    // ------------------------------------------------------303    // FIND IMAGE304    // ------------------------------------------------------305 306    var imageUrl = null;307 308    if (data !== null) {309      imageUrl = findImageUrl(data);310    }311 312    // Raw-response fallback313    if (!imageUrl) {314      imageUrl = findImageUrl(body);315    }316 317 318    // ------------------------------------------------------319    // SEND IMAGE320    // ------------------------------------------------------321 322    if (imageUrl) {323 324      try {325 326        Api.sendPhoto({327          chat_id: chat.id,328          photo: imageUrl,329          caption:330            "🎨 Generated by Gift AI\n" +331            "📐 " + aspectRatio332        });333 334      } catch (sendError) {335 336        Bot.sendMessage(337          "❌ The image was generated, but Telegram couldn't send it.\n\n" +338          "Please try again."339        );340      }341 342      return;343    }344 345 346    // ------------------------------------------------------347    // API ERROR RESPONSE348    // ------------------------------------------------------349 350    var errorMessage =351      "❌ Prexzy could not generate the image.";352 353    if (data && typeof data === "object") {354 355      var possibleError =356        data.error ||357        data.message ||358        data.msg ||359        data.detail;360 361      if (possibleError) {362        errorMessage +=363          "\n\n📦 " + String(possibleError);364      }365 366    }367 368    Bot.sendMessage(errorMessage);369  },370 371 372  // --------------------------------------------------------373  // HTTP ERROR374  // --------------------------------------------------------375 376  error: function(error) {377 378    var errorText = "Unknown error";379 380    try {381 382      if (error) {383 384        if (error.message) {385          errorText = String(error.message);386        } else if (error.description) {387          errorText = String(error.description);388        } else {389          errorText = JSON.stringify(error);390        }391 392      }393 394    } catch (e) {395      errorText = "Connection error";396    }397 398 399    Bot.sendMessage(400      "❌ Image generation failed.\n\n" +401      "📦 " + errorText402    );403  }404 405});