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/_anime.js

javascript · 1036 lines

Raw
1/**#command2name: /anime3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// ==========================================================13// 🎌 GIFT AI — /anime14// PREXZY ANIME SEARCH + DETAILS15//16// Usage:17// /anime One Piece18// /anime Naruto19// /anime Demon Slayer20//21// FEATURES:22// • Accurate anime matching23// • Exact anime ID extraction24// • Automatic detail lookup25// • Poster support26// • DIRECT REPLY to user's /anime message27// • Gift AI watermark28// ==========================================================29 30 31// ----------------------------------------------------------32// GET QUERY33// ----------------------------------------------------------34 35var text = String(message || "").trim();36 37var query = text38  .replace(/^\/anime(?:@\w+)?/i, "")39  .trim();40 41 42// ----------------------------------------------------------43// GET ORIGINAL MESSAGE ID44// ----------------------------------------------------------45 46var replyMessageId = null;47 48try {49 50  if (51    msg &&52    msg.message_id53  ) {54 55    replyMessageId =56      msg.message_id;57 58  } else if (59    update &&60    update.message &&61    update.message.message_id62  ) {63 64    replyMessageId =65      update.message.message_id;66 67  } else if (68    request &&69    request.message_id70  ) {71 72    replyMessageId =73      request.message_id;74  }75 76} catch (e) {77 78  replyMessageId = null;79}80 81 82// ----------------------------------------------------------83// SEND TEXT REPLY84// ----------------------------------------------------------85 86async function sendReply(text, parseMode) {87 88  var data = {89    text: text90  };91 92  if (parseMode) {93    data.parse_mode = parseMode;94  }95 96  if (replyMessageId) {97 98    data.reply_to_message_id =99      replyMessageId;100  }101 102  return await Api.sendMessage(data);103}104 105 106// ----------------------------------------------------------107// ESCAPE HTML108// ----------------------------------------------------------109 110function esc(value) {111 112  return String(113    value == null ? "" : value114  )115    .replace(/&/g, "&amp;")116    .replace(/</g, "&lt;")117    .replace(/>/g, "&gt;");118}119 120 121// ----------------------------------------------------------122// NORMALIZE123// ----------------------------------------------------------124 125function normalize(value) {126 127  return String(value || "")128    .toLowerCase()129    .replace(/&/g, " and ")130    .replace(/[^a-z0-9]+/g, " ")131    .replace(/\s+/g, " ")132    .trim();133}134 135 136// ----------------------------------------------------------137// CLEAN TITLE138// ----------------------------------------------------------139 140function cleanTitle(value) {141 142  return normalize(value)143    .replace(144      /\b(english|hindi|dub|dubbed|sub|subbed)\b/g,145      ""146    )147    .replace(/\s+/g, " ")148    .trim();149}150 151 152// ----------------------------------------------------------153// WORDS154// ----------------------------------------------------------155 156function getWords(value) {157 158  var clean =159    normalize(value);160 161  if (!clean) {162    return [];163  }164 165  return clean.split(" ");166}167 168 169// ----------------------------------------------------------170// NO QUERY171// ----------------------------------------------------------172 173if (!query) {174 175  await sendReply(176    "🎌 <b>Anime Search</b>\n\n" +177    "Enter an anime name.\n\n" +178    "Examples:\n" +179    "<code>/anime One Piece</code>\n" +180    "<code>/anime Naruto</code>\n" +181    "<code>/anime Demon Slayer</code>",182    "HTML"183  );184 185  return;186}187 188 189// ----------------------------------------------------------190// SEARCH191// ----------------------------------------------------------192 193try {194 195  var cleanQuery =196    cleanTitle(query);197 198 199  var searchUrl =200    "https://prexzyapis.com/anime/animekill-search?query=" +201    encodeURIComponent(query);202 203 204  var response =205    await HTTP.get(searchUrl);206 207 208  var json =209    response.data;210 211 212  // --------------------------------------------------------213  // PARSE JSON214  // --------------------------------------------------------215 216  if (typeof json === "string") {217 218    try {219 220      json =221        JSON.parse(json);222 223    } catch (e) {224 225      await sendReply(226        "⚠️ Prexzy returned an invalid search response.",227        "HTML"228      );229 230      return;231    }232  }233 234 235  // --------------------------------------------------------236  // PREXZY STRUCTURE237  //238  // json.data.data.animelist239  // --------------------------------------------------------240 241  var animeList = [];242 243 244  if (245    json &&246    json.data &&247    json.data.data &&248    Array.isArray(249      json.data.data.animelist250    )251  ) {252 253    animeList =254      json.data.data.animelist;255  }256 257 258  // --------------------------------------------------------259  // NO RESULTS260  // --------------------------------------------------------261 262  if (!animeList.length) {263 264    await sendReply(265      "🔎 <b>No anime found</b>\n\n" +266      "I couldn't find:\n" +267      "<code>" +268      esc(query) +269      "</code>",270      "HTML"271    );272 273    return;274  }275 276 277  // --------------------------------------------------------278  // MATCH VARIABLES279  // --------------------------------------------------------280 281  var exactTitle = null;282  var exactWeb = null;283  var exactSynonym = null;284 285  var bestAnime = null;286  var bestScore = -1;287 288 289  // --------------------------------------------------------290  // SEARCH RESULTS291  // --------------------------------------------------------292 293  for (294    var i = 0;295    i < animeList.length;296    i++297  ) {298 299    var item =300      animeList[i];301 302 303    if (!item) {304      continue;305    }306 307 308    var animeName =309      cleanTitle(item.name);310 311 312    var animeWebId =313      cleanTitle(item.anime_id_web);314 315 316    var synonyms =317      normalize(item.synonyms);318 319 320    var animeId =321      String(322        item.anime_id || ""323      ).trim();324 325 326    if (!animeId) {327      continue;328    }329 330 331    // ------------------------------------------------------332    // EXACT TITLE333    // ------------------------------------------------------334 335    if (336      animeName &&337      animeName === cleanQuery338    ) {339 340      exactTitle =341        item;342    }343 344 345    // ------------------------------------------------------346    // EXACT WEB TITLE347    // ------------------------------------------------------348 349    if (350      animeWebId &&351      animeWebId === cleanQuery352    ) {353 354      exactWeb =355        item;356    }357 358 359    // ------------------------------------------------------360    // EXACT SYNONYM361    // ------------------------------------------------------362 363    if (synonyms) {364 365      var synonymList =366        synonyms.split(",");367 368 369      for (370        var s = 0;371        s < synonymList.length;372        s++373      ) {374 375        if (376          cleanTitle(377            synonymList[s]378          ) === cleanQuery379        ) {380 381          exactSynonym =382            item;383 384          break;385        }386      }387    }388 389 390    // ------------------------------------------------------391    // SCORE392    // ------------------------------------------------------393 394    var score = 0;395 396 397    // Exact name398    if (399      animeName === cleanQuery400    ) {401 402      score += 1000;403    }404 405 406    // Exact web ID407    if (408      animeWebId === cleanQuery409    ) {410 411      score += 900;412    }413 414 415    // Name contains complete query416    if (417      animeName.indexOf(cleanQuery) !== -1418    ) {419 420      score += 250;421    }422 423 424    // Web ID contains complete query425    if (426      animeWebId.indexOf(cleanQuery) !== -1427    ) {428 429      score += 200;430    }431 432 433    // ------------------------------------------------------434    // WORD MATCH435    // ------------------------------------------------------436 437    var qWords =438      getWords(cleanQuery);439 440 441    var nameWords =442      getWords(animeName);443 444 445    var matched = 0;446 447 448    for (449      var q = 0;450      q < qWords.length;451      q++452    ) {453 454      for (455        var n = 0;456        n < nameWords.length;457        n++458      ) {459 460        if (461          qWords[q] ===462          nameWords[n]463        ) {464 465          matched++;466          break;467        }468      }469    }470 471 472    if (qWords.length > 0) {473 474      score +=475        Math.round(476          (matched /477            qWords.length) * 300478        );479    }480 481 482    // ------------------------------------------------------483    // PREXZY MATCH SCORE484    // ------------------------------------------------------485 486    var matchScore =487      Number(488        item.match_score || 0489      );490 491 492    if (!isNaN(matchScore)) {493 494      score +=495        Math.min(496          matchScore,497          100498        );499    }500 501 502    // ------------------------------------------------------503    // KEEP BEST504    // ------------------------------------------------------505 506    if (507      score > bestScore508    ) {509 510      bestScore =511        score;512 513      bestAnime =514        item;515    }516  }517 518 519  // --------------------------------------------------------520  // EXACT MATCH PRIORITY521  // --------------------------------------------------------522 523  if (exactTitle) {524 525    bestAnime =526      exactTitle;527 528  } else if (exactWeb) {529 530    bestAnime =531      exactWeb;532 533  } else if (exactSynonym) {534 535    bestAnime =536      exactSynonym;537  }538 539 540  // --------------------------------------------------------541  // VERIFY542  // --------------------------------------------------------543 544  if (!bestAnime) {545 546    await sendReply(547      "🔎 <b>No accurate anime match found.</b>\n\n" +548      "Try the full anime title.",549      "HTML"550    );551 552    return;553  }554 555 556  var selectedName =557    cleanTitle(558      bestAnime.name559    );560 561 562  var selectedWeb =563    cleanTitle(564      bestAnime.anime_id_web565    );566 567 568  var selectedSynonyms =569    normalize(570      bestAnime.synonyms571    );572 573 574  var selectedId =575    String(576      bestAnime.anime_id || ""577    ).trim();578 579 580  // --------------------------------------------------------581  // STRICT MATCH582  // --------------------------------------------------------583 584  var qWords2 =585    getWords(cleanQuery);586 587 588  var selectedWords =589    getWords(selectedName);590 591 592  var matchedWords =593    0;594 595 596  for (597    var a = 0;598    a < qWords2.length;599    a++600  ) {601 602    for (603      var b = 0;604      b < selectedWords.length;605      b++606    ) {607 608      if (609        qWords2[a] ===610        selectedWords[b]611      ) {612 613        matchedWords++;614        break;615      }616    }617  }618 619 620  var ratio =621    qWords2.length622      ? matchedWords /623        qWords2.length624      : 0;625 626 627  var validMatch =628    selectedName === cleanQuery ||629    selectedWeb === cleanQuery ||630    selectedSynonyms.indexOf(cleanQuery) !== -1 ||631    ratio >= 0.75;632 633 634  // --------------------------------------------------------635  // NEVER RETURN RANDOM ANIME636  // --------------------------------------------------------637 638  if (639    !validMatch ||640    !selectedId641  ) {642 643    await sendReply(644      "🔎 <b>I couldn't confidently match that anime.</b>\n\n" +645      "Try the exact anime title:\n" +646      "<code>/anime One Piece</code>",647      "HTML"648    );649 650    return;651  }652 653 654  // --------------------------------------------------------655  // DETAIL API656  // --------------------------------------------------------657 658  var detailUrl =659    "https://prexzyapis.com/anime/animekill-detail?anime_id=" +660    encodeURIComponent(661      selectedId662    );663 664 665  var detailResponse =666    await HTTP.get(detailUrl);667 668 669  var detailJson =670    detailResponse.data;671 672 673  // --------------------------------------------------------674  // PARSE DETAIL JSON675  // --------------------------------------------------------676 677  if (678    typeof detailJson === "string"679  ) {680 681    try {682 683      detailJson =684        JSON.parse(detailJson);685 686    } catch (e) {687 688      await sendReply(689        "⚠️ Prexzy returned invalid anime details.",690        "HTML"691      );692 693      return;694    }695  }696 697 698  // --------------------------------------------------------699  // FIND DETAIL DATA700  // --------------------------------------------------------701 702  var info =703    detailJson;704 705 706  if (707    detailJson &&708    detailJson.data &&709    typeof detailJson.data === "object"710  ) {711 712    info =713      detailJson.data;714  }715 716 717  if (718    info &&719    info.data &&720    typeof info.data === "object"721  ) {722 723    info =724      info.data;725  }726 727 728  // --------------------------------------------------------729  // GET VALUE730  // --------------------------------------------------------731 732  function getValue(keys) {733 734    for (735      var x = 0;736      x < keys.length;737      x++738    ) {739 740      var key =741        keys[x];742 743 744      if (745        info &&746        info[key] !== undefined &&747        info[key] !== null &&748        info[key] !== ""749      ) {750 751        return info[key];752      }753    }754 755 756    return "";757  }758 759 760  // --------------------------------------------------------761  // DETAILS762  // --------------------------------------------------------763 764  var title =765    getValue([766      "name",767      "title",768      "anime_name",769      "anime_title"770    ]);771 772 773  var description =774    getValue([775      "description",776      "synopsis",777      "plot",778      "overview"779    ]);780 781 782  var genre =783    getValue([784      "genre",785      "genres"786    ]);787 788 789  var type =790    getValue([791      "anime_type",792      "type",793      "format"794    ]);795 796 797  var origin =798    getValue([799      "anime_origin",800      "origin"801    ]);802 803 804  var status =805    getValue([806      "status"807    ]);808 809 810  var episodes =811    getValue([812      "episodes",813      "episode",814      "total_episodes",815      "totalEpisodes"816    ]);817 818 819  var score =820    getValue([821      "score",822      "rating"823    ]);824 825 826  var poster =827    getValue([828      "large_poster",829      "small_poster",830      "poster",831      "image",832      "image_url"833    ]);834 835 836  // --------------------------------------------------------837  // SEARCH RESULT FALLBACKS838  // --------------------------------------------------------839 840  if (!title) {841    title = bestAnime.name;842  }843 844  if (!genre) {845    genre = bestAnime.genre;846  }847 848  if (!type) {849    type = bestAnime.anime_type;850  }851 852  if (!origin) {853    origin = bestAnime.anime_origin;854  }855 856  if (!score) {857    score = bestAnime.score;858  }859 860  if (!poster) {861    poster =862      bestAnime.large_poster ||863      bestAnime.small_poster;864  }865 866 867  // --------------------------------------------------------868  // FORMAT ARRAYS869  // --------------------------------------------------------870 871  if (Array.isArray(genre)) {872    genre = genre.join(", ");873  }874 875  if (Array.isArray(type)) {876    type = type.join(", ");877  }878 879 880  // --------------------------------------------------------881  // BUILD RESULT882  // --------------------------------------------------------883 884  var result =885    "🎌 <b>ANIME DETAILS</b>\n\n";886 887 888  if (title) {889 890    result +=891      "📺 <b>Title:</b> " +892      esc(title) +893      "\n";894  }895 896 897  if (type) {898 899    result +=900      "🎞️ <b>Type:</b> " +901      esc(type) +902      "\n";903  }904 905 906  if (status) {907 908    result +=909      "📌 <b>Status:</b> " +910      esc(status) +911      "\n";912  }913 914 915  if (episodes) {916 917    result +=918      "🎬 <b>Episodes:</b> " +919      esc(episodes) +920      "\n";921  }922 923 924  if (genre) {925 926    result +=927      "🏷️ <b>Genre:</b> " +928      esc(genre) +929      "\n";930  }931 932 933  if (origin) {934 935    result +=936      "🌍 <b>Origin:</b> " +937      esc(origin) +938      "\n";939  }940 941 942  if (score) {943 944    result +=945      "⭐ <b>Score:</b> " +946      esc(score) +947      "\n";948  }949 950 951  if (description) {952 953    result +=954      "\n📖 <b>Description:</b>\n" +955      esc(description) +956      "\n";957  }958 959 960  // --------------------------------------------------------961  // WATERMARK962  // --------------------------------------------------------963 964  result +=965    "\n━━━━━━━━━━━━━━━━━━\n" +966    "💗 <i>Powered by Gift AI herself</i>";967 968 969  // --------------------------------------------------------970  // SEND PHOTO AS A REPLY971  // --------------------------------------------------------972 973  if (974    poster &&975    /^https?:\/\//i.test(976      String(poster)977    )978  ) {979 980    try {981 982      var photoData = {983        photo:984          String(poster),985 986        caption:987          result,988 989        parse_mode:990          "HTML"991      };992 993 994      if (replyMessageId) {995 996        photoData.reply_to_message_id =997          replyMessageId;998      }999 1000 1001      await Api.sendPhoto(1002        photoData1003      );1004 1005      return;1006 1007    } catch (photoError) {1008 1009      // If poster fails, send text instead.1010    }1011  }1012 1013 1014  // --------------------------------------------------------1015  // SEND TEXT AS A REPLY1016  // --------------------------------------------------------1017 1018  await sendReply(1019    result,1020    "HTML"1021  );1022 1023}1024catch (error) {1025 1026  // --------------------------------------------------------1027  // SAFE ERROR MESSAGE1028  // --------------------------------------------------------1029 1030  await sendReply(1031    "⚠️ <b>Gift couldn't fetch that anime right now.</b>\n\n" +1032    "Please try again in a few seconds.",1033    "HTML"1034  );1035 1036  }