xseaqbka/Nawaab_RoBotPublic · Bot Template

AIThis Telegram bot acts as a TOTP authenticator: users can add accounts via Base32 secret, QR code, or otpauth:// URI, list saved keys, and generate current OTP codes on demand with refresh and delete options. It includes an admin panel with user ban/unban, paginated user management, required-channel management, and a broadcast system that sends text, image, or copied replied messages to all private chats. A web dashboard endpoint provides OTP generation and account management over HTTP. The bot also supports an on/off maintenance switch and per-user access gating.

Utilitytotpauthenticatorotp2fabroadcastadmin
ProfileTelegram
59 commands1 envUpdated 10d agoCreated Aug 28, 2026
Back to folder

commands/_view.js

javascript · 72 lines

Raw
1/**#command2name: /view3answer: 4keyboard: 5parse_mode: html6aliases: view7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12/* Command: /view */13if (!(await authUtils.userGate())) return;14 15const keys = await authUtils.getKeys();16const requested = parseInt(String(options?.index || params || "").trim(), 10);17 18if (!keys.length) {19  await authUtils.renderMedia(20    "🔐 <b>No Accounts</b>\n\nAdd an authenticator account first.",21    [[authUtils.btn("➕ Add Key", "add_key", "success"), authUtils.btn("⬅️ Main Menu", "start")]],22    "key_image"23  );24  return;25}26 27if (!Number.isNaN(requested)) {28  if (requested < 1 || requested > keys.length) {29    await authUtils.renderMedia(30      `❌ <b>Invalid account</b>\n\nChoose an account from <b>1–${keys.length}</b>.`,31      [[authUtils.btn("🔐 My Keys", "my_keys"), authUtils.btn("✕ Close", "close", "danger")]],32      "key_image"33    );34    return;35  }36 37  const account = keys[requested-1];38  const now = Date.now();39  const otp = authUtils.generateTotp(account, now);40  const period = Number(account.period || 30);41  const remaining = authUtils.secondsRemaining(period, now);42  const safeName = authUtils.escapeHtml(account.name || "Authenticator Account");43  const issuer = account.issuer ? `\n🏢 ${authUtils.escapeHtml(account.issuer)}` : "";44 45  await authUtils.renderMedia(46    "🔐 <b>" + safeName + "</b>" +47    issuer + "\n\n" +48    `🔢 <b>OTP:</b> <code>${otp}</code>\n` +49    `⏳ Expires in: <b>${remaining}s</b>\n\n` +50    "<i>Tap refresh whenever you need a new code.</i>",51    [52      [authUtils.btn("🔄 Refresh", "view_" + requested, "primary"), authUtils.btn("🗑 Delete", "delete_" + requested, "danger")],53      [authUtils.btn("⬅️ My Keys", "my_keys"), authUtils.btn("✕ Close", "close", "danger")]54    ],55    "key_image"56  );57  return;58}59 60const rows=[];61for(let i=0;i<keys.length;i+=2){62  const row=[authUtils.btn("🔐 "+(keys[i].name||"Account "+(i+1)), "view_"+(i+1))];63  if(keys[i+1]) row.push(authUtils.btn("🔐 "+(keys[i+1].name||"Account "+(i+2)), "view_"+(i+2)));64  rows.push(row);65}66rows.push([authUtils.btn("⬅️ Main Menu","start"),authUtils.btn("✕ Close","close","danger")]);67 68await authUtils.renderMedia(69  "👁️ <b>Your Accounts</b>\n\nSelect an account to view its current verification code.",70  rows,71  "key_image"72);