millswelbeck148/SireimadeBotPublic · Bot Template

ProfileTelegram

AIGift AI is a command‑based Telegram bot that offers a mix of moderation tools and light‑hearted features. It lets group admins ban, unban, and promote users by replying to messages, while also providing user‑ID lookup and a support link that enforces a forced‑join check. In addition, the bot includes simple games such as tic‑tac‑toe (commands /x and /o) and a Magic 8‑Ball (/8ball). The code uses the TeleBotHost TBL APIs (Bot, Api, db, etc.) and contains no long‑running listeners or external frameworks.

Moderationmoderationadminbanunbanpromoteuser-info
118 commands3 envUpdated 17d agoCreated Aug 27, 2026
Back to folder

commands/start_callback_handler.js

javascript · 413 lines

Raw
1/**#command2name: start_callback_handler3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// ==========================================================13// 💜 GIFT AI — MEMBERSHIP CALLBACK14// callback_data: "start"15// ==========================================================16 17 18// ==========================================================19// 🛡️ SAFETY CHECK20// ==========================================================21 22if (!user) {23  return;24}25 26 27// ==========================================================28// 📢 REQUIRED CHANNELS29// ==========================================================30 31var channel1 = "@Sire_mide";32var channel2 = "@me_himweds";33 34var joinLink1 = "https://t.me/Sire_mide";35var joinLink2 = "https://t.me/+Znlg3G0aNQcyZjVk";36 37 38// ==========================================================39// 👤 USER ID40// ==========================================================41 42var userId = String(43  user.telegramid || user.id || ""44).trim();45 46if (47  !userId ||48  !/^\d+$/.test(userId)49) {50  return;51}52 53 54// ==========================================================55// 🔍 CHECK MEMBERSHIP56// ==========================================================57 58var check1 = null;59var check2 = null;60 61 62// ----------------------------------------------------------63// CHANNEL 164// ----------------------------------------------------------65 66try {67 68  check1 = Api.call(69    "getChatMember",70    {71      chat_id: channel1,72      user_id: userId73    }74  );75 76} catch (e1) {77 78  check1 = null;79 80}81 82 83// ----------------------------------------------------------84// CHANNEL 285// ----------------------------------------------------------86 87try {88 89  check2 = Api.call(90    "getChatMember",91    {92      chat_id: channel2,93      user_id: userId94    }95  );96 97} catch (e2) {98 99  check2 = null;100 101}102 103 104// ==========================================================105// 👥 MEMBERSHIP FUNCTION106// ==========================================================107 108function isMember(result) {109 110  if (!result) {111    return false;112  }113 114 115  // TeleBotHost may return Telegram response116  // either directly or inside result.117 118  var member = null;119 120 121  // Standard Telegram response:122  // { ok: true, result: {...} }123 124  if (125    result.ok === true &&126    result.result127  ) {128 129    member = result.result;130 131  }132 133  // Direct ChatMember response134 135  else if (136    result.status137  ) {138 139    member = result;140 141  }142 143 144  if (!member) {145    return false;146  }147 148 149  var status =150    String(151      member.status || ""152    ).toLowerCase();153 154 155  // --------------------------------------------------------156  // MEMBER157  // --------------------------------------------------------158 159  if (160    status === "member"161  ) {162    return true;163  }164 165 166  // --------------------------------------------------------167  // ADMIN168  // --------------------------------------------------------169 170  if (171    status === "administrator"172  ) {173    return true;174  }175 176 177  // --------------------------------------------------------178  // OWNER179  // --------------------------------------------------------180 181  if (182    status === "creator"183  ) {184    return true;185  }186 187 188  // --------------------------------------------------------189  // RESTRICTED190  // --------------------------------------------------------191 192  if (193    status === "restricted" &&194    member.is_member === true195  ) {196    return true;197  }198 199 200  return false;201}202 203 204// ==========================================================205// ✅ RESULTS206// ==========================================================207 208var joined1 = isMember(check1);209var joined2 = isMember(check2);210 211 212// ==========================================================213// ❌ STILL NOT JOINED214// ==========================================================215 216if (217  !joined1 ||218  !joined2219) {220 221  var missing = "";222 223 224  if (!joined1) {225    missing += "🟣 <b>Channel 1</b>\n";226  }227 228 229  if (!joined2) {230    missing += "🌺 <b>Channel 2</b>\n";231  }232 233 234  Api.answerCallbackQuery({235    callback_query_id: request.id,236    text: "❌ You haven't joined all required channels yet.",237    show_alert: true238  });239 240 241  Api.sendMessage({242 243    chat_id: userId,244 245    text:246 247      "🔒 <b>ACCESS STILL LOCKED</b>\n\n" +248 249      "Gift checked your membership, but you're " +250      "still missing:\n\n" +251 252      missing +253 254      "\n👇 Join the missing channel(s), " +255      "then tap <b>CHECK MEMBERSHIP</b> again.",256 257    parse_mode: "HTML",258 259    reply_markup: {260 261      inline_keyboard: [262 263        [264          {265            text: "💜 JOIN CHANNEL 1",266            url: joinLink1267          }268        ],269 270        [271          {272            text: "🌺 JOIN CHANNEL 2",273            url: joinLink2274          }275        ],276 277        [278          {279            text: "🔄 CHECK MEMBERSHIP",280            callback_data: "start"281          }282        ]283 284      ]285 286    }287 288  });289 290  return;291}292 293 294// ==========================================================295// 🎉 BOTH CHANNELS VERIFIED296// ==========================================================297 298Bot.setProperty(299  "GIFT_VERIFIED_" + userId,300  true,301  "boolean"302);303 304 305// ==========================================================306// 📡 REGISTER USER307// ==========================================================308 309var users =310  Bot.getProperty(311    "broadcast_users"312  );313 314if (!Array.isArray(users)) {315  users = [];316}317 318 319var cleanUsers = [];320var seenUsers = {};321 322for (323  var i = 0;324  i < users.length;325  i++326) {327 328  if (329    users[i] === null ||330    users[i] === undefined331  ) {332    continue;333  }334 335 336  var savedId =337    String(users[i]).trim();338 339 340  if (341    !/^\d+$/.test(savedId)342  ) {343    continue;344  }345 346 347  if (348    seenUsers[savedId]349  ) {350    continue;351  }352 353 354  seenUsers[savedId] = true;355 356  cleanUsers.push(357    savedId358  );359 360}361 362 363if (364  !seenUsers[userId]365) {366 367  cleanUsers.push(368    userId369  );370 371}372 373 374Bot.setProperty(375  "broadcast_users",376  cleanUsers,377  "json"378);379 380 381// ==========================================================382// 🔄 CALLBACK SUCCESS383// ==========================================================384 385Api.answerCallbackQuery({386  callback_query_id: request.id,387  text: "✅ Membership verified!",388  show_alert: false389});390 391 392// ==========================================================393// 💜 TELL USER TO CLICK /START394// ==========================================================395 396Bot.sendMessage({397 398  chat_id: userId,399 400  text:401 402    "🎉 <b>MEMBERSHIP VERIFIED!</b> 💜\n\n" +403 404    "You've successfully joined both required channels. 🔓\n\n" +405 406    "✨ Gift AI is now unlocked.\n\n" +407 408    "👇 <b>Click /start again</b> to enter Gift AI " +409    "and see the available commands.",410 411  parse_mode: "HTML"412 413});