CREATORS/OnecreatorsbotPublic · Bot Template

ProfileTelegram

AIThe bot manages a membership club called CREATORS. Users can apply for membership, view their status, and receive payment instructions. Administrators can approve or reject applications, set subscription prices, configure payment details, and review pending payments. The bot stores data in a database, sends notifications to users and admins, and handles payment receipts via photo or document uploads.

Commercemembershipsubscriptionpaymentsadmincreatortelegram
22 commands1 envUpdated 20d agoCreated Oct 6, 2026
Back to folder

commands/_manage.js

javascript · 392 lines

Raw
1/**#command2name: /manage3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12if (String(user.id) !== String(process.env.ADMIN_ID)) {13  await Api.sendMessage({14    chat_id: chat.id,15    text: "⛔ دسترسی مجاز نیست."16  });17  return;18}19 20 21// ─────────────────────────────22// بدون عبارت جستجو23// ─────────────────────────────24 25if (!params || !params.trim()) {26 27  await Api.sendMessage({28    chat_id: chat.id,29    text:30      "✦ مدیریت Creator\n\n" +31      "برای پیدا کردن یک Creator می‌توانی یکی از موارد زیر را وارد کنی:\n\n" +32      "• Telegram ID\n" +33      "• نام\n" +34      "• نام خانوادگی\n" +35      "• Username\n\n" +36      "مثال:\n" +37      "/manage 1747493585\n" +38      "/manage Erfan\n" +39      "/manage @Iamerfannasiri"40  });41 42  return;43}44 45 46// ─────────────────────────────47// عبارت جستجو48// ─────────────────────────────49 50const query = params.trim().toLowerCase();51 52 53// ─────────────────────────────54// اگر Telegram ID وارد شده باشد55// ─────────────────────────────56 57if (/^\d+$/.test(query)) {58 59  const targetId = Number(query);60 61  const info = await Api.getChat({62    chat_id: targetId63  });64 65  if (!info.ok) {66 67    await Api.sendMessage({68      chat_id: chat.id,69      text: "⛔ کاربری با این Telegram ID پیدا نشد."70    });71 72    return;73  }74 75  await sendManagePanel(targetId, info.result);76  return;77}78 79 80// ─────────────────────────────81// جستجوی نام / username82// ─────────────────────────────83 84const ids = await Bot.getUsers();85 86const matches = [];87 88for (const id of ids) {89 90  const info = await Api.getChat({91    chat_id: Number(id)92  });93 94  if (!info.ok || !info.result) {95    continue;96  }97 98  const person = info.result;99 100  const firstName = String(person.first_name || "").toLowerCase();101  const lastName = String(person.last_name || "").toLowerCase();102  const username = String(person.username || "").toLowerCase();103 104  const fullName =105    (firstName + " " + lastName).trim();106 107  const searchUsername =108    query.startsWith("@")109      ? query.substring(1)110      : query;111 112  if (113    firstName.includes(query) ||114    lastName.includes(query) ||115    fullName.includes(query) ||116    username.includes(searchUsername)117  ) {118 119    matches.push(person);120  }121}122 123 124// ─────────────────────────────125// هیچ نتیجه‌ای پیدا نشد126// ─────────────────────────────127 128if (matches.length === 0) {129 130  await Api.sendMessage({131    chat_id: chat.id,132    text:133      "⛔ هیچ Creatorای با این مشخصات پیدا نشد.\n\n" +134      "جستجو: " + params.trim()135  });136 137  return;138}139 140 141// ─────────────────────────────142// فقط یک نتیجه143// ─────────────────────────────144 145if (matches.length === 1) {146 147  await sendManagePanel(148    matches[0].id,149    matches[0]150  );151 152  return;153}154 155 156// ─────────────────────────────157// چند نتیجه158// ─────────────────────────────159 160const keyboard = [];161 162for (const person of matches.slice(0, 20)) {163 164  const name =165    ((person.first_name || "") + " " +166     (person.last_name || "")).trim();167 168  const username =169    person.username170      ? " @" + person.username171      : "";172 173  keyboard.push([174    {175      text:176        "👤 " +177        (name || "بدون نام") +178        username,179 180      callback_data:181        "manage_" + person.id182    }183  ]);184}185 186 187await Api.sendMessage({188  chat_id: chat.id,189 190  text:191    "✦ چند Creator پیدا شد\n\n" +192    "نتیجه موردنظر را انتخاب کن:",193 194  reply_markup: {195    inline_keyboard: keyboard196  }197});198 199 200// ─────────────────────────────201// ساخت پنل مدیریت202// ─────────────────────────────203 204async function sendManagePanel(targetId, person) {205 206  const membership = await db.user.get(207    "membership_status",208    "unknown",209    { user_id: targetId }210  );211 212  const access = await db.user.get(213    "access",214    {},215    { user_id: targetId }216  );217 218  const a = access || {};219 220  const name =221    ((person.first_name || "") + " " +222     (person.last_name || "")).trim();223 224  const username =225    person.username226      ? "@" + person.username227      : "ندارد";228 229  await Api.sendMessage({230 231    chat_id: chat.id,232 233    text:234      "✦ مدیریت Creator\n\n" +235 236      "نام: " +237      (name || "بدون نام") +238      "\n" +239 240      "Username: " +241      username +242      "\n" +243 244      "Telegram ID: " +245      targetId +246      "\n\n" +247 248      "وضعیت عضویت: " +249      membership +250      "\n\n" +251 252      "دسترسی‌ها:",253 254    reply_markup: {255 256      inline_keyboard: [257 258        [259          {260            text: "🟢 فعال کردن همه",261            callback_data:262              "all_on_" + targetId263          },264 265          {266            text: "🔴 غیرفعال کردن همه",267            callback_data:268              "all_off_" + targetId269          }270        ],271 272        [273          {274            text:275              (a.membership ? "🟢" : "🔴") +276              " عضویت اصلی",277 278            callback_data:279              "toggle_" +280              targetId +281              "_membership"282          }283        ],284 285        [286          {287            text:288              (a.profile ? "🟢" : "🔴") +289              " پروفایل",290 291            callback_data:292              "toggle_" +293              targetId +294              "_profile"295          }296        ],297 298        [299          {300            text:301              (a.challenges ? "🟢" : "🔴") +302              " چالش‌ها",303 304            callback_data:305              "toggle_" +306              targetId +307              "_challenges"308          }309        ],310 311        [312          {313            text:314              (a.vc ? "🟢" : "🔴") +315              " VC",316 317            callback_data:318              "toggle_" +319              targetId +320              "_vc"321          }322        ],323 324        [325          {326            text:327              (a.streak ? "🟢" : "🔴") +328              " Streak",329 330            callback_data:331              "toggle_" +332              targetId +333              "_streak"334          }335        ],336 337        [338          {339            text:340              (a.achievements ? "🟢" : "🔴") +341              " دستاوردها",342 343            callback_data:344              "toggle_" +345              targetId +346              "_achievements"347          }348        ],349 350        [351          {352            text:353              (a.rewards ? "🟢" : "🔴") +354              " جوایز",355 356            callback_data:357              "toggle_" +358              targetId +359              "_rewards"360          }361        ],362 363        [364          {365            text:366              (a.private_content ? "🟢" : "🔴") +367              " محتوای خصوصی",368 369            callback_data:370              "toggle_" +371              targetId +372              "_private_content"373          }374        ],375 376        [377          {378            text:379              (a.private_group ? "🟢" : "🔴") +380              " گروه خصوصی",381 382            callback_data:383              "toggle_" +384              targetId +385              "_private_group"386          }387        ]388 389      ]390    }391  });392    }