Spaces:
Running on Zero
Running on Zero
Upload 6 files
Browse files- README.md +3 -8
- app.py +0 -0
- index.html +1146 -0
- prompt.txt +0 -0
- requirements.txt +6 -0
README.md
CHANGED
|
@@ -1,13 +1,8 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom: pink
|
| 5 |
-
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
python_version: '3.12'
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
---
|
| 12 |
-
|
| 13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Telegram Bot
|
| 3 |
+
emoji: 🤖
|
|
|
|
|
|
|
| 4 |
sdk: gradio
|
| 5 |
+
sdk_version: 5.49.1
|
|
|
|
| 6 |
app_file: app.py
|
| 7 |
pinned: false
|
| 8 |
---
|
|
|
|
|
|
app.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
index.html
ADDED
|
@@ -0,0 +1,1146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="fa" dir="rtl" data-bs-theme="dark">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<script>try{if(localStorage.getItem("TG_PASS"))document.documentElement.classList.add("has-session")}catch(e){}</script>
|
| 6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
|
| 7 |
+
<title>Telegram Web Admin</title>
|
| 8 |
+
<link rel="manifest" href="/manifest.json">
|
| 9 |
+
<meta name="theme-color" content="#10131a">
|
| 10 |
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
| 11 |
+
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
| 12 |
+
<link rel="icon" type="image/svg+xml" href="/icon.svg">
|
| 13 |
+
<link rel="apple-touch-icon" href="/icon.svg">
|
| 14 |
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
| 15 |
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 16 |
+
<!-- Material Symbols (Rounded), loaded as a small subset of just the icons the app uses.
|
| 17 |
+
If you add an icon, add its name here (alphabetical) and map it in static/css/icons.css -->
|
| 18 |
+
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,400,0..1,0&icon_names=add,android,arrow_back,attach_file,auto_fix_high,badge,block,chat,check_circle,chevron_right,close,content_copy,delete,description,desktop_windows,devices,done,download,edit,edit_square,error,filter_list,forward,gif_box,group,image,info,install_mobile,keep,key,keyboard_arrow_down,language,logout,manage_accounts,menu,mic,mic_off,mood,movie,notifications,notifications_off,pause,pause_circle,person_add,person_remove,photo_camera,play_arrow,play_circle,reply,search,send,shortcut,smart_toy,sticky_note_2,verified_user,videocam,warning,work&display=block" rel="stylesheet">
|
| 19 |
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 20 |
+
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
| 21 |
+
<!-- Material Design 3: tokens → icons → base primitives → components -->
|
| 22 |
+
<link href="/static/css/variables.css" rel="stylesheet">
|
| 23 |
+
<link href="/static/css/icons.css" rel="stylesheet">
|
| 24 |
+
<link href="/static/css/base.css" rel="stylesheet">
|
| 25 |
+
<link href="/static/css/sidebar.css" rel="stylesheet">
|
| 26 |
+
<link href="/static/css/chatlist.css" rel="stylesheet">
|
| 27 |
+
<link href="/static/css/topbar.css" rel="stylesheet">
|
| 28 |
+
<link href="/static/css/bubble.css" rel="stylesheet">
|
| 29 |
+
<link href="/static/css/composer.css" rel="stylesheet">
|
| 30 |
+
<link href="/static/css/emoji.css" rel="stylesheet">
|
| 31 |
+
<link href="/static/css/settings.css" rel="stylesheet">
|
| 32 |
+
</head>
|
| 33 |
+
<body>
|
| 34 |
+
<!-- shown (instead of the sign-in form) while a stored session is re-validated — see html.has-session in settings.css -->
|
| 35 |
+
<div class="splash" id="splash" aria-hidden="true">
|
| 36 |
+
<div class="brand-orb"><i class="bi bi-telegram"></i></div>
|
| 37 |
+
<div class="splash-status"><span class="spinner-border spinner-border-sm"></span><span id="splashText">در حال بارگذاری…</span></div>
|
| 38 |
+
</div>
|
| 39 |
+
<div id="authBox" class="container h-100 d-flex justify-content-center align-items-center">
|
| 40 |
+
<div class="auth-card text-center">
|
| 41 |
+
<div class="brand-orb mx-auto mb-3"><i class="bi bi-telegram"></i></div>
|
| 42 |
+
<h5 class="mb-1 fw-bold">پنل مدیریت تلگرام</h5>
|
| 43 |
+
<!-- login mode -->
|
| 44 |
+
<div id="authLogin">
|
| 45 |
+
<p class="text-secondary small mb-3">برای ورود، یوزرنیم و رمز عبور را وارد کن</p>
|
| 46 |
+
<div id="authSuspended" class="auth-suspended d-none"><i class="bi bi-slash-circle"></i> این یوزر تعلیق شده است. با مدیر تماس بگیر.</div>
|
| 47 |
+
<input type="text" id="userInput" class="form-control mb-2 text-center" placeholder="یوزرنیم" autocomplete="username">
|
| 48 |
+
<input type="password" id="passInput" class="form-control mb-3 text-center" placeholder="رمز عبور" autocomplete="current-password" onkeydown="if(event.key==='Enter')login()">
|
| 49 |
+
<button class="btn btn-primary w-100 py-2" onclick="login()">ورود</button>
|
| 50 |
+
<a class="auth-link" onclick="showAuthMode('forgot')">فراموشی رمز عبور</a>
|
| 51 |
+
</div>
|
| 52 |
+
<!-- forgot mode -->
|
| 53 |
+
<div id="authForgot" class="d-none">
|
| 54 |
+
<p class="text-secondary small mb-3">یوزرنیمت را بنویس؛ ربات خودت یک رمز موقت برای تلگرامِ صاحب حساب میفرستد (باید قبلاً یکبار ربات را /start کرده باشی).</p>
|
| 55 |
+
<input type="text" id="forgotUser" class="form-control mb-3 text-center" placeholder="یوزرنیم">
|
| 56 |
+
<button class="btn btn-primary w-100 py-2" onclick="requestReset()">ارسال رمز موقت به تلگرام</button>
|
| 57 |
+
<a class="auth-link" onclick="showAuthMode('login')">بازگشت به ورود</a>
|
| 58 |
+
</div>
|
| 59 |
+
<!-- forced change: shown after logging in with a one-time recovery password -->
|
| 60 |
+
<div id="authForce" class="d-none">
|
| 61 |
+
<p class="text-secondary small mb-3">با رمز موقت وارد شدی. یک رمز عبور جدید انتخاب کن (حداقل ۶ کاراکتر).</p>
|
| 62 |
+
<input type="password" id="forceNew1" class="form-control mb-2 text-center" placeholder="رمز جدید" autocomplete="new-password">
|
| 63 |
+
<input type="password" id="forceNew2" class="form-control mb-3 text-center" placeholder="تکرار رمز جدید" autocomplete="new-password" onkeydown="if(event.key==='Enter')submitForcedChange()">
|
| 64 |
+
<button class="btn btn-primary w-100 py-2" onclick="submitForcedChange()">ذخیره و ورود</button>
|
| 65 |
+
</div>
|
| 66 |
+
</div>
|
| 67 |
+
</div>
|
| 68 |
+
|
| 69 |
+
<div id="mainApp" class="app d-none">
|
| 70 |
+
<!-- Settings overlay -->
|
| 71 |
+
<!-- Phase 6: real multi-page settings (main list → sub-pages),
|
| 72 |
+
instead of one long flat page — matches the actual Telegram
|
| 73 |
+
app's Settings screen structure. Sub-page navigation goes
|
| 74 |
+
through the same back-stack as everything else (pushUiState),
|
| 75 |
+
so the device back button steps out of a sub-page one level
|
| 76 |
+
at a time instead of leaving settings entirely. -->
|
| 77 |
+
<div class="settings-page" id="settingsPage">
|
| 78 |
+
<!-- main list -->
|
| 79 |
+
<div class="sp-view" id="spMain">
|
| 80 |
+
<div class="sp-hdr">
|
| 81 |
+
<button class="icon-btn" onclick="goBackOneLevel()"><i class="bi bi-arrow-right"></i></button>
|
| 82 |
+
<h5>تنظیمات</h5>
|
| 83 |
+
</div>
|
| 84 |
+
<div class="sp-body">
|
| 85 |
+
<div class="sp-list-row owner-only d-none" onclick="openSettingsSub('users')"><i class="bi bi-people"></i><span>کاربران پنل</span><i class="bi bi-chevron-left arrow"></i></div>
|
| 86 |
+
<div class="sp-list-row" onclick="openSettingsSub('ai')"><i class="bi bi-robot"></i><span>هوش مصنوعی</span><small id="spAiSummary"></small><i class="bi bi-chevron-left arrow"></i></div>
|
| 87 |
+
<div class="sp-list-row" onclick="openSettingsSub('panel')"><i class="bi bi-person-gear"></i><span>پنل و اعلانها</span><i class="bi bi-chevron-left arrow"></i></div>
|
| 88 |
+
<div class="sp-list-row" onclick="openSettingsSub('devices')"><i class="bi bi-devices"></i><span>دستگاههای وارد شده</span><i class="bi bi-chevron-left arrow"></i></div>
|
| 89 |
+
<div class="sp-list-row" onclick="openSettingsSub('bot')"><i class="bi bi-pencil-square"></i><span>پروفایل ربات</span><i class="bi bi-chevron-left arrow"></i></div>
|
| 90 |
+
<div class="sp-list-row" onclick="openSettingsSub('about')"><i class="bi bi-info-circle"></i><span>درباره</span><i class="bi bi-chevron-left arrow"></i></div>
|
| 91 |
+
<div class="sp-list-row tenant-only d-none" onclick="changePasswordDialog()"><i class="bi bi-key"></i><span>تغییر رمز عبور</span></div>
|
| 92 |
+
<div class="sp-list-row" onclick="logout()"><i class="bi bi-box-arrow-right" style="background:var(--md-sys-color-error-container);color:var(--md-sys-color-on-error-container)"></i><span style="color:var(--md-sys-color-error)">خروج از حساب</span></div>
|
| 93 |
+
</div>
|
| 94 |
+
</div>
|
| 95 |
+
|
| 96 |
+
<!-- Users sub-page (owner only): everything /signup, /setbot, /resetpass,
|
| 97 |
+
/suspend, /deleteuser do from the admin group, as a GUI -->
|
| 98 |
+
<div class="sp-view sp-sub" id="spUsers" style="display:none">
|
| 99 |
+
<div class="sp-hdr">
|
| 100 |
+
<button class="icon-btn" onclick="goBackOneLevel()"><i class="bi bi-arrow-right"></i></button>
|
| 101 |
+
<h5>کاربران پنل</h5>
|
| 102 |
+
</div>
|
| 103 |
+
<div class="sp-body">
|
| 104 |
+
<div id="uBaseWarn" class="alert alert-warning py-2 d-none" style="font-size:.8rem">متغیر <code>PUBLIC_BASE_URL</code> روی Space تنظیم نشده؛ تا تنظیم نشه نمیشه ربات کاربر را وصل کرد.</div>
|
| 105 |
+
<div class="sp-card">
|
| 106 |
+
<div class="u-form-title"><i class="bi bi-person-plus"></i> کاربر جدید</div>
|
| 107 |
+
<input id="uName" class="form-control mb-2" placeholder="یوزرنیم (لاتین، ۳ تا ۳۲ کاراکتر)" autocomplete="off">
|
| 108 |
+
<div class="d-flex gap-2 mb-2">
|
| 109 |
+
<input id="uPass" class="form-control" placeholder="رمز عبور (حداقل ۶ کاراکتر)" autocomplete="new-password">
|
| 110 |
+
<button class="btn btn-outline-secondary" type="button" title="تولید رمز تصادفی" onclick="document.getElementById('uPass').value=genPass()"><i class="bi bi-magic"></i></button>
|
| 111 |
+
</div>
|
| 112 |
+
<input id="uTgId" class="form-control mb-2" placeholder="آیدی عددی تلگرام صاحب حساب (برای بازیابی رمز)" autocomplete="off" inputmode="numeric">
|
| 113 |
+
<button class="btn btn-primary w-100" onclick="createUser()">ساخت حساب</button>
|
| 114 |
+
</div>
|
| 115 |
+
<div class="u-form-title mt-3"><i class="bi bi-people"></i> حسابها</div>
|
| 116 |
+
<div id="uList"></div>
|
| 117 |
+
</div>
|
| 118 |
+
</div>
|
| 119 |
+
|
| 120 |
+
<!-- AI sub-page -->
|
| 121 |
+
<div class="sp-view sp-sub" id="spAi" style="display:none">
|
| 122 |
+
<div class="sp-hdr">
|
| 123 |
+
<button class="icon-btn" onclick="goBackOneLevel()"><i class="bi bi-arrow-right"></i></button>
|
| 124 |
+
<h5>هوش مصنوعی</h5>
|
| 125 |
+
</div>
|
| 126 |
+
<div class="sp-body">
|
| 127 |
+
<div class="sp-card">
|
| 128 |
+
<div class="sp-row">
|
| 129 |
+
<label for="gAiToggle">فعالسازی کلی AI</label>
|
| 130 |
+
<div class="form-check form-switch m-0"><input class="form-check-input" type="checkbox" id="gAiToggle"></div>
|
| 131 |
+
</div>
|
| 132 |
+
<div class="sp-row">
|
| 133 |
+
<label>کلید API گوگل (AI Studio)</label>
|
| 134 |
+
<span><input id="gGeminiKey" type="password" class="sp-inp" style="width:190px" autocomplete="new-password"> <button class="u-btn danger" type="button" onclick="clearGeminiKey()">حذف</button></span>
|
| 135 |
+
</div>
|
| 136 |
+
<div class="text-secondary" id="gGeminiHint" style="font:var(--md-type-body-small)"></div>
|
| 137 |
+
<div class="sp-row">
|
| 138 |
+
<label>مدل زبانی</label>
|
| 139 |
+
<input id="gModel" class="sp-inp" style="width:200px" placeholder="gemini-2.5-flash">
|
| 140 |
+
</div>
|
| 141 |
+
<div class="sp-row">
|
| 142 |
+
<label>تأخیر پاسخ دستهای (ثانیه)</label>
|
| 143 |
+
<input id="gDelay" type="number" class="sp-inp" style="width:80px" min="5" max="120">
|
| 144 |
+
</div>
|
| 145 |
+
<div>
|
| 146 |
+
<label class="form-label">پرامپت پیشفرض</label>
|
| 147 |
+
<textarea id="gPrompt" class="form-control" rows="6" placeholder="پرامپت مادر..."></textarea>
|
| 148 |
+
</div>
|
| 149 |
+
</div>
|
| 150 |
+
<button class="btn btn-primary w-100 mb-3 mt-3" onclick="saveAllSettings()">ذخیره</button>
|
| 151 |
+
</div>
|
| 152 |
+
</div>
|
| 153 |
+
|
| 154 |
+
<!-- Panel sub-page -->
|
| 155 |
+
<div class="sp-view sp-sub" id="spPanel" style="display:none">
|
| 156 |
+
<div class="sp-hdr">
|
| 157 |
+
<button class="icon-btn" onclick="goBackOneLevel()"><i class="bi bi-arrow-right"></i></button>
|
| 158 |
+
<h5>پنل و اعلانها</h5>
|
| 159 |
+
</div>
|
| 160 |
+
<div class="sp-body">
|
| 161 |
+
<div class="sp-card">
|
| 162 |
+
<div class="sp-row">
|
| 163 |
+
<label>آیدی عددی تلگرام شما (تشخیص پیامهای خودتان + بازیابی رمز)</label>
|
| 164 |
+
<input id="gOwnerId" class="sp-inp" style="width:150px" placeholder="12345678">
|
| 165 |
+
</div>
|
| 166 |
+
<div class="sp-row">
|
| 167 |
+
<label>پکهای استیکر پنل (نام کوتاه، با کاما جدا کن)</label>
|
| 168 |
+
<input id="gStickerPacks" class="sp-inp" style="width:220px" placeholder="MyStickerSet, AnotherPack">
|
| 169 |
+
</div>
|
| 170 |
+
<div class="sp-row">
|
| 171 |
+
<label>نرخ بروزرسانی (میلیثانیه)</label>
|
| 172 |
+
<input id="gPoll" type="number" class="sp-inp" style="width:100px" min="500">
|
| 173 |
+
</div>
|
| 174 |
+
<div class="sp-row tenant-only d-none">
|
| 175 |
+
<label>آیدی گروه ادمین (برای /send_msg و گزارش خطا)</label>
|
| 176 |
+
<span><input id="gAdminGroup" class="sp-inp" style="width:150px" placeholder="-1001234567890" autocomplete="off"> <button class="u-btn primary" type="button" onclick="testAdminGroup()">تست</button></span>
|
| 177 |
+
</div>
|
| 178 |
+
<div class="sp-row">
|
| 179 |
+
<label>فعالسازی اعلان پسزمینه</label>
|
| 180 |
+
<div class="form-check form-switch m-0"><input class="form-check-input" type="checkbox" id="gPushToggle" onchange="togglePushNotifications(this.checked)"></div>
|
| 181 |
+
</div>
|
| 182 |
+
</div>
|
| 183 |
+
<button class="btn btn-primary w-100 mb-3 mt-3" onclick="saveAllSettings()">ذخیره</button>
|
| 184 |
+
</div>
|
| 185 |
+
</div>
|
| 186 |
+
|
| 187 |
+
<!-- Bot profile sub-page -->
|
| 188 |
+
<div class="sp-view sp-sub" id="spBot" style="display:none">
|
| 189 |
+
<div class="sp-hdr">
|
| 190 |
+
<button class="icon-btn" onclick="goBackOneLevel()"><i class="bi bi-arrow-right"></i></button>
|
| 191 |
+
<h5>پروفایل ربات</h5>
|
| 192 |
+
</div>
|
| 193 |
+
<div class="sp-body">
|
| 194 |
+
<div id="bpNoBot" class="alert alert-warning py-2 d-none" style="font-size:.8rem"></div>
|
| 195 |
+
<div class="bp-head">
|
| 196 |
+
<div class="bp-avatar"><img id="bpPhoto" alt="" class="d-none"><i class="bi bi-robot" id="bpPhotoFallback"></i></div>
|
| 197 |
+
<div class="bp-info">
|
| 198 |
+
<div class="bp-name" id="bpName">—</div>
|
| 199 |
+
<div class="bp-meta" dir="ltr" id="bpUser"></div>
|
| 200 |
+
<div class="bp-meta" dir="ltr" id="bpId"></div>
|
| 201 |
+
</div>
|
| 202 |
+
</div>
|
| 203 |
+
<div class="d-flex gap-2 mb-3 justify-content-center">
|
| 204 |
+
<button class="u-btn primary" type="button" onclick="document.getElementById('bpFile').click()"><i class="bi bi-camera"></i> تغییر عکس</button>
|
| 205 |
+
<button class="u-btn danger" type="button" onclick="removeBotPhoto()"><i class="bi bi-trash3"></i> حذف عکس</button>
|
| 206 |
+
<input type="file" id="bpFile" accept="image/*" class="d-none" onchange="uploadBotPhoto(this)">
|
| 207 |
+
</div>
|
| 208 |
+
<div class="sp-card">
|
| 209 |
+
<label class="bp-label">نام ربات</label>
|
| 210 |
+
<input id="bName" class="form-control mb-2" placeholder="نام ربات">
|
| 211 |
+
<label class="bp-label">توضیحات کوتاه</label>
|
| 212 |
+
<textarea id="bShort" class="form-control mb-2" rows="2" placeholder="توضیحات کوتاه (روی صفحهی پروفایل ربات)"></textarea>
|
| 213 |
+
<label class="bp-label">توضیحات کامل</label>
|
| 214 |
+
<textarea id="bDesc" class="form-control" rows="4" placeholder="توضیحات کامل (وقتی چت خالی است)"></textarea>
|
| 215 |
+
</div>
|
| 216 |
+
<button class="btn btn-primary w-100 mb-3 mt-3" onclick="saveAllSettings()">ذخیره</button>
|
| 217 |
+
</div>
|
| 218 |
+
</div>
|
| 219 |
+
|
| 220 |
+
<!-- Signed-in devices: every browser / app session of this account -->
|
| 221 |
+
<div class="sp-view sp-sub" id="spDevices" style="display:none">
|
| 222 |
+
<div class="sp-hdr">
|
| 223 |
+
<button class="icon-btn" onclick="goBackOneLevel()"><i class="bi bi-arrow-right"></i></button>
|
| 224 |
+
<h5>دستگاههای وارد شده</h5>
|
| 225 |
+
</div>
|
| 226 |
+
<div class="sp-body">
|
| 227 |
+
<p class="text-secondary mb-3" style="font:var(--md-type-body-medium)">مرورگرها و اپهایی که با حساب تو وارد شدهاند. اسم هر کدام را عوض کن تا راحتتر تشخیصشان بدهی، و دستگاهی را که نمیشناسی خارج کن.</p>
|
| 228 |
+
<div id="devList"></div>
|
| 229 |
+
</div>
|
| 230 |
+
</div>
|
| 231 |
+
|
| 232 |
+
<!-- About sub-page -->
|
| 233 |
+
<div class="sp-view sp-sub" id="spAbout" style="display:none">
|
| 234 |
+
<div class="sp-hdr">
|
| 235 |
+
<button class="icon-btn" onclick="goBackOneLevel()"><i class="bi bi-arrow-right"></i></button>
|
| 236 |
+
<h5>درباره</h5>
|
| 237 |
+
</div>
|
| 238 |
+
<div class="sp-body">
|
| 239 |
+
<div class="sp-card text-center py-4">
|
| 240 |
+
<div class="brand-orb mx-auto mb-2"><i class="bi bi-telegram"></i></div>
|
| 241 |
+
<h6 class="fw-bold mb-1">Telegram Web Admin</h6>
|
| 242 |
+
<div class="text-secondary" style="font-size:.82rem">پنل مدیریت ربات/بیزینس تلگرام با ظاهر Telegram Web K</div>
|
| 243 |
+
</div>
|
| 244 |
+
<div class="sp-card mt-3" id="spAboutDetails">
|
| 245 |
+
<div class="sp-row"><label>مدل زبانی فعال</label><span id="spAboutModel" class="text-secondary"></span></div>
|
| 246 |
+
<div class="sp-row"><label>وضعیت AI</label><span id="spAboutAiState" class="text-secondary"></span></div>
|
| 247 |
+
</div>
|
| 248 |
+
</div>
|
| 249 |
+
</div>
|
| 250 |
+
</div>
|
| 251 |
+
|
| 252 |
+
<!-- Sidebar (Phase 1: real tweb structure — sidebar-header, view
|
| 253 |
+
switcher, folder tabs, ul.chatlist) -->
|
| 254 |
+
<div class="sidebar" id="sidebar">
|
| 255 |
+
<div>
|
| 256 |
+
<div class="sidebar-header">
|
| 257 |
+
<div class="search-bar">
|
| 258 |
+
<button class="icon-btn" onclick="openSettings()" title="تنظیمات" aria-label="تنظیمات"><i class="bi bi-list"></i></button>
|
| 259 |
+
<input type="text" id="searchInput" placeholder="جستجو" oninput="filterChats()" aria-label="جستجو">
|
| 260 |
+
<i class="bi bi-search search-ico"></i>
|
| 261 |
+
</div>
|
| 262 |
+
</div>
|
| 263 |
+
<!-- connection state (ws.js): connecting / waiting for network / updating -->
|
| 264 |
+
<div class="conn-status" id="connStatus" role="status" aria-live="polite"><span class="spinner-border spinner-border-sm"></span><span id="connText"></span></div>
|
| 265 |
+
<div class="view-switcher">
|
| 266 |
+
<div class="view-btn active" data-view="bot" onclick="switchView('bot')"><i class="bi bi-robot"></i> ربات <span class="vb-badge d-none" id="vbBotCount">0</span></div>
|
| 267 |
+
<div class="view-btn" data-view="biz" onclick="switchView('biz')"><i class="bi bi-telegram"></i> تلگرام <span class="vb-badge d-none" id="vbBizCount">0</span></div>
|
| 268 |
+
</div>
|
| 269 |
+
<div class="folder-tabs">
|
| 270 |
+
<div class="ftab active" data-tab="all" onclick="setTab('all')">همه <span class="cnt" id="cntAll">0</span></div>
|
| 271 |
+
<div class="ftab" data-tab="unread" onclick="setTab('unread')">خواندهنشده <span class="cnt" id="cntUnread">0</span></div>
|
| 272 |
+
<div class="ftab" data-tab="pinned" onclick="setTab('pinned')">پینشده <span class="cnt" id="cntPinned">0</span></div>
|
| 273 |
+
<div class="ftab" data-tab="groups" onclick="setTab('groups')">گروهها <span class="cnt" id="cntGroups">0</span></div>
|
| 274 |
+
</div>
|
| 275 |
+
</div>
|
| 276 |
+
<ul class="chatlist" id="chatList"></ul>
|
| 277 |
+
<button class="fab" onclick="openNewChatModal()" title="چت جدید" aria-label="چت جدید"><i class="bi bi-pencil"></i></button>
|
| 278 |
+
</div>
|
| 279 |
+
|
| 280 |
+
<!-- Main chat area -->
|
| 281 |
+
<div class="chat-main" id="chatMain">
|
| 282 |
+
<div id="noChat" class="h-100 d-flex flex-column align-items-center justify-content-center text-secondary">
|
| 283 |
+
<div class="brand-orb mb-3" style="opacity:.4"><i class="bi bi-chat-square-dots"></i></div>
|
| 284 |
+
<p>یک گفتگو را برای شروع انتخاب کنید</p>
|
| 285 |
+
</div>
|
| 286 |
+
|
| 287 |
+
<div id="chatBox" class="d-none h-100 flex-column">
|
| 288 |
+
<!-- Header (Phase 2: real tweb structure — chat-topbar /
|
| 289 |
+
chat-info-container / person-avatar / user-title) -->
|
| 290 |
+
<div class="chat-topbar">
|
| 291 |
+
<div class="chat-info-container" onclick="showProfileModal()" title="پروفایل">
|
| 292 |
+
<button class="icon-btn d-md-none" onclick="event.stopPropagation();handleBackButton()"><i class="bi bi-arrow-right"></i></button>
|
| 293 |
+
<div class="person-avatar" id="hdrAv">ت</div>
|
| 294 |
+
<div class="chat-info-text">
|
| 295 |
+
<h6 class="user-title text-truncate" id="hdrTitle">مخاطب</h6>
|
| 296 |
+
<div class="chat-info-subtitle" id="hdrSub">شناسه</div>
|
| 297 |
+
</div>
|
| 298 |
+
</div>
|
| 299 |
+
<!-- Pin/mute/AI-settings/delete/user-info now live inside
|
| 300 |
+
the profile modal (tap the name/avatar above) so the
|
| 301 |
+
topbar stays just back+avatar+name — the full
|
| 302 |
+
contact name stays readable even on small screens. -->
|
| 303 |
+
<div class="chat-utils">
|
| 304 |
+
<!-- Phase 5: opens the same group-info modal as
|
| 305 |
+
tapping the avatar/name — group management now
|
| 306 |
+
lives there (Members + مدیریت گروه), not in a
|
| 307 |
+
separate topbar toolbar. -->
|
| 308 |
+
<button class="icon-btn" id="gmodToggleBtn" onclick="showProfileModal()" title="اطلاعات و مدیریت گروه" style="display:none"><i class="bi bi-shield-check"></i></button>
|
| 309 |
+
</div>
|
| 310 |
+
</div>
|
| 311 |
+
|
| 312 |
+
<div class="msgs" id="msgs"></div>
|
| 313 |
+
|
| 314 |
+
<div id="scrollBtn" class="scroll-btn d-none" onclick="scrollBot(true)">
|
| 315 |
+
<i class="bi bi-chevron-down"></i>
|
| 316 |
+
<span id="ubadge" class="ubadge d-none">0</span>
|
| 317 |
+
</div>
|
| 318 |
+
|
| 319 |
+
<!-- Emoji picker -->
|
| 320 |
+
<div class="emoji-picker" id="emojiPicker">
|
| 321 |
+
<div class="emoji-cats" id="emojiCats"></div>
|
| 322 |
+
<div class="emoji-grid" id="emojiGrid"></div>
|
| 323 |
+
</div>
|
| 324 |
+
|
| 325 |
+
<!-- Sticker/GIF panel. The Bot API can't browse/search all
|
| 326 |
+
stickers (MTProto-only feature) — only sets the admin
|
| 327 |
+
names (Settings → sticker packs) plus whatever's been
|
| 328 |
+
sent before (tracked as "recent"). -->
|
| 329 |
+
<div class="emoji-picker" id="stickerPicker">
|
| 330 |
+
<div class="emoji-cats">
|
| 331 |
+
<span class="ec sk-tab active" data-tab="sticker" onclick="switchStickerTab('sticker')">🎭 استیکر</span>
|
| 332 |
+
<span class="ec sk-tab" data-tab="gif" onclick="switchStickerTab('gif')">🎬 گیف</span>
|
| 333 |
+
</div>
|
| 334 |
+
<div class="sk-grid" id="stickerGrid">
|
| 335 |
+
<div class="sk-empty" id="stickerEmpty">موردی نیست</div>
|
| 336 |
+
</div>
|
| 337 |
+
</div>
|
| 338 |
+
|
| 339 |
+
<!-- Composer -->
|
| 340 |
+
<div class="comp-wrap">
|
| 341 |
+
<div class="rstrip" id="rstrip">
|
| 342 |
+
<div class="d-flex align-items-center gap-2 flex-1" style="min-width:0">
|
| 343 |
+
<i class="bi bi-reply-fill" style="color:var(--md-sys-color-primary)"></i>
|
| 344 |
+
<span class="txt" id="rstripTxt"></span>
|
| 345 |
+
</div>
|
| 346 |
+
<i class="bi bi-x-lg" style="cursor:pointer" onclick="cancelReply()"></i>
|
| 347 |
+
</div>
|
| 348 |
+
<!-- Phase 3: real tweb recording pill — cancel(×), a
|
| 349 |
+
blinking-dot + timer pill, and an always-visible
|
| 350 |
+
send button (previously recording only offered a
|
| 351 |
+
text "لغو" link with no way to actually send). -->
|
| 352 |
+
<div class="voice-rec-panel" id="voiceRecPanel">
|
| 353 |
+
<div class="voice-rec-cancel" onclick="cancelRec()" title="لغو ضبط"><i class="bi bi-trash3"></i></div>
|
| 354 |
+
<div class="voice-rec-pill">
|
| 355 |
+
<span class="voice-rec-dot"></span>
|
| 356 |
+
<span class="voice-rec-label">در حال ضبط پیام صوتی...</span>
|
| 357 |
+
<span class="voice-rec-timer" id="voiceRecTimer">0:00</span>
|
| 358 |
+
</div>
|
| 359 |
+
<div class="voice-rec-send" onclick="stopRec(true)" title="ارسال"><i class="bi bi-send-fill" style="font-size:.85rem"></i></div>
|
| 360 |
+
</div>
|
| 361 |
+
<div class="comp-dock">
|
| 362 |
+
<div class="inp-row" id="inpRow">
|
| 363 |
+
<div style="position:relative">
|
| 364 |
+
<button class="icon-btn" id="attBtn"><i class="bi bi-paperclip"></i></button>
|
| 365 |
+
<div class="att-menu" id="attMenu">
|
| 366 |
+
<div class="opt" onclick="pickFile('image/*','photo')"><i class="bi bi-image"></i> عکس</div>
|
| 367 |
+
<div class="opt" onclick="pickFile('video/*','video')"><i class="bi bi-camera-video"></i> ویدیو</div>
|
| 368 |
+
<div class="opt" onclick="pickFile('image/gif,video/mp4','animation')"><i class="bi bi-film"></i> GIF</div>
|
| 369 |
+
<div class="opt" onclick="pickFile('*','document')"><i class="bi bi-file-earmark"></i> فایل</div>
|
| 370 |
+
</div>
|
| 371 |
+
</div>
|
| 372 |
+
<input type="file" id="fileIn" style="display:none">
|
| 373 |
+
<button class="icon-btn" id="emojiBtn" onclick="toggleEmojiPicker()"><i class="bi bi-emoji-smile"></i></button>
|
| 374 |
+
<button class="icon-btn" id="stickerBtn" onclick="toggleStickerPicker()"><i class="bi bi-stickies"></i></button>
|
| 375 |
+
<textarea id="msgIn" class="form-control" rows="1" placeholder="پیام..."></textarea>
|
| 376 |
+
<button class="icon-btn rec-btn" id="micBtn"><i class="bi bi-mic-fill"></i></button>
|
| 377 |
+
<button class="send-btn d-none" id="sendBtn" onclick="sendMsg()"><i class="bi bi-send-fill"></i></button>
|
| 378 |
+
</div>
|
| 379 |
+
<!-- sender selector (only when Business connection available) -->
|
| 380 |
+
<div id="senderSelector" style="display:none;padding:0 4px 4px;font-size:.78rem;color:var(--md-sys-color-on-surface-variant);display:none">
|
| 381 |
+
ارسال بهعنوان:
|
| 382 |
+
<label style="margin-right:10px"><input type="radio" name="sender" value="bot" checked> ربات</label>
|
| 383 |
+
<label><input type="radio" name="sender" value="me"> من</label>
|
| 384 |
+
</div>
|
| 385 |
+
</div>
|
| 386 |
+
</div>
|
| 387 |
+
</div>
|
| 388 |
+
</div>
|
| 389 |
+
|
| 390 |
+
<!-- chat AI settings panel -->
|
| 391 |
+
</div>
|
| 392 |
+
|
| 393 |
+
<!-- AI panel — a normal modal now (same size as the profile modal),
|
| 394 |
+
opened FROM the profile modal; closing it (X, backdrop, Escape, or
|
| 395 |
+
the back-arrow) returns to the profile modal instead of just
|
| 396 |
+
vanishing, matching how it was reached. -->
|
| 397 |
+
<div class="modal fade" id="chatSP" tabindex="-1">
|
| 398 |
+
<div class="modal-dialog modal-dialog-centered">
|
| 399 |
+
<div class="modal-content text-white">
|
| 400 |
+
<div class="modal-header border-secondary">
|
| 401 |
+
<button class="icon-btn me-2" onclick="bootstrap.Modal.getInstance(document.getElementById('chatSP')).hide()"><i class="bi bi-arrow-right"></i></button>
|
| 402 |
+
<h5 class="modal-title flex-grow-1"><i class="bi bi-robot"></i> تنظیمات AI این چت</h5>
|
| 403 |
+
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
|
| 404 |
+
</div>
|
| 405 |
+
<div class="modal-body d-flex flex-column gap-3">
|
| 406 |
+
<div class="d-flex align-items-center justify-content-between">
|
| 407 |
+
<div class="form-check form-switch fs-6 m-0">
|
| 408 |
+
<input class="form-check-input" type="checkbox" id="csAi" onchange="updateCsStatus()">
|
| 409 |
+
<label class="form-check-label" for="csAi">فعالسازی AI برای این چت</label>
|
| 410 |
+
</div>
|
| 411 |
+
<small id="csStatus" class="pa-sub"></small>
|
| 412 |
+
</div>
|
| 413 |
+
<div>
|
| 414 |
+
<label class="text-secondary small d-block mb-1">پرامپت اختصاصی (خالی = پیشفرض)</label>
|
| 415 |
+
<textarea id="csPrompt" class="form-control" rows="10" placeholder="دستورالعمل اختصاصی..."></textarea>
|
| 416 |
+
</div>
|
| 417 |
+
<button class="btn btn-primary" onclick="saveChatSettings()">ذخیره</button>
|
| 418 |
+
</div>
|
| 419 |
+
</div>
|
| 420 |
+
</div>
|
| 421 |
+
</div>
|
| 422 |
+
|
| 423 |
+
<!-- new chat modal -->
|
| 424 |
+
<div class="modal fade" id="newChatModal" tabindex="-1">
|
| 425 |
+
<div class="modal-dialog modal-dialog-centered">
|
| 426 |
+
<div class="modal-content text-white">
|
| 427 |
+
<div class="modal-header border-secondary">
|
| 428 |
+
<h5 class="modal-title"><i class="bi bi-person-plus"></i> چت جدید</h5>
|
| 429 |
+
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
|
| 430 |
+
</div>
|
| 431 |
+
<div class="modal-body">
|
| 432 |
+
<label class="form-label small text-secondary">آیدی / یوزرنیم</label>
|
| 433 |
+
<input type="text" id="ncId" class="form-control mb-3" placeholder="123456789 یا @username">
|
| 434 |
+
<label class="form-label small text-secondary">متن اولین پیام</label>
|
| 435 |
+
<textarea id="ncMsg" class="form-control" rows="3" placeholder="سلام..."></textarea>
|
| 436 |
+
</div>
|
| 437 |
+
<div class="modal-footer border-secondary">
|
| 438 |
+
<button class="btn btn-primary w-100" onclick="startNewChat()">ارسال و شروع چت</button>
|
| 439 |
+
</div>
|
| 440 |
+
</div>
|
| 441 |
+
</div>
|
| 442 |
+
</div>
|
| 443 |
+
|
| 444 |
+
<!-- profile modal -->
|
| 445 |
+
<div class="modal fade" id="profileModal" tabindex="-1">
|
| 446 |
+
<div class="modal-dialog modal-dialog-centered">
|
| 447 |
+
<div class="modal-content text-white">
|
| 448 |
+
<div class="modal-header border-secondary">
|
| 449 |
+
<h5 class="modal-title"><i class="bi bi-card-heading"></i> پروفایل</h5>
|
| 450 |
+
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
|
| 451 |
+
</div>
|
| 452 |
+
<div class="modal-body" id="profileBody">
|
| 453 |
+
<div class="py-4 text-center"><div class="spinner-border" style="color:var(--md-sys-color-primary)"></div></div>
|
| 454 |
+
</div>
|
| 455 |
+
<!-- actions moved here from the topbar -->
|
| 456 |
+
<div class="profile-actions" id="profileActions">
|
| 457 |
+
<button class="pa-btn" id="paPin" onclick="profileTogglePin()"><i class="bi bi-pin-angle"></i><span>پین گفتگو</span></button>
|
| 458 |
+
<button class="pa-btn" id="paMute" onclick="profileToggleMute()"><i class="bi bi-bell"></i><span>بیصدا کردن</span></button>
|
| 459 |
+
<button class="pa-btn" onclick="openChatSettingsFromProfile()"><i class="bi bi-robot"></i><span>پنل AI</span><small class="pa-sub" id="paAiStatus"></small></button>
|
| 460 |
+
<button class="pa-btn danger" onclick="deleteCurrentChat()"><i class="bi bi-trash3"></i><span>حذف گفتگو</span></button>
|
| 461 |
+
</div>
|
| 462 |
+
</div>
|
| 463 |
+
</div>
|
| 464 |
+
</div>
|
| 465 |
+
|
| 466 |
+
<!-- gmod modals -->
|
| 467 |
+
<!-- in-app photo/video lightbox — avoids window.open(), which on an
|
| 468 |
+
installed PWA navigates the whole app out to the system browser -->
|
| 469 |
+
<!-- Phase 4: message context menu — right-click (desktop) or
|
| 470 |
+
long-press (touch) on a bubble; built dynamically in chat.js -->
|
| 471 |
+
<div class="msg-ctx-menu" id="msgCtxMenu">
|
| 472 |
+
<div class="mcm-react" id="mcmReact"></div>
|
| 473 |
+
<div class="mcm-items" id="mcmItems"></div>
|
| 474 |
+
</div>
|
| 475 |
+
|
| 476 |
+
<!-- glass toast host (replaces every alert()) -->
|
| 477 |
+
<div class="toast-host" id="toastHost"></div>
|
| 478 |
+
|
| 479 |
+
<div class="modal fade" id="mediaViewerModal" tabindex="-1">
|
| 480 |
+
<div class="modal-dialog modal-dialog-centered modal-lg">
|
| 481 |
+
<div class="modal-content bg-transparent border-0">
|
| 482 |
+
<button type="button" class="btn-close btn-close-white ms-auto m-2" data-bs-dismiss="modal" style="position:absolute;top:0;left:0;z-index:5"></button>
|
| 483 |
+
<div class="modal-body p-0 d-flex align-items-center justify-content-center">
|
| 484 |
+
<img id="mvImg" class="d-none" style="max-width:100%;max-height:85vh;border-radius:var(--md-sys-shape-md)">
|
| 485 |
+
<video id="mvVideo" class="d-none" controls autoplay style="max-width:100%;max-height:85vh;border-radius:var(--md-sys-shape-md)"></video>
|
| 486 |
+
</div>
|
| 487 |
+
</div>
|
| 488 |
+
</div>
|
| 489 |
+
</div>
|
| 490 |
+
|
| 491 |
+
<div class="modal fade" id="gmodModal" tabindex="-1">
|
| 492 |
+
<div class="modal-dialog modal-dialog-centered">
|
| 493 |
+
<div class="modal-content text-white">
|
| 494 |
+
<div class="modal-header border-secondary">
|
| 495 |
+
<h5 class="modal-title" id="gmodModalTitle">عملیات گروه</h5>
|
| 496 |
+
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
|
| 497 |
+
</div>
|
| 498 |
+
<div class="modal-body" id="gmodModalBody"></div>
|
| 499 |
+
<div class="modal-footer border-secondary">
|
| 500 |
+
<button class="btn btn-secondary" data-bs-dismiss="modal">لغو</button>
|
| 501 |
+
<button class="btn btn-primary" id="gmodModalOk">تأیید</button>
|
| 502 |
+
</div>
|
| 503 |
+
</div>
|
| 504 |
+
</div>
|
| 505 |
+
</div>
|
| 506 |
+
|
| 507 |
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
| 508 |
+
<!-- animated (.tgs/Lottie) sticker support: pako un-gzips the raw file,
|
| 509 |
+
lottie-web renders the resulting JSON animation -->
|
| 510 |
+
<script src="https://cdn.jsdelivr.net/npm/pako@2.1.0/dist/pako.min.js"></script>
|
| 511 |
+
<script src="https://cdn.jsdelivr.net/npm/lottie-web@5.12.2/build/player/lottie.min.js"></script>
|
| 512 |
+
<!-- Renders emoji as consistent flat-design images instead of the
|
| 513 |
+
device's own emoji font (e.g. Samsung's), so everyone sees the
|
| 514 |
+
same emoji regardless of phone/OS. -->
|
| 515 |
+
<script src="https://cdn.jsdelivr.net/npm/twemoji@14.0.2/dist/twemoji.min.js"></script>
|
| 516 |
+
<!-- Phase 1: state + api + sidebar + chat-list, must load before the
|
| 517 |
+
remaining inline script below (chat/composer/settings/group-mod),
|
| 518 |
+
which still calls into them as plain globals. -->
|
| 519 |
+
<script src="/static/js/state.js"></script>
|
| 520 |
+
<script src="/static/js/api.js"></script>
|
| 521 |
+
<script src="/static/js/ripple.js"></script>
|
| 522 |
+
<script src="/static/js/ws.js"></script>
|
| 523 |
+
<script src="/static/js/sidebar.js"></script>
|
| 524 |
+
<script src="/static/js/chatlist.js"></script>
|
| 525 |
+
<script src="/static/js/chat.js"></script>
|
| 526 |
+
<script src="/static/js/composer.js"></script>
|
| 527 |
+
<script>
|
| 528 |
+
const QUICK_REACT = ["❤","👍","🔥","😁","😱","🤣"]; // top 6 most used
|
| 529 |
+
const ALL_REACT = ["❤","👍","👎","🔥","🥰","👏","😁","🤔","🤯","😱","🤬","😢","🎉","🤩","🤮","💩","🙏","👌","🕊","🤡","🥱","🥴","😍","🐳","❤🔥","🌚","🌭","💯","🤣","⚡","🍌","🏆","💔","🤨","😐","🍓","🍾","💋","🖕","😈","😴","😭","🤓","👻","👨💻","👀","🎃","🙈","😇","😨","🤝","✍","🤗","🫡","🎅","🎄","☃","💅","🤪","🗿","🆒","💘","🙉","🦄","😘","💊","🙊","😎","👾","🤷♂","🤷","🤷♀","😡"];
|
| 530 |
+
|
| 531 |
+
// Emoji picker data (categories)
|
| 532 |
+
// EMOJI_CATS/buildEmojiPicker/switchEmojiCat/renderEmojiCat/
|
| 533 |
+
// toggleEmojiPicker now live in static/js/composer.js (Phase 3).
|
| 534 |
+
|
| 535 |
+
window.onload=function(){applyEmojiImages(document.body);const ta=document.getElementById('msgIn');ta.addEventListener('keydown',e=>{if(e.key==='Enter'&&!e.shiftKey){e.preventDefault();sendMsg()}});ta.addEventListener('input',syncSendMic);document.getElementById('msgs').addEventListener('scroll',handleScroll);document.getElementById('attBtn').addEventListener('click',e=>{e.stopPropagation();document.getElementById('attMenu').classList.toggle('show')});document.getElementById('fileIn').addEventListener('change',onFilePick);document.getElementById('micBtn').addEventListener('click',toggleRec);document.addEventListener('click',e=>{if(!e.target.closest('.react-bar')&&!e.target.closest('.tbb'))document.querySelectorAll('.react-bar.show').forEach(p=>p.classList.remove('show'));if(!e.target.closest('#attMenu')&&!e.target.closest('#attBtn'))document.getElementById('attMenu').classList.remove('show');if(!e.target.closest('#emojiPicker')&&!e.target.closest('#emojiBtn')){emojiOpen=false;document.getElementById('emojiPicker').classList.remove('show')}if(!e.target.closest('#stickerPicker')&&!e.target.closest('#stickerBtn')){stickerOpen=false;document.getElementById('stickerPicker').classList.remove('show')}})}
|
| 536 |
+
|
| 537 |
+
function notify(){try{const A=window.AudioContext||window.webkitAudioContext;if(!A)return;const c=new A(),o=c.createOscillator(),g=c.createGain();o.type='sine';o.frequency.setValueAtTime(587.33,c.currentTime);o.frequency.exponentialRampToValueAtTime(880,c.currentTime+.12);g.gain.setValueAtTime(.15,c.currentTime);g.gain.exponentialRampToValueAtTime(.001,c.currentTime+.28);o.connect(g);g.connect(c.destination);o.start();o.stop(c.currentTime+.28)}catch(e){}}
|
| 538 |
+
function atBot(){const m=document.getElementById('msgs');return(m.scrollHeight-m.scrollTop-m.clientHeight)<70}
|
| 539 |
+
// Always instant — no "smooth" option anymore. A smooth/animated
|
| 540 |
+
// jump to the bottom (especially on a long chat, where media still
|
| 541 |
+
// loading shifts the layout underneath it) is exactly the "scrolling
|
| 542 |
+
// in from way above, stuttering midway" effect that was reported;
|
| 543 |
+
// real Telegram just jumps straight there.
|
| 544 |
+
function scrollBot(){const m=document.getElementById('msgs');m.scrollTop=m.scrollHeight;unreadCnt=0;updUBadge();document.getElementById('scrollBtn').classList.add('d-none')}
|
| 545 |
+
function handleScroll(){const b=document.getElementById('scrollBtn');if(atBot()){b.classList.add('d-none');unreadCnt=0;updUBadge()}else b.classList.remove('d-none');const m=document.getElementById('msgs');if(m.scrollTop<120&&hasMoreOlder&&oldestLoadedId)loadOlderMessages()}
|
| 546 |
+
function updUBadge(){const u=document.getElementById('ubadge');if(unreadCnt>0){u.innerText=unreadCnt>99?'99+':unreadCnt;u.classList.remove('d-none')}else u.classList.add('d-none')}
|
| 547 |
+
function updGlobalUnread(){let t=0;Object.values(unreadPer).forEach(v=>t+=v);document.title=t>0?`(${t}) Telegram Web Admin`:'Telegram Web Admin'}
|
| 548 |
+
// Phase 6: settings is now a real list→sub-page stack, wired into the
|
| 549 |
+
// same back-stack as everything else (pushUiState/applyUiState/
|
| 550 |
+
// goBackOneLevel, defined in chat.js) so the device back button steps
|
| 551 |
+
// out of a sub-page first, then out of the settings list, instead of
|
| 552 |
+
// either doing nothing or leaving settings in one jump.
|
| 553 |
+
const SP_SUBS=['spAi','spPanel','spBot','spAbout','spUsers','spDevices'];
|
| 554 |
+
function showSettingsMain(){
|
| 555 |
+
document.getElementById('spMain').style.display='flex';
|
| 556 |
+
SP_SUBS.forEach(id=>document.getElementById(id).style.display='none');
|
| 557 |
+
}
|
| 558 |
+
function showSettingsSub(name){
|
| 559 |
+
const id='sp'+name.charAt(0).toUpperCase()+name.slice(1);
|
| 560 |
+
document.getElementById('spMain').style.display='none';
|
| 561 |
+
SP_SUBS.forEach(x=>document.getElementById(x).style.display=(x===id?'flex':'none'));
|
| 562 |
+
if(name==='about')refreshAboutPage();
|
| 563 |
+
if(name==='users')loadUsers();
|
| 564 |
+
if(name==='devices')loadDevices();
|
| 565 |
+
if(name==='bot')loadBotProfile();
|
| 566 |
+
}
|
| 567 |
+
function openSettings(){
|
| 568 |
+
pushUiState({level:'settings'});
|
| 569 |
+
document.getElementById('settingsPage').classList.add('show');
|
| 570 |
+
showSettingsMain();
|
| 571 |
+
refreshAiSummary();
|
| 572 |
+
}
|
| 573 |
+
function closeSettings(){document.getElementById('settingsPage').classList.remove('show')}
|
| 574 |
+
function openSettingsSub(name){
|
| 575 |
+
pushUiState({level:'settings-sub',sub:name});
|
| 576 |
+
showSettingsSub(name);
|
| 577 |
+
}
|
| 578 |
+
async function refreshAiSummary(){
|
| 579 |
+
const r=await apiFetch('/api/settings');
|
| 580 |
+
const el=document.getElementById('spAiSummary');
|
| 581 |
+
if(el&&r)el.textContent=r.ai_mode?'فعال':'غیرفعال';
|
| 582 |
+
}
|
| 583 |
+
async function refreshAboutPage(){
|
| 584 |
+
const r=await apiFetch('/api/settings');
|
| 585 |
+
if(!r)return;
|
| 586 |
+
document.getElementById('spAboutModel').textContent=r.gemini_model||'—';
|
| 587 |
+
document.getElementById('spAboutAiState').textContent=r.ai_mode?'فعال':'غیرفعال';
|
| 588 |
+
}
|
| 589 |
+
|
| 590 |
+
|
| 591 |
+
// Real accounts now: login() exchanges username+password for a SESSION
|
| 592 |
+
// TOKEN (POST /api/login) and PASS holds that token from then on — every
|
| 593 |
+
// other request/media URL already sends PASS, so nothing else changed.
|
| 594 |
+
// With no fields filled (page reload) it just re-validates the stored token.
|
| 595 |
+
function showAuthMode(mode){
|
| 596 |
+
document.getElementById('authLogin').classList.toggle('d-none',mode!=='login');
|
| 597 |
+
document.getElementById('authForgot').classList.toggle('d-none',mode!=='forgot');
|
| 598 |
+
document.getElementById('authForce').classList.toggle('d-none',mode!=='force');
|
| 599 |
+
}
|
| 600 |
+
// What this browser is, for the "signed-in devices" list (the user can rename it there).
|
| 601 |
+
function deviceInfo(){
|
| 602 |
+
const ua=navigator.userAgent;
|
| 603 |
+
const br=/Edg\//.test(ua)?'Edge':/OPR\//.test(ua)?'Opera':/SamsungBrowser/.test(ua)?'Samsung Internet':/Firefox\//.test(ua)?'Firefox':/Chrome\//.test(ua)?'Chrome':/Safari\//.test(ua)?'Safari':'مرورگر';
|
| 604 |
+
const os=/Windows/.test(ua)?'Windows':/Android/.test(ua)?'Android':/iPhone|iPad|iPod/.test(ua)?'iOS':/Mac OS X/.test(ua)?'macOS':/Linux/.test(ua)?'Linux':'';
|
| 605 |
+
const pwa=matchMedia('(display-mode: standalone)').matches||navigator.standalone===true;
|
| 606 |
+
return{deviceName:br+(os?' · '+os:''),platform:pwa?'pwa':'web'};
|
| 607 |
+
}
|
| 608 |
+
// Start-up splash: visible from the very first paint when a session is stored (html.has-session);
|
| 609 |
+
// fades out once the app is ready, or is replaced by the sign-in form if the session turns out invalid.
|
| 610 |
+
function endSplash(showAuth){
|
| 611 |
+
const s=document.getElementById('splash');
|
| 612 |
+
if(showAuth){document.documentElement.classList.remove('has-session');document.getElementById('authBox').classList.remove('d-none')}
|
| 613 |
+
if(!s)return;
|
| 614 |
+
s.classList.add('leaving');
|
| 615 |
+
setTimeout(()=>{s.remove();if(!showAuth)document.documentElement.classList.remove('has-session')},260);
|
| 616 |
+
}
|
| 617 |
+
let _loginBusy=false;
|
| 618 |
+
async function login(){
|
| 619 |
+
if(_loginBusy)return;
|
| 620 |
+
_loginBusy=true;
|
| 621 |
+
try{await doLogin()}finally{_loginBusy=false}
|
| 622 |
+
}
|
| 623 |
+
async function doLogin(){
|
| 624 |
+
const u=document.getElementById('userInput').value.trim();
|
| 625 |
+
const p=document.getElementById('passInput').value;
|
| 626 |
+
document.getElementById('authSuspended').classList.add('d-none');
|
| 627 |
+
if(p){
|
| 628 |
+
let res;
|
| 629 |
+
try{res=await fetch('/api/login',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({username:u,password:p,...deviceInfo()})})}
|
| 630 |
+
catch(e){showToast('اتصال به سرور برقرار نشد','error');return}
|
| 631 |
+
const d=await res.json().catch(()=>({}));
|
| 632 |
+
if(!res.ok){
|
| 633 |
+
if(d.suspended)document.getElementById('authSuspended').classList.remove('d-none');
|
| 634 |
+
else showToast(d.error||'ورود ناموفق بود','error');
|
| 635 |
+
return;
|
| 636 |
+
}
|
| 637 |
+
PASS=d.token;
|
| 638 |
+
if(d.must_change){ // logged in with a one-time recovery password
|
| 639 |
+
document.getElementById('passInput').value='';showAuthMode('force');return;
|
| 640 |
+
}
|
| 641 |
+
localStorage.setItem('TG_IS_OWNER',d.is_owner?'1':'');
|
| 642 |
+
}
|
| 643 |
+
const r=await apiFetch('/api/settings');
|
| 644 |
+
if(r===null){
|
| 645 |
+
// network problem, NOT a rejected session: a stored login must survive being offline
|
| 646 |
+
if(!p){document.getElementById('splashText').textContent='منتظر اتصال به شبکه…';setTimeout(login,2500)}
|
| 647 |
+
else showToast('اتصال به سرور برقرار نشد','error');
|
| 648 |
+
return;
|
| 649 |
+
}
|
| 650 |
+
if(r&&!r.error){
|
| 651 |
+
localStorage.setItem('TG_PASS',PASS);
|
| 652 |
+
document.getElementById('authBox').classList.add('d-none');
|
| 653 |
+
document.getElementById('mainApp').classList.remove('d-none');
|
| 654 |
+
const isOwner=!!localStorage.getItem('TG_IS_OWNER');
|
| 655 |
+
document.querySelectorAll('.owner-only').forEach(el=>el.classList.toggle('d-none',!isOwner));
|
| 656 |
+
document.querySelectorAll('.tenant-only').forEach(el=>el.classList.toggle('d-none',isOwner));
|
| 657 |
+
// every account's own settings fill the form — a form left blank would
|
| 658 |
+
// wipe the saved values (including the Telegram id) on the next save
|
| 659 |
+
document.getElementById('gAiToggle').checked=r.ai_mode;document.getElementById('gPrompt').value=r.system_prompt||'';
|
| 660 |
+
document.getElementById('gPoll').value=r.poll_interval||3000;document.getElementById('gModel').value=r.gemini_model||'gemini-2.5-flash';
|
| 661 |
+
document.getElementById('gDelay').value=r.batch_delay_seconds||28;document.getElementById('gOwnerId').value=r.owner_user_id||'';
|
| 662 |
+
document.getElementById('gStickerPacks').value=r.sticker_packs||'';
|
| 663 |
+
document.getElementById('gAdminGroup').value=r.admin_group_id||'';
|
| 664 |
+
const gk=document.getElementById('gGeminiKey');gk.value='';
|
| 665 |
+
gk.placeholder=r.has_gemini_api_key?'•••••• (ذخیرهشده — خالی = بدون تغییر)':'کلید از aistudio.google.com/apikey';
|
| 666 |
+
document.getElementById('gGeminiHint').textContent=isOwner
|
| 667 |
+
?'خالی = از کلید مشترک سرور (GEMINI_API_KEY) استفاده میشود.'
|
| 668 |
+
:'هر حساب کلید خودش را دارد؛ بدون کلید، هوش مصنوعی برای این حساب پاسخی نمیدهد.';
|
| 669 |
+
pollMs=r.poll_interval||3000;syncSendMic();startPoller();
|
| 670 |
+
endSplash(false);
|
| 671 |
+
}else{
|
| 672 |
+
localStorage.removeItem('TG_PASS');localStorage.removeItem('TG_IS_OWNER');PASS='';
|
| 673 |
+
endSplash(true);
|
| 674 |
+
if(p)showToast('ورود ناموفق بود','error');
|
| 675 |
+
}
|
| 676 |
+
}
|
| 677 |
+
window.addEventListener('online',()=>{if(document.getElementById('splash')&&PASS)login()});
|
| 678 |
+
async function submitForcedChange(){
|
| 679 |
+
const a=document.getElementById('forceNew1').value,b=document.getElementById('forceNew2').value;
|
| 680 |
+
if(a.length<6){showToast('رمز باید حداقل ۶ کاراکتر باشد','warn');return}
|
| 681 |
+
if(a!==b){showToast('تکرار رمز با رمز جدید یکی نیست','warn');return}
|
| 682 |
+
const res=await fetch('/api/change-password',{method:'POST',headers:{'Content-Type':'application/json',Authorization:PASS},body:JSON.stringify({newPassword:a})});
|
| 683 |
+
const d=await res.json().catch(()=>({}));
|
| 684 |
+
if(!res.ok){showToast(d.error||'خطا','error');return}
|
| 685 |
+
PASS=d.token;localStorage.setItem('TG_IS_OWNER','');
|
| 686 |
+
document.getElementById('forceNew1').value='';document.getElementById('forceNew2').value='';
|
| 687 |
+
showToast('رمز جدید ذخیره شد','success');
|
| 688 |
+
await login();
|
| 689 |
+
}
|
| 690 |
+
// voluntary change from Settings (needs the current password)
|
| 691 |
+
function changePasswordDialog(){
|
| 692 |
+
openGmodModal('تغییر رمز عبور',
|
| 693 |
+
`<input id="cpOld" type="password" class="form-control mb-2" placeholder="رمز فعلی" autocomplete="current-password"><input id="cpNew" type="password" class="form-control" placeholder="رمز جدید (حداقل ۶ کاراکتر)" autocomplete="new-password"><div class="text-secondary mt-2" style="font-size:.78rem">بعد از تغییر، از بقیهی دستگاهها خارج میشوی.</div>`,
|
| 694 |
+
async()=>{
|
| 695 |
+
const res=await fetch('/api/change-password',{method:'POST',headers:{'Content-Type':'application/json',Authorization:PASS},body:JSON.stringify({currentPassword:document.getElementById('cpOld').value,newPassword:document.getElementById('cpNew').value})});
|
| 696 |
+
const d=await res.json().catch(()=>({}));
|
| 697 |
+
if(!res.ok){showToast(d.error||'خطا','error',4000);return}
|
| 698 |
+
PASS=d.token;localStorage.setItem('TG_PASS',PASS);closeGmod();showToast('رمز عبور تغییر کرد','success');
|
| 699 |
+
});
|
| 700 |
+
}
|
| 701 |
+
async function clearGeminiKey(){
|
| 702 |
+
if(!confirm('کلید Gemini این حساب حذف شود؟'))return;
|
| 703 |
+
const res=await apiFetch('/api/settings',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({clear_gemini_api_key:true})});
|
| 704 |
+
if(res&&res.success){document.getElementById('gGeminiKey').placeholder='کلید از aistudio.google.com/apikey';showToast('کلید حذف شد','success')}else showToast(res?.error||'خطا','error');
|
| 705 |
+
}
|
| 706 |
+
async function testAdminGroup(){
|
| 707 |
+
await adminCall('POST','/api/admin-group/test',{groupId:document.getElementById('gAdminGroup').value.trim()});
|
| 708 |
+
}
|
| 709 |
+
|
| 710 |
+
// ---------- bot profile: show current, change photo ----------
|
| 711 |
+
let botProfileOrig={};
|
| 712 |
+
async function loadBotProfile(){
|
| 713 |
+
const p=await apiFetch('/api/bot-profile');
|
| 714 |
+
const warn=document.getElementById('bpNoBot');
|
| 715 |
+
if(!p||p.error&&!p.connected&&p.connected!==false){warn.textContent='بارگذاری نشد';warn.classList.remove('d-none');return}
|
| 716 |
+
if(!p.connected){
|
| 717 |
+
warn.textContent=p.error||'برای این حساب هنوز رباتی متصل نشده است.';warn.classList.remove('d-none');
|
| 718 |
+
document.getElementById('bpName').textContent='—';document.getElementById('bpUser').textContent='';document.getElementById('bpId').textContent='';
|
| 719 |
+
botProfileOrig={};return;
|
| 720 |
+
}
|
| 721 |
+
warn.classList.add('d-none');
|
| 722 |
+
botProfileOrig={name:p.name||'',short_description:p.short_description||'',description:p.description||''};
|
| 723 |
+
document.getElementById('bpName').textContent=p.name||'';
|
| 724 |
+
document.getElementById('bpUser').textContent='@'+p.username;
|
| 725 |
+
document.getElementById('bpId').textContent='ID: '+p.id;
|
| 726 |
+
document.getElementById('bName').value=botProfileOrig.name;
|
| 727 |
+
document.getElementById('bShort').value=botProfileOrig.short_description;
|
| 728 |
+
document.getElementById('bDesc').value=botProfileOrig.description;
|
| 729 |
+
const img=document.getElementById('bpPhoto'),fb=document.getElementById('bpPhotoFallback');
|
| 730 |
+
img.classList.add('d-none');fb.classList.remove('d-none');
|
| 731 |
+
img.onload=()=>{img.classList.remove('d-none');fb.classList.add('d-none')};
|
| 732 |
+
img.onerror=()=>{img.classList.add('d-none');fb.classList.remove('d-none')};
|
| 733 |
+
img.src=`/api/user-photo?id=${p.id}&auth=${encodeURIComponent(PASS)}&t=${Date.now()}`;
|
| 734 |
+
}
|
| 735 |
+
// any picture → centered square JPEG (Telegram wants a static JPG) before upload
|
| 736 |
+
function toSquareJpeg(file,size=640){
|
| 737 |
+
return new Promise((resolve,reject)=>{
|
| 738 |
+
const img=new Image(),url=URL.createObjectURL(file);
|
| 739 |
+
img.onload=()=>{
|
| 740 |
+
const s=Math.min(img.width,img.height),cv=document.createElement('canvas');cv.width=cv.height=size;
|
| 741 |
+
cv.getContext('2d').drawImage(img,(img.width-s)/2,(img.height-s)/2,s,s,0,0,size,size);
|
| 742 |
+
URL.revokeObjectURL(url);cv.toBlob(b=>b?resolve(b):reject(new Error('convert')),'image/jpeg',0.9);
|
| 743 |
+
};
|
| 744 |
+
img.onerror=()=>{URL.revokeObjectURL(url);reject(new Error('load'))};
|
| 745 |
+
img.src=url;
|
| 746 |
+
});
|
| 747 |
+
}
|
| 748 |
+
async function uploadBotPhoto(input){
|
| 749 |
+
const f=input.files[0];input.value='';
|
| 750 |
+
if(!f)return;
|
| 751 |
+
let blob;
|
| 752 |
+
try{blob=await toSquareJpeg(f)}catch(e){showToast('این فایل عکس قابلخواندن نیست','error');return}
|
| 753 |
+
const fd=new FormData();fd.append('file',blob,'photo.jpg');
|
| 754 |
+
const res=await fetch('/api/bot-profile/photo',{method:'POST',headers:{Authorization:PASS},body:fd});
|
| 755 |
+
const d=await res.json().catch(()=>({}));
|
| 756 |
+
showToast(res.ok?(d.message||'انجام شد'):(d.error||'خطا'),res.ok?'success':'error',res.ok?2000:7000);
|
| 757 |
+
if(res.ok)loadBotProfile();
|
| 758 |
+
}
|
| 759 |
+
async function removeBotPhoto(){
|
| 760 |
+
if(!confirm('عکس ربات حذف شود؟'))return;
|
| 761 |
+
if(await adminCall('DELETE','/api/bot-profile/photo'))loadBotProfile();
|
| 762 |
+
}
|
| 763 |
+
|
| 764 |
+
// ---------- owner: user management GUI ----------
|
| 765 |
+
function genPass(){
|
| 766 |
+
const a='abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789',b=new Uint32Array(12);
|
| 767 |
+
crypto.getRandomValues(b);return Array.from(b,x=>a[x%a.length]).join('');
|
| 768 |
+
}
|
| 769 |
+
async function adminCall(method,path,body){
|
| 770 |
+
const res=await fetch(path,{method,headers:{'Content-Type':'application/json',Authorization:PASS},body:body?JSON.stringify(body):undefined});
|
| 771 |
+
const d=await res.json().catch(()=>({}));
|
| 772 |
+
showToast(res.ok?(d.message||'انجام شد'):(d.error||'خطا'),res.ok?'success':'error',res.ok?2000:7000);
|
| 773 |
+
return res.ok;
|
| 774 |
+
}
|
| 775 |
+
// ---- signed-in devices (GET/PATCH/DELETE /api/sessions) ----
|
| 776 |
+
const DEV_PLAT={web:{icon:'bi-globe',label:'نسخه وب'},pwa:{icon:'bi-install',label:'وباپ نصبشده'},android:{icon:'bi-android2',label:'اپ اندروید'},windows:{icon:'bi-windows',label:'اپ ویندوز'}};
|
| 777 |
+
// "5 minutes ago" in Persian. last_seen is stamped about every 5 minutes, so anything fresher than 10 is just "recently active".
|
| 778 |
+
function agoLabel(ts){
|
| 779 |
+
if(!ts)return 'نامشخص';
|
| 780 |
+
const s=(Date.now()-ts)/1000;
|
| 781 |
+
if(s<600)return 'اخیراً فعال';
|
| 782 |
+
const rtf=new Intl.RelativeTimeFormat('fa',{numeric:'auto'});
|
| 783 |
+
if(s<3600)return rtf.format(-Math.round(s/60),'minute');
|
| 784 |
+
if(s<86400)return rtf.format(-Math.round(s/3600),'hour');
|
| 785 |
+
return rtf.format(-Math.round(s/86400),'day');
|
| 786 |
+
}
|
| 787 |
+
async function loadDevices(){
|
| 788 |
+
const host=document.getElementById('devList');
|
| 789 |
+
const r=await apiFetch('/api/sessions');
|
| 790 |
+
if(!Array.isArray(r)){host.innerHTML='<div class="pm-empty">بارگذاری نشد</div>';return}
|
| 791 |
+
host.replaceChildren(...r.map(deviceCard));
|
| 792 |
+
}
|
| 793 |
+
function deviceCard(s){
|
| 794 |
+
const dv=s.device||{},pl=DEV_PLAT[dv.platform]||{icon:'bi-devices',label:'دستگاه ناشناس'};
|
| 795 |
+
const card=document.createElement('div');card.className='dev-card'+(s.current?' current':'');
|
| 796 |
+
const ic=document.createElement('i');ic.className='bi '+pl.icon+' dev-ic';
|
| 797 |
+
const info=document.createElement('div');info.className='dev-info';
|
| 798 |
+
const nm=document.createElement('div');nm.className='dev-name';
|
| 799 |
+
const nmText=document.createElement('span');nmText.textContent=dv.name||pl.label;nm.appendChild(nmText);
|
| 800 |
+
if(s.current){const b=document.createElement('span');b.className='dev-chip';b.textContent='این دستگاه';nm.appendChild(b)}
|
| 801 |
+
const sub=document.createElement('div');sub.className='dev-sub';
|
| 802 |
+
const when=s.created?new Date(s.created).toLocaleString('fa-IR',{dateStyle:'medium',timeStyle:'short'}):'';
|
| 803 |
+
sub.textContent=[pl.label+(dv.app?' '+dv.app:''),'آخرین فعالیت: '+(s.current?'هماکنون':agoLabel(s.last_seen||s.created)),when&&'ورود: '+when].filter(Boolean).join(' · ');
|
| 804 |
+
info.append(nm,sub);
|
| 805 |
+
const acts=document.createElement('div');acts.className='dev-acts';
|
| 806 |
+
const ren=document.createElement('button');ren.className='icon-btn';ren.title='تغییر نام';ren.innerHTML='<i class="bi bi-pencil"></i>';
|
| 807 |
+
ren.onclick=()=>renameDevice(s,dv.name||'');
|
| 808 |
+
const out=document.createElement('button');out.className='icon-btn dev-kick';out.title=s.current?'خروج از این دستگاه':'خارج کردن این دستگاه';out.innerHTML='<i class="bi bi-box-arrow-right"></i>';
|
| 809 |
+
out.onclick=()=>kickDevice(s,dv.name||pl.label);
|
| 810 |
+
acts.append(ren,out);
|
| 811 |
+
card.append(ic,info,acts);
|
| 812 |
+
return card;
|
| 813 |
+
}
|
| 814 |
+
function renameDevice(s,cur){
|
| 815 |
+
openGmodModal('تغییر نام دستگاه','<input id="devName" class="form-control" maxlength="60" placeholder="مثلاً لپتاپ کار">',async()=>{
|
| 816 |
+
const name=document.getElementById('devName').value.trim();
|
| 817 |
+
if(!name){showToast('نام را وارد کن','warn');return}
|
| 818 |
+
const r=await apiFetch('/api/sessions/'+encodeURIComponent(s.id),{method:'PATCH',headers:{'Content-Type':'application/json'},body:JSON.stringify({name})});
|
| 819 |
+
if(r&&r.success){closeGmod();showToast('نام تغییر کرد','success');loadDevices()}else showToast((r&&r.error)||'تغییر نام انجام نشد','error');
|
| 820 |
+
});
|
| 821 |
+
const inp=document.getElementById('devName');inp.value=cur;setTimeout(()=>{inp.focus();inp.select()},350);
|
| 822 |
+
inp.addEventListener('keydown',e=>{if(e.key==='Enter')document.getElementById('gmodModalOk').click()});
|
| 823 |
+
}
|
| 824 |
+
function kickDevice(s,label){
|
| 825 |
+
const me=!!s.current;
|
| 826 |
+
openGmodModal(me?'خروج از این دستگاه':'خارج کردن دستگاه','<p class="mb-0" id="devKickMsg"></p>',async()=>{
|
| 827 |
+
if(me){closeGmod();logout();return}
|
| 828 |
+
const r=await apiFetch('/api/sessions/'+encodeURIComponent(s.id),{method:'DELETE'});
|
| 829 |
+
if(r&&r.success){closeGmod();showToast('دستگاه خارج شد','success');loadDevices()}else showToast('انجام نشد','error');
|
| 830 |
+
});
|
| 831 |
+
document.getElementById('devKickMsg').textContent=me?'از این دستگاه خارج میشوی و برای ورود دوباره باید رمز را وارد کنی.':'«'+label+'» از حساب خارج میشود و برای ورود دوباره باید رمز را وارد کند.';
|
| 832 |
+
}
|
| 833 |
+
async function loadUsers(){
|
| 834 |
+
const host=document.getElementById('uList');
|
| 835 |
+
const r=await apiFetch('/api/admin/users');
|
| 836 |
+
host.innerHTML='';
|
| 837 |
+
if(!r||r.error){host.innerHTML='<div class="pm-empty">بارگذاری نشد</div>';return}
|
| 838 |
+
document.getElementById('uBaseWarn').classList.toggle('d-none',!!r.public_base_url_set);
|
| 839 |
+
if(!r.users.length){host.innerHTML='<div class="pm-empty">هنوز کاربری ساخته نشده</div>';return}
|
| 840 |
+
r.users.forEach(u=>host.appendChild(userCard(u)));
|
| 841 |
+
}
|
| 842 |
+
function userCard(u){
|
| 843 |
+
const card=document.createElement('div');card.className='u-card';
|
| 844 |
+
const head=document.createElement('div');head.className='u-head';
|
| 845 |
+
const name=document.createElement('span');name.className='u-name';name.textContent=u.username;
|
| 846 |
+
const badge=document.createElement('span');badge.className='u-badge '+(u.suspended?'off':'on');badge.textContent=u.suspended?'تعلیقشده':'فعال';
|
| 847 |
+
head.append(name,badge);
|
| 848 |
+
const meta=document.createElement('div');meta.className='u-meta';
|
| 849 |
+
const bot=document.createElement('div');
|
| 850 |
+
bot.textContent=u.has_bot?'🤖 @'+u.bot_username:'⚪️ ربات وصل نشده';
|
| 851 |
+
const mail=document.createElement('div');mail.textContent=u.telegram_id?'🆔 '+u.telegram_id+(u.recovery_ready?'':' (ربات وصل نیست؛ بازیابی رمز کار نمیکند)'):'⚠️ آیدی تلگرام ثبت نشده (بازیابی رمز کار نمیکند)';
|
| 852 |
+
meta.append(bot,mail);
|
| 853 |
+
const acts=document.createElement('div');acts.className='u-actions';
|
| 854 |
+
const mk=(icon,label,fn,cls)=>{const b=document.createElement('button');b.className='u-btn'+(cls?' '+cls:'');b.innerHTML=`<i class="bi ${icon}"></i> ${label}`;b.onclick=fn;return b};
|
| 855 |
+
acts.append(
|
| 856 |
+
mk('bi-robot',u.has_bot?'تغییر ربات':'اتصال ربات',()=>userDialog('bot',u),u.has_bot?'':'primary'),
|
| 857 |
+
mk('bi-key','رمز جدید',()=>userDialog('password',u)),
|
| 858 |
+
mk('bi-telegram','آیدی تلگرام',()=>userDialog('telegram',u)),
|
| 859 |
+
mk(u.suspended?'bi-play-circle':'bi-pause-circle',u.suspended?'رفع تعلیق':'تعلیق',async()=>{
|
| 860 |
+
if(await adminCall('POST',`/api/admin/users/${encodeURIComponent(u.username)}/suspend`,{suspended:!u.suspended}))loadUsers();
|
| 861 |
+
},u.suspended?'':'warn'),
|
| 862 |
+
mk('bi-trash3','حذف',()=>userDialog('delete',u),'danger')
|
| 863 |
+
);
|
| 864 |
+
card.append(head,meta,acts);return card;
|
| 865 |
+
}
|
| 866 |
+
// Bootstrap silently ignores hide() while the modal is still mid fade-in
|
| 867 |
+
// (first ~300ms); if a save finishes in that window the dialog would stay
|
| 868 |
+
// open forever, so check again once the transition is over.
|
| 869 |
+
function closeGmod(){
|
| 870 |
+
const el=document.getElementById('gmodModal'),inst=bootstrap.Modal.getInstance(el);
|
| 871 |
+
if(!inst)return;
|
| 872 |
+
inst.hide();
|
| 873 |
+
setTimeout(()=>{if(el.classList.contains('show'))inst.hide()},450);
|
| 874 |
+
}
|
| 875 |
+
function userDialog(kind,u){
|
| 876 |
+
const base=`/api/admin/users/${encodeURIComponent(u.username)}`;
|
| 877 |
+
const done=async(ok)=>{if(ok){closeGmod();loadUsers()}};
|
| 878 |
+
const val=id=>document.getElementById(id).value.trim();
|
| 879 |
+
if(kind==='password')openGmodModal('رمز جدید برای «'+u.username+'»',
|
| 880 |
+
`<div class="d-flex gap-2"><input id="dlgPass" class="form-control" placeholder="رمز جدید" autocomplete="new-password"><button class="btn btn-outline-secondary" type="button" onclick="document.getElementById('dlgPass').value=genPass()"><i class="bi bi-magic"></i></button></div><div class="text-secondary mt-2" style="font-size:.78rem">رمز بعد از ذخیره قابل مشاهده نیست؛ همینجا کپیاش کن و به کاربر بده. کاربر از همهی دستگاهها خارج میشود.</div>`,
|
| 881 |
+
async()=>done(await adminCall('POST',base+'/password',{password:document.getElementById('dlgPass').value})));
|
| 882 |
+
else if(kind==='telegram')openGmodModal('آیدی تلگرام «'+u.username+'»',
|
| 883 |
+
`<input id="dlgTg" class="form-control" placeholder="مثلاً 123456789" inputmode="numeric" autocomplete="off" value="${u.telegram_id||''}"><div class="text-secondary mt-2" style="font-size:.78rem">آیدی عددی خودِ صاحب حساب (از @userinfobot). رمز موقت بازیابی به همین آیدی، از طریق ربات خودش، فرستاده میشود.</div>`,
|
| 884 |
+
async()=>done(await adminCall('POST',base+'/telegram-id',{telegramId:val('dlgTg')})));
|
| 885 |
+
else if(kind==='bot')openGmodModal('ربات «'+u.username+'»',
|
| 886 |
+
`<input id="dlgToken" class="form-control" placeholder="توکن BotFather" autocomplete="off"><div class="text-secondary mt-2" style="font-size:.78rem">توکن فقط برای ثبت webhook استفاده میشود و در تاریخچهی چتها نمیماند.</div>`,
|
| 887 |
+
async()=>done(await adminCall('POST',base+'/bot',{token:val('dlgToken')})));
|
| 888 |
+
else if(kind==='delete')openGmodModal('حذف «'+u.username+'»',
|
| 889 |
+
`<div class="alert alert-danger py-2" style="font-size:.82rem">حساب، ربات متصل (webhook) و <b>تمام چتها و تنظیمات</b> این کاربر برای همیشه پاک میشود. برای فقط قطع دسترسی از «تعلیق» استفاده کن.</div><input id="dlgConfirm" class="form-control" placeholder="برای تأیید، یوزرنیم را تایپ کن" autocomplete="off">`,
|
| 890 |
+
async()=>{
|
| 891 |
+
if(val('dlgConfirm')!==u.username){showToast('یوزرنیم تأیید درست نیست','warn');return}
|
| 892 |
+
done(await adminCall('DELETE',base));
|
| 893 |
+
});
|
| 894 |
+
}
|
| 895 |
+
async function createUser(){
|
| 896 |
+
const body={username:document.getElementById('uName').value.trim(),password:document.getElementById('uPass').value,telegramId:document.getElementById('uTgId').value.trim()};
|
| 897 |
+
if(await adminCall('POST','/api/admin/users',body)){
|
| 898 |
+
['uName','uPass','uTgId'].forEach(id=>document.getElementById(id).value='');
|
| 899 |
+
loadUsers();
|
| 900 |
+
}
|
| 901 |
+
}
|
| 902 |
+
async function logout(){
|
| 903 |
+
try{await fetch('/api/logout',{method:'POST',headers:{Authorization:PASS}})}catch(e){}
|
| 904 |
+
localStorage.removeItem('TG_PASS');localStorage.removeItem('TG_IS_OWNER');PASS='';location.reload();
|
| 905 |
+
}
|
| 906 |
+
async function requestReset(){
|
| 907 |
+
const username=document.getElementById('forgotUser').value.trim();
|
| 908 |
+
if(!username){showToast('یوزرنیم را وارد کن','warn');return}
|
| 909 |
+
const res=await fetch('/api/request-password-reset',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({username})});
|
| 910 |
+
const d=await res.json().catch(()=>({}));
|
| 911 |
+
showToast(d.message||'درخواست ثبت شد','success',4000);
|
| 912 |
+
showAuthMode('login');
|
| 913 |
+
}
|
| 914 |
+
async function saveAllSettings(){
|
| 915 |
+
const v=id=>document.getElementById(id).value;
|
| 916 |
+
const body={
|
| 917 |
+
ai_mode:document.getElementById('gAiToggle').checked,system_prompt:v('gPrompt'),
|
| 918 |
+
poll_interval:parseInt(v('gPoll'))||3000,gemini_model:v('gModel').trim()||'gemini-2.5-flash',
|
| 919 |
+
batch_delay_seconds:parseFloat(v('gDelay'))||28,owner_user_id:v('gOwnerId').trim(),
|
| 920 |
+
sticker_packs:v('gStickerPacks').trim(),admin_group_id:v('gAdminGroup').trim(),
|
| 921 |
+
};
|
| 922 |
+
const key=v('gGeminiKey').trim();if(key)body.gemini_api_key=key; // blank = keep the stored one
|
| 923 |
+
const res=await apiFetch('/api/settings',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(body)});
|
| 924 |
+
if(!(res&&res.success)){showToast(res?.error||'خطا در ذخیره','error',5000);return}
|
| 925 |
+
pollMs=body.poll_interval;startPoller();
|
| 926 |
+
if(key)document.getElementById('gGeminiKey').value='';
|
| 927 |
+
// bot profile: only send what actually changed (Telegram rate-limits name changes)
|
| 928 |
+
const now={name:v('bName'),short_description:v('bShort'),description:v('bDesc')};
|
| 929 |
+
const changed={};Object.keys(now).forEach(k=>{if(botProfileOrig[k]!==undefined&&now[k]!==botProfileOrig[k])changed[k]=now[k]});
|
| 930 |
+
if(Object.keys(changed).length){
|
| 931 |
+
const r2=await apiFetch('/api/bot-profile',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(changed)});
|
| 932 |
+
if(r2&&r2.error){showToast(r2.error,'error',5000);return}
|
| 933 |
+
botProfileOrig={...botProfileOrig,...changed};
|
| 934 |
+
}
|
| 935 |
+
showToast('تنظیمات ذخیره شد','success');goBackOneLevel();
|
| 936 |
+
}
|
| 937 |
+
|
| 938 |
+
let pollSkip=0;function startPoller(){fetchChats();if(curChatId)fetchHistory(curChatId,true);if(pollerID)clearInterval(pollerID);pollerID=setInterval(()=>{if(window.wsLive&&(++pollSkip%10))return;fetchChats(true);if(curChatId)fetchHistory(curChatId,true)},pollMs);if(window.wsConnect)wsConnect()}
|
| 939 |
+
|
| 940 |
+
// fetchChats/renderChatList/filterChats/togglePin/toggleMute/
|
| 941 |
+
// togglePinCurrent/toggleMuteCurrent now live in static/js/chatlist.js
|
| 942 |
+
|
| 943 |
+
// selChat/backList/murl/mkMedia/doReact/mkReactBar/mkReactionChips/
|
| 944 |
+
// setReply/cancelReply/fetchHistory now live in static/js/chat.js
|
| 945 |
+
// (Phase 2 — chat topbar + real-tail bubbles).
|
| 946 |
+
|
| 947 |
+
// sendMsg/pickFile/onFilePick/uploadMedia/toggleRec/cancelRec/
|
| 948 |
+
// stopRec now live in static/js/composer.js (Phase 3 — real tweb
|
| 949 |
+
// recording pill: cancel + dot/timer + an always-visible send button).
|
| 950 |
+
|
| 951 |
+
// new chat
|
| 952 |
+
function openNewChatModal(){pushUiState({level:'overlay',chatId:curChatId||null});new bootstrap.Modal(document.getElementById('newChatModal')).show()}
|
| 953 |
+
async function startNewChat(){const id=document.getElementById('ncId').value.trim();const msg=document.getElementById('ncMsg').value.trim();if(!id||!msg){showToast('شناسه و پیام لازم است','warn');return}const res=await apiFetch('/api/send',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({chatId:id,text:msg,customTitle:'مخاطب '+id,senderMode:'bot'})});if(res?.success){bootstrap.Modal.getInstance(document.getElementById('newChatModal')).hide();document.getElementById('ncId').value='';document.getElementById('ncMsg').value='';lastChatsHash='';await fetchChats(false);selChat(res.resolvedChatId||id,'مخاطب '+id,null)}else showToast(res?.error||'ارسال ناموفق','error')}
|
| 954 |
+
|
| 955 |
+
// profile
|
| 956 |
+
async function showProfileModal(){
|
| 957 |
+
if(!curChatId)return;
|
| 958 |
+
pushUiState({level:'profile',chatId:curChatId});
|
| 959 |
+
const modal=new bootstrap.Modal(document.getElementById('profileModal'));
|
| 960 |
+
const body=document.getElementById('profileBody');
|
| 961 |
+
body.innerHTML='<div class="py-4 text-center"><div class="spinner-border" style="color:var(--md-sys-color-primary)"></div></div>';
|
| 962 |
+
modal.show();
|
| 963 |
+
// reflect current pin/mute state on the action buttons moved here from the topbar
|
| 964 |
+
const c=allChats.find(x=>x.id===curChatId);
|
| 965 |
+
const pinBtn=document.getElementById('paPin'),muteBtn=document.getElementById('paMute');
|
| 966 |
+
pinBtn.querySelector('i').className='bi '+(c&&c.pinned?'bi-pin-angle-fill':'bi-pin-angle');
|
| 967 |
+
pinBtn.querySelector('span').textContent=c&&c.pinned?'لغو پین':'پین گفتگو';
|
| 968 |
+
muteBtn.querySelector('i').className='bi '+(c&&c.muted?'bi-bell-slash-fill':'bi-bell');
|
| 969 |
+
muteBtn.querySelector('span').textContent=c&&c.muted?'لغو بیصدا':'بیصدا کردن';
|
| 970 |
+
// small status line under the "پنل AI" button — فعال (green) / غیرفعال (red)
|
| 971 |
+
apiFetch('/api/chat-settings?id='+encodeURIComponent(curChatId)).then(cfg=>{
|
| 972 |
+
const on=cfg?(cfg.ai_mode!==undefined?cfg.ai_mode:true):true;
|
| 973 |
+
const paEl=document.getElementById('paAiStatus');
|
| 974 |
+
paEl.textContent=on?'فعال':'غیرفعال';paEl.className='pa-sub '+(on?'on':'off');
|
| 975 |
+
});
|
| 976 |
+
if(isGroup) await renderGroupInfoBody(body);
|
| 977 |
+
else await renderUserProfileBody(body);
|
| 978 |
+
}
|
| 979 |
+
|
| 980 |
+
async function renderUserProfileBody(body){
|
| 981 |
+
const p=await apiFetch('/api/user-profile?id='+encodeURIComponent(curChatId));
|
| 982 |
+
body.innerHTML='';
|
| 983 |
+
if(!p||p.error){
|
| 984 |
+
const a=document.createElement('div');a.className='alert alert-warning';a.textContent='پروفایل در دسترس نیست';body.appendChild(a);
|
| 985 |
+
return;
|
| 986 |
+
}
|
| 987 |
+
const img=document.createElement('div');img.className='text-center mb-3';
|
| 988 |
+
const im=document.createElement('img');
|
| 989 |
+
im.src=`/api/user-photo?id=${encodeURIComponent(curChatId)}&auth=${encodeURIComponent(PASS)}`;
|
| 990 |
+
im.className='rounded-circle';
|
| 991 |
+
im.style.cssText='width:128px;height:128px;object-fit:cover;border:3px solid var(--md-sys-color-primary)';
|
| 992 |
+
im.onerror=()=>im.style.display='none';
|
| 993 |
+
img.appendChild(im);body.appendChild(img);
|
| 994 |
+
const rows=[['شناسه',p.id||curChatId,true],['نام',(p.first_name||'')+' '+(p.last_name||'')],['یوزرنیم',p.username?'@'+p.username:'ندارد'],['بیوگرافی',p.bio||'ثبت نشده']];
|
| 995 |
+
rows.forEach(([l,v,code])=>{const d=document.createElement('p');d.innerHTML=`<strong>${l}: </strong>`+(code?`<code>${v}</code>`:v);body.appendChild(d)});
|
| 996 |
+
if(p.limited){const note=document.createElement('div');note.className='alert alert-warning py-2';note.style.fontSize='.78rem';note.textContent=p.limited_reason;body.appendChild(note);}
|
| 997 |
+
|
| 998 |
+
// ---- shared media tabs (Photos/Videos/Files/Voice) ----
|
| 999 |
+
const tabs=document.createElement('div');tabs.className='pm-tabs';
|
| 1000 |
+
const grid=document.createElement('div');grid.className='pm-media-grid';
|
| 1001 |
+
const TAB_DEFS=[['photo','عکس',''],['video','ویدیو',''],['voice','صوتی','list'],['document','فایل','list']];
|
| 1002 |
+
let media=null;
|
| 1003 |
+
TAB_DEFS.forEach(([type,label,mode],i)=>{
|
| 1004 |
+
const t=document.createElement('div');t.className='pm-tab'+(i===0?' active':'');t.textContent=label;
|
| 1005 |
+
t.onclick=()=>{tabs.querySelectorAll('.pm-tab').forEach(x=>x.classList.remove('active'));t.classList.add('active');renderMediaGrid(grid,media,type,mode);};
|
| 1006 |
+
tabs.appendChild(t);
|
| 1007 |
+
});
|
| 1008 |
+
body.appendChild(tabs);body.appendChild(grid);
|
| 1009 |
+
grid.innerHTML='<div class="pm-empty">در حال بارگذاری...</div>';
|
| 1010 |
+
media=await apiFetch('/api/chat-media?id='+encodeURIComponent(curChatId));
|
| 1011 |
+
renderMediaGrid(grid,media,'photo','');
|
| 1012 |
+
}
|
| 1013 |
+
|
| 1014 |
+
function renderMediaGrid(grid,media,type,mode){
|
| 1015 |
+
grid.className='pm-media-grid'+(mode==='list'?' list':'');
|
| 1016 |
+
grid.innerHTML='';
|
| 1017 |
+
const items=(media&&media[type])||[];
|
| 1018 |
+
if(!items.length){grid.innerHTML='<div class="pm-empty">چیزی نیست</div>';return;}
|
| 1019 |
+
items.forEach(it=>{
|
| 1020 |
+
if(mode==='list'){
|
| 1021 |
+
const row=document.createElement('div');row.className='pm-media-row';
|
| 1022 |
+
row.innerHTML=`<i class="bi ${type==='voice'?'bi-mic-fill':'bi-file-earmark'}"></i><span class="flex-1" style="flex:1">${type==='voice'?'پیام صوتی':'فایل'}</span><span class="text-secondary" style="font-size:.75rem">${it.time||''}</span>`;
|
| 1023 |
+
row.onclick=()=>downloadFile(it.file_id,type);
|
| 1024 |
+
grid.appendChild(row);
|
| 1025 |
+
}else{
|
| 1026 |
+
const tile=document.createElement('div');tile.className='pm-media-tile';
|
| 1027 |
+
if(type==='photo'){const img=document.createElement('img');img.src=murl(it.file_id);tile.appendChild(img);tile.onclick=()=>viewMedia(it.file_id,'photo');}
|
| 1028 |
+
else{const v=document.createElement('video');v.src=murl(it.file_id);v.muted=true;tile.appendChild(v);tile.onclick=()=>viewMedia(it.file_id,'video');}
|
| 1029 |
+
grid.appendChild(tile);
|
| 1030 |
+
}
|
| 1031 |
+
});
|
| 1032 |
+
}
|
| 1033 |
+
|
| 1034 |
+
// ---- group info (real tweb-style: header + members + management,
|
| 1035 |
+
// all in one panel instead of a scattered topbar toolbar) ----
|
| 1036 |
+
async function renderGroupInfoBody(body){
|
| 1037 |
+
body.innerHTML='<div class="py-4 text-center"><div class="spinner-border" style="color:var(--md-sys-color-primary)"></div></div>';
|
| 1038 |
+
const info=await apiFetch('/api/group/info?chatId='+encodeURIComponent(curChatId));
|
| 1039 |
+
body.innerHTML='';
|
| 1040 |
+
const head=document.createElement('div');head.className='gi-header';
|
| 1041 |
+
const im=document.createElement('img');
|
| 1042 |
+
im.src=`/api/user-photo?id=${encodeURIComponent(curChatId)}&auth=${encodeURIComponent(PASS)}`;
|
| 1043 |
+
im.className='rounded-circle';im.style.cssText='width:96px;height:96px;object-fit:cover;border:3px solid var(--md-sys-color-primary)';
|
| 1044 |
+
im.onerror=()=>im.style.display='none';
|
| 1045 |
+
head.appendChild(im);
|
| 1046 |
+
const h=document.createElement('h5');h.className='mt-2 mb-0';h.textContent=(info&&info.title)||curChatId;head.appendChild(h);
|
| 1047 |
+
if(info&&info.member_count!=null){const mc=document.createElement('div');mc.className='gi-meta';mc.textContent=info.member_count+' عضو';head.appendChild(mc);}
|
| 1048 |
+
if(info&&info.description){const d=document.createElement('div');d.className='gi-desc';d.textContent=info.description;head.appendChild(d);}
|
| 1049 |
+
body.appendChild(head);
|
| 1050 |
+
|
| 1051 |
+
const memTitle=document.createElement('div');memTitle.className='gi-section-title';
|
| 1052 |
+
memTitle.textContent='اعضا (فقط ادمینها — Bot API دسترسی به لیست کامل اعضا نداره)';
|
| 1053 |
+
body.appendChild(memTitle);
|
| 1054 |
+
const memList=document.createElement('div');memList.id='giMembers';
|
| 1055 |
+
memList.innerHTML='<div class="pm-empty">در حال بارگذاری...</div>';
|
| 1056 |
+
body.appendChild(memList);
|
| 1057 |
+
apiFetch('/api/group/members?chatId='+encodeURIComponent(curChatId)).then(res=>{
|
| 1058 |
+
memList.innerHTML='';
|
| 1059 |
+
const admins=(res&&res.admins)||[];
|
| 1060 |
+
if(!admins.length){memList.innerHTML='<div class="pm-empty">موردی نیست</div>';return;}
|
| 1061 |
+
admins.forEach(a=>{
|
| 1062 |
+
const u=a.user||{};
|
| 1063 |
+
const row=document.createElement('div');row.className='gi-member';
|
| 1064 |
+
const av=document.createElement('div');av.className='gi-member-av';av.style.background=avGrad(u.id||u.username||'?');
|
| 1065 |
+
av.textContent=(u.first_name||'?')[0].toUpperCase();
|
| 1066 |
+
const nm=document.createElement('div');nm.className='gi-member-name';nm.textContent=(u.first_name||'')+' '+(u.last_name||'')+(u.username?' (@'+u.username+')':'');
|
| 1067 |
+
const badge=document.createElement('span');badge.className='gi-role-badge'+(a.status==='creator'?' owner':'');
|
| 1068 |
+
badge.textContent=a.status==='creator'?'سازنده':'ادمین';
|
| 1069 |
+
row.append(av,nm,badge);
|
| 1070 |
+
memList.appendChild(row);
|
| 1071 |
+
});
|
| 1072 |
+
});
|
| 1073 |
+
|
| 1074 |
+
const mgmtTitle=document.createElement('div');mgmtTitle.className='gi-section-title';mgmtTitle.textContent='مدیریت گروه';
|
| 1075 |
+
body.appendChild(mgmtTitle);
|
| 1076 |
+
const mgmt=document.createElement('div');mgmt.className='gi-mgmt-grid';
|
| 1077 |
+
const actions=[
|
| 1078 |
+
['bi-mic-mute','سکوت کاربر',showMuteModal,'danger'],
|
| 1079 |
+
['bi-ban','بن کاربر',showBanModal,'danger'],
|
| 1080 |
+
['bi-check-circle','آنبن کاربر',showUnbanModal,''],
|
| 1081 |
+
['bi-trash3','حذف N پیام',showDeleteMsgsModal,'warn'],
|
| 1082 |
+
['bi-person-x','حذف پیامهای یک کاربر',deleteUserMsgs,'warn'],
|
| 1083 |
+
['bi-funnel','فیلتر محتوا',showFilterModal,''],
|
| 1084 |
+
];
|
| 1085 |
+
actions.forEach(([icon,label,fn,cls])=>{
|
| 1086 |
+
const b=document.createElement('button');b.className='pa-btn'+(cls==='danger'?' danger':'');
|
| 1087 |
+
if(cls==='warn')b.style.color='var(--app-amber)';
|
| 1088 |
+
b.innerHTML=`<i class="bi ${icon}"></i><span>${label}</span>`;
|
| 1089 |
+
b.onclick=fn;
|
| 1090 |
+
mgmt.appendChild(b);
|
| 1091 |
+
});
|
| 1092 |
+
body.appendChild(mgmt);
|
| 1093 |
+
}
|
| 1094 |
+
|
| 1095 |
+
// edit
|
| 1096 |
+
async function editMsg(iid,mid,old){const nt=prompt('ویرایش پیام:',old);if(!nt||nt===old)return;const res=await apiFetch('/api/edit',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({chatId:curChatId,msgId:mid,internalId:iid,newText:nt})});if(res?.success)fetchHistory(curChatId,false)}
|
| 1097 |
+
|
| 1098 |
+
// delete chat
|
| 1099 |
+
async function deleteCurrentChat(){if(!curChatId)return;if(!confirm('این گفتگو از پنل حذف شود؟'))return;await apiFetch('/api/delete-chat',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({chatId:curChatId})});backList();lastChatsHash='';fetchChats(false)}
|
| 1100 |
+
|
| 1101 |
+
// chat AI settings
|
| 1102 |
+
async function loadChatSP(id){
|
| 1103 |
+
const cfg=await apiFetch('/api/chat-settings?id='+encodeURIComponent(id));
|
| 1104 |
+
const on=cfg?(cfg.ai_mode!==undefined?cfg.ai_mode:true):true;
|
| 1105 |
+
document.getElementById('csAi').checked=on;
|
| 1106 |
+
document.getElementById('csPrompt').value=cfg?.system_prompt||'';
|
| 1107 |
+
updateCsStatus();
|
| 1108 |
+
}
|
| 1109 |
+
function updateCsStatus(){
|
| 1110 |
+
const on=document.getElementById('csAi').checked;
|
| 1111 |
+
const el=document.getElementById('csStatus');
|
| 1112 |
+
el.textContent=on?'فعال':'غیرفعال';el.className='pa-sub '+(on?'on':'off');
|
| 1113 |
+
const paEl=document.getElementById('paAiStatus');
|
| 1114 |
+
if(paEl){paEl.textContent=on?'فعال':'غیرفعال';paEl.className='pa-sub '+(on?'on':'off')}
|
| 1115 |
+
}
|
| 1116 |
+
async function saveChatSettings(){if(!curChatId)return;const res=await apiFetch('/api/chat-settings',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({chatId:curChatId,ai_mode:document.getElementById('csAi').checked,system_prompt:document.getElementById('csPrompt').value})});if(res?.success){bootstrap.Modal.getInstance(document.getElementById('chatSP')).hide()}else showToast(res?.error||'خطا','error')}
|
| 1117 |
+
// Opened from the profile modal's "پنل AI" button; closing this modal
|
| 1118 |
+
// (any way — X, backdrop, Escape, or its own back-arrow, which just
|
| 1119 |
+
// calls .hide()) re-opens the profile modal, so "back" always lands
|
| 1120 |
+
// you where you came from. (History is the single source of truth now —
|
| 1121 |
+
// see pushUiState/applyUiState/wireModalBackStack in chat.js — so this
|
| 1122 |
+
// just pushes the next level; popstate on the way back is what actually
|
| 1123 |
+
// re-opens the profile modal, whether "back" came from this screen's
|
| 1124 |
+
// own control, the device back button, or a laptop's mouse back button.)
|
| 1125 |
+
function openChatSettingsFromProfile(){
|
| 1126 |
+
pushUiState({level:'ai',chatId:curChatId});
|
| 1127 |
+
bootstrap.Modal.getInstance(document.getElementById('profileModal'))?.hide();
|
| 1128 |
+
new bootstrap.Modal(document.getElementById('chatSP')).show();
|
| 1129 |
+
}
|
| 1130 |
+
|
| 1131 |
+
// ---- group moderation ----
|
| 1132 |
+
function openGmodModal(title,body,onOk){pushUiState({level:'overlay',chatId:curChatId||null});document.getElementById('gmodModalTitle').textContent=title;document.getElementById('gmodModalBody').innerHTML=body;const ok=document.getElementById('gmodModalOk');const clone=ok.cloneNode(true);ok.parentNode.replaceChild(clone,ok);clone.onclick=onOk;const modal=new bootstrap.Modal(document.getElementById('gmodModal'));modal.show()}
|
| 1133 |
+
function showMuteModal(){openGmodModal('سکوت کاربر',`<label class="mb-2 d-block">آیدی عددی کاربر</label><input id="gmUid" class="form-control mb-3" placeholder="12345678"><label class="mb-2 d-block">مدت (ثانیه، 0=دائمی)</label><input id="gmDur" type="number" value="0" class="form-control">`,async()=>{const uid=document.getElementById('gmUid').value.trim();const dur=parseInt(document.getElementById('gmDur').value)||0;const until=dur>0?Math.floor(Date.now()/1000)+dur:0;const res=await apiFetch('/api/group/restrict',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({chatId:curChatId,userId:uid,mute:true,untilDate:until})});bootstrap.Modal.getInstance(document.getElementById('gmodModal')).hide();toastResult(res,'سکوت اعمال شد')})}
|
| 1134 |
+
function showBanModal(){openGmodModal('بن کاربر',`<label class="mb-2 d-block">آیدی عددی کاربر</label><input id="gmBuid" class="form-control mb-3" placeholder="12345678"><div class="form-check"><input class="form-check-input" type="checkbox" id="gmRev"><label class="form-check-label">حذف پیامهای اخیر</label></div>`,async()=>{const uid=document.getElementById('gmBuid').value.trim();const rev=document.getElementById('gmRev').checked;const res=await apiFetch('/api/group/ban',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({chatId:curChatId,userId:uid,revokeMessages:rev})});bootstrap.Modal.getInstance(document.getElementById('gmodModal')).hide();toastResult(res,'بن انجام شد')})}
|
| 1135 |
+
function showUnbanModal(){openGmodModal('آنبن کاربر',`<label class="mb-2 d-block">آیدی عددی کاربر</label><input id="gmUbuid" class="form-control" placeholder="12345678">`,async()=>{const uid=document.getElementById('gmUbuid').value.trim();const res=await apiFetch('/api/group/unban',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({chatId:curChatId,userId:uid})});bootstrap.Modal.getInstance(document.getElementById('gmodModal')).hide();toastResult(res,'آنبن انجام شد')})}
|
| 1136 |
+
function showDeleteMsgsModal(){openGmodModal('حذف پیامهای آخر',`<label class="mb-2 d-block">تعداد پیام برای حذف (حداکثر 200)</label><input id="gmDc" type="number" value="10" min="1" max="200" class="form-control">`,async()=>{const n=parseInt(document.getElementById('gmDc').value)||10;const res=await apiFetch('/api/group/delete-messages',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({chatId:curChatId,count:n})});bootstrap.Modal.getInstance(document.getElementById('gmodModal')).hide();if(res?.success){showToast(`${res.deleted} پیام حذف شد`,'success');fetchHistory(curChatId,false)}else showToast(res?.error||'خطا','error')})}
|
| 1137 |
+
async function deleteUserMsgs(){const uid=prompt('آیدی عددی کاربر را وارد کن:');if(!uid)return;const res=await apiFetch('/api/group/delete-user-messages',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({chatId:curChatId,userId:uid})});toastResult(res,'پیامهای کاربر حذف شد')}
|
| 1138 |
+
function showFilterModal(){openGmodModal('فیلتر محتوا در گروه',`<div class="d-flex flex-wrap gap-2"><div class="form-check"><input class="form-check-input" type="checkbox" id="fSticker"><label class="form-check-label">استیکر</label></div><div class="form-check"><input class="form-check-input" type="checkbox" id="fGif"><label class="form-check-label">GIF</label></div><div class="form-check"><input class="form-check-input" type="checkbox" id="fVoice"><label class="form-check-label">ویس</label></div><div class="form-check"><input class="form-check-input" type="checkbox" id="fVideo"><label class="form-check-label">ویدیو</label></div><div class="form-check"><input class="form-check-input" type="checkbox" id="fPhoto"><label class="form-check-label">عکس</label></div><div class="form-check"><input class="form-check-input" type="checkbox" id="fFile"><label class="form-check-label">فایل</label></div><div class="form-check"><input class="form-check-input" type="checkbox" id="fLink"><label class="form-check-label">لینک</label></div><div class="form-check"><input class="form-check-input" type="checkbox" id="fSong"><label class="form-check-label">آهنگ</label></div></div>`,async()=>{const filters={sticker:document.getElementById('fSticker').checked,gif:document.getElementById('fGif').checked,voice:document.getElementById('fVoice').checked,video:document.getElementById('fVideo').checked,photo:document.getElementById('fPhoto').checked,file:document.getElementById('fFile').checked,link:document.getElementById('fLink').checked,song:document.getElementById('fSong').checked};const res=await apiFetch('/api/group/content-filter',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({chatId:curChatId,filters})});bootstrap.Modal.getInstance(document.getElementById('gmodModal')).hide();toastResult(res,'فیلترها ذخیره شدند')})}
|
| 1139 |
+
// loadGroupAdmins removed (Phase 5) — members now render directly
|
| 1140 |
+
// inside renderGroupInfoBody() instead of a separate admins-only modal.
|
| 1141 |
+
// a stored session is re-validated right away (not on window.onload, which waits for every image/font)
|
| 1142 |
+
if(PASS)login();
|
| 1143 |
+
</script>
|
| 1144 |
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
| 1145 |
+
</body>
|
| 1146 |
+
</html>
|
prompt.txt
ADDED
|
File without changes
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
httpx
|
| 2 |
+
pywebpush
|
| 3 |
+
tzdata
|
| 4 |
+
spaces
|
| 5 |
+
python-multipart
|
| 6 |
+
websockets
|