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

javascript · 282 lines

Raw
1/**#command2name: /unlock3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// ==========================================================13// 👑 GIFT AI — /unlock14// GROUP UNLOCK SYSTEM15//16// • Admin only17// • Opens the group immediately18// • Restores normal member permissions19// • Clears saved lock state20// • Replies directly to /unlock21// ==========================================================22 23 24// ----------------------------------------------------------25// BASIC CHECK26// ----------------------------------------------------------27 28if (!request || !chat || !chat.id) {29  return;30}31 32 33var chatId = chat.id;34var adminId = request.from.id;35 36 37// ----------------------------------------------------------38// ONLY GROUPS39// ----------------------------------------------------------40 41if (42  chat.type !== "group" &&43  chat.type !== "supergroup"44) {45 46  await Api.sendMessage({47    chat_id: chatId,48    text: "😐 <b>/unlock only works inside groups.</b>",49    parse_mode: "HTML",50    reply_to_message_id: request.message_id51  });52 53  return;54}55 56 57// ----------------------------------------------------------58// CHECK ADMIN59// ----------------------------------------------------------60 61var adminCheck = await Api.getChatMember({62  chat_id: chatId,63  user_id: adminId64});65 66 67if (68  !adminCheck ||69  !adminCheck.ok ||70  !adminCheck.result71) {72 73  await Api.sendMessage({74    chat_id: chatId,75    text:76      "⚠️ <b>I couldn't verify your admin status.</b>",77    parse_mode: "HTML",78    reply_to_message_id: request.message_id79  });80 81  return;82}83 84 85var adminStatus =86  adminCheck.result.status;87 88 89// ----------------------------------------------------------90// ADMIN ONLY91// ----------------------------------------------------------92 93if (94  adminStatus !== "administrator" &&95  adminStatus !== "creator"96) {97 98  await Api.sendMessage({99    chat_id: chatId,100    text:101      "🚫 <b>Only group admins can unlock the group.</b>",102    parse_mode: "HTML",103    reply_to_message_id: request.message_id104  });105 106  return;107}108 109 110// ----------------------------------------------------------111// CHECK GIFT'S PERMISSIONS112// ----------------------------------------------------------113 114var botId = null;115 116try {117 118  var me = await Api.getMe();119 120  if (121    me &&122    me.ok &&123    me.result124  ) {125    botId = me.result.id;126  }127 128} catch (e) {129 130  botId = null;131}132 133 134// ----------------------------------------------------------135// VERIFY GIFT IS ADMIN136// ----------------------------------------------------------137 138if (botId) {139 140  var botCheck = await Api.getChatMember({141    chat_id: chatId,142    user_id: botId143  });144 145 146  if (147    !botCheck ||148    !botCheck.ok ||149    !botCheck.result150  ) {151 152    await Api.sendMessage({153      chat_id: chatId,154      text:155        "❌ <b>Gift must be an admin to unlock this group.</b>",156      parse_mode: "HTML",157      reply_to_message_id: request.message_id158    });159 160    return;161  }162 163 164  var botStatus =165    botCheck.result.status;166 167 168  if (169    botStatus !== "administrator" &&170    botStatus !== "creator"171  ) {172 173    await Api.sendMessage({174      chat_id: chatId,175      text:176        "❌ <b>Make Gift an admin first.</b>",177      parse_mode: "HTML",178      reply_to_message_id: request.message_id179    });180 181    return;182  }183}184 185 186// ----------------------------------------------------------187// UNLOCK GROUP188// ----------------------------------------------------------189//190// Restore normal Telegram group permissions.191// ----------------------------------------------------------192 193var unlockResult =194  await Api.setChatPermissions({195    chat_id: chatId,196 197    permissions: {198      can_send_messages: true,199      can_send_audios: true,200      can_send_documents: true,201      can_send_photos: true,202      can_send_videos: true,203      can_send_video_notes: true,204      can_send_voice_notes: true,205      can_send_polls: true,206      can_send_other_messages: true,207      can_add_web_page_previews: true208    }209  });210 211 212// ----------------------------------------------------------213// UNLOCK FAILED214// ----------------------------------------------------------215 216if (217  !unlockResult ||218  !unlockResult.ok219) {220 221  await Api.sendMessage({222    chat_id: chatId,223    text:224      "❌ <b>I couldn't unlock this group.</b>\n\n" +225      "Make sure Gift is an admin and has permission to change group permissions.",226    parse_mode: "HTML",227    reply_to_message_id: request.message_id228  });229 230  return;231}232 233 234// ----------------------------------------------------------235// CLEAR LOCK STATE236// ----------------------------------------------------------237 238Bot.setProperty(239  "LOCKED_" + chatId,240  false,241  "boolean"242);243 244Bot.setProperty(245  "LOCK_UNTIL_" + chatId,246  0,247  "integer"248);249 250 251// ----------------------------------------------------------252// GET ADMIN NAME253// ----------------------------------------------------------254 255var adminName =256  String(257    request.from.first_name ||258    request.from.username ||259    "Admin"260  );261 262 263// ----------------------------------------------------------264// SUCCESS265// ----------------------------------------------------------266 267await Api.sendMessage({268  chat_id: chatId,269  text:270    "🔓 <b>GROUP UNLOCKED</b>\n\n" +271    "💜 <b>" +272    String(chat.title || "This group") +273    "</b> is open again.\n\n" +274    "👑 Unlocked by: <a href=\"tg://user?id=" +275    adminId +276    "\">" +277    adminName +278    "</a>\n\n" +279    "😌 You may resume the chaos.",280  parse_mode: "HTML",281  reply_to_message_id: request.message_id282});