| <!DOCTYPE html> |
| <html lang="fa" dir="rtl"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <title>🤖 ربات هوشمند ایتا - Eita Bot</title> |
| <style> |
| * { margin: 0; padding: 0; box-sizing: border-box; } |
| body { |
| font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; |
| background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%); |
| min-height: 100vh; padding: 20px; color: #fff; |
| } |
| .container { |
| max-width: 1200px; margin: 0 auto; |
| display: grid; grid-template-columns: 350px 1fr; gap: 20px; |
| } |
| @media (max-width: 968px) { |
| .container { grid-template-columns: 1fr; } |
| } |
| .panel { |
| background: rgba(255,255,255,0.05); backdrop-filter: blur(20px); |
| border: 1px solid rgba(255,255,255,0.1); border-radius: 20px; |
| padding: 25px; box-shadow: 0 20px 40px rgba(0,0,0,0.3); |
| } |
| .panel h2 { |
| font-size: 18px; margin-bottom: 20px; display: flex; |
| align-items: center; gap: 10px; color: #00d2ff; |
| } |
| .panel h2 .icon { |
| width: 40px; height: 40px; border-radius: 12px; |
| background: linear-gradient(135deg, #00d2ff, #3a7bd5); |
| display: flex; align-items: center; justify-content: center; font-size: 20px; |
| } |
| .form-group { margin-bottom: 18px; } |
| .form-group label { |
| display: block; font-size: 13px; font-weight: 600; |
| margin-bottom: 8px; color: rgba(255,255,255,0.8); |
| } |
| .form-group input, .form-group textarea, .form-group select { |
| width: 100%; padding: 12px 15px; |
| background: rgba(255,255,255,0.07); border: 2px solid rgba(255,255,255,0.1); |
| border-radius: 10px; color: #fff; font-size: 14px; |
| font-family: inherit; outline: none; transition: all 0.3s; |
| } |
| .form-group input:focus, .form-group textarea:focus, .form-group select:focus { |
| border-color: #00d2ff; background: rgba(255,255,255,0.1); |
| } |
| .form-group input::placeholder { color: rgba(255,255,255,0.3); } |
| .btn { |
| width: 100%; padding: 14px; border: none; border-radius: 10px; |
| font-size: 15px; font-weight: 700; font-family: inherit; |
| cursor: pointer; transition: all 0.3s; display: flex; |
| align-items: center; justify-content: center; gap: 8px; |
| } |
| .btn-primary { |
| background: linear-gradient(135deg, #00d2ff, #3a7bd5); color: #fff; |
| } |
| .btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 25px rgba(0,210,255,0.4); } |
| .btn-success { background: linear-gradient(135deg, #2ed573, #17a558); color: #fff; } |
| .btn-danger { background: linear-gradient(135deg, #ff4757, #c0392b); color: #fff; } |
| .btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; } |
| .status-indicator { |
| display: inline-flex; align-items: center; gap: 8px; |
| padding: 8px 15px; border-radius: 20px; font-size: 13px; font-weight: 600; |
| margin-bottom: 15px; |
| } |
| .status-indicator.online { background: rgba(46,213,115,0.2); color: #2ed573; } |
| .status-indicator.offline { background: rgba(255,71,87,0.2); color: #ff4757; } |
| .status-indicator .dot { |
| width: 8px; height: 8px; border-radius: 50%; |
| animation: pulse 1.5s ease-in-out infinite; |
| } |
| .status-indicator.online .dot { background: #2ed573; } |
| .status-indicator.offline .dot { background: #ff4757; } |
| @keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} } |
| .stats { |
| display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; |
| margin-bottom: 20px; |
| } |
| .stat-box { |
| background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); |
| border-radius: 12px; padding: 15px; text-align: center; |
| } |
| .stat-box .value { font-size: 24px; font-weight: 700; color: #00d2ff; } |
| .stat-box .label { font-size: 11px; color: rgba(255,255,255,0.6); margin-top: 5px; } |
| .log-container { |
| background: rgba(0,0,0,0.3); border-radius: 12px; padding: 15px; |
| height: 400px; overflow-y: auto; font-family: 'Courier New', monospace; |
| font-size: 12px; line-height: 1.8; |
| } |
| .log-entry { |
| padding: 8px 12px; margin-bottom: 8px; border-radius: 8px; |
| border-right: 3px solid; animation: slideIn 0.3s ease; |
| } |
| @keyframes slideIn { from{opacity:0;transform:translateX(20px)} to{opacity:1;transform:translateX(0)} } |
| .log-entry.info { background: rgba(0,210,255,0.1); border-color: #00d2ff; } |
| .log-entry.success { background: rgba(46,213,115,0.1); border-color: #2ed573; } |
| .log-entry.warning { background: rgba(255,193,7,0.1); border-color: #ffc107; } |
| .log-entry.error { background: rgba(255,71,87,0.1); border-color: #ff4757; } |
| .log-entry .time { color: rgba(255,255,255,0.5); font-size: 10px; } |
| .log-entry .message { color: #fff; margin-top: 3px; } |
| .features-grid { |
| display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; |
| margin-top: 15px; |
| } |
| .feature-card { |
| background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); |
| border-radius: 10px; padding: 12px; cursor: pointer; transition: all 0.3s; |
| } |
| .feature-card:hover { background: rgba(255,255,255,0.1); transform: translateY(-2px); } |
| .feature-card.active { border-color: #2ed573; background: rgba(46,213,115,0.1); } |
| .feature-card .icon { font-size: 24px; margin-bottom: 8px; } |
| .feature-card .title { font-size: 13px; font-weight: 600; margin-bottom: 3px; } |
| .feature-card .desc { font-size: 11px; color: rgba(255,255,255,0.5); } |
| .toggle-switch { |
| position: relative; display: inline-block; width: 50px; height: 26px; |
| } |
| .toggle-switch input { opacity: 0; width: 0; height: 0; } |
| .slider { |
| position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; |
| background: rgba(255,255,255,0.1); transition: 0.4s; border-radius: 26px; |
| } |
| .slider:before { |
| position: absolute; content: ""; height: 20px; width: 20px; |
| left: 3px; bottom: 3px; background: white; transition: 0.4s; border-radius: 50%; |
| } |
| input:checked + .slider { background: #2ed573; } |
| input:checked + .slider:before { transform: translateX(24px); } |
| .setting-row { |
| display: flex; align-items: center; justify-content: space-between; |
| padding: 12px; background: rgba(255,255,255,0.03); border-radius: 10px; |
| margin-bottom: 10px; |
| } |
| .setting-row .info { flex: 1; } |
| .setting-row .title { font-size: 13px; font-weight: 600; } |
| .setting-row .desc { font-size: 11px; color: rgba(255,255,255,0.5); margin-top: 3px; } |
| .tab-buttons { |
| display: flex; gap: 8px; margin-bottom: 20px; |
| border-bottom: 2px solid rgba(255,255,255,0.1); padding-bottom: 10px; |
| } |
| .tab-btn { |
| padding: 8px 16px; border: none; background: transparent; |
| color: rgba(255,255,255,0.6); font-size: 13px; font-weight: 600; |
| cursor: pointer; border-radius: 8px; transition: all 0.3s; |
| } |
| .tab-btn.active { background: rgba(0,210,255,0.2); color: #00d2ff; } |
| .tab-content { display: none; } |
| .tab-content.active { display: block; animation: fadeIn 0.3s ease; } |
| @keyframes fadeIn { from{opacity:0} to{opacity:1} } |
| .keyword-list { |
| max-height: 200px; overflow-y: auto; margin-top: 10px; |
| } |
| .keyword-item { |
| display: flex; align-items: center; justify-content: space-between; |
| padding: 10px; background: rgba(255,255,255,0.05); border-radius: 8px; |
| margin-bottom: 8px; |
| } |
| .keyword-item .text { flex: 1; font-size: 13px; } |
| .keyword-item .delete { |
| background: rgba(255,71,87,0.2); border: none; color: #ff4757; |
| width: 28px; height: 28px; border-radius: 50%; cursor: pointer; |
| } |
| .add-keyword { |
| display: flex; gap: 8px; margin-top: 10px; |
| } |
| .add-keyword input { flex: 1; } |
| .add-keyword button { |
| padding: 10px 20px; background: #00d2ff; border: none; |
| border-radius: 8px; color: #fff; cursor: pointer; font-weight: 600; |
| } |
| </style> |
| </head> |
| <body> |
| <div class="container"> |
| |
| <div class="panel"> |
| <h2><span class="icon">⚙️</span> پنل کنترل ربات</h2> |
| |
| <div class="status-indicator offline" id="statusIndicator"> |
| <span class="dot"></span> |
| <span id="statusText">آفلاین</span> |
| </div> |
|
|
| <div class="form-group"> |
| <label>🔑 توکن API</label> |
| <input type="password" id="apiToken" placeholder="توکن را وارد کنید..."> |
| </div> |
|
|
| <div class="form-group"> |
| <label>👥 شناسه گروه (Chat ID)</label> |
| <input type="text" id="chatId" placeholder="مثال: 279058397"> |
| </div> |
|
|
| <button class="btn btn-primary" id="startBtn" onclick="startBot()"> |
| <span>▶️</span> شروع ربات |
| </button> |
|
|
| <button class="btn btn-danger" id="stopBtn" onclick="stopBot()" style="margin-top: 10px; display: none;"> |
| <span>⏹️</span> توقف ربات |
| </button> |
|
|
| <div class="stats" style="margin-top: 20px;"> |
| <div class="stat-box"> |
| <div class="value" id="messagesCount">0</div> |
| <div class="label">پیام دریافتی</div> |
| </div> |
| <div class="stat-box"> |
| <div class="value" id="responsesCount">0</div> |
| <div class="label">پاسخ ارسال شده</div> |
| </div> |
| <div class="stat-box"> |
| <div class="value" id="uptime">00:00</div> |
| <div class="label">زمان فعالیت</div> |
| </div> |
| <div class="stat-box"> |
| <div class="value" id="errorsCount">0</div> |
| <div class="label">خطاها</div> |
| </div> |
| </div> |
|
|
| <h2 style="margin-top: 25px;"><span class="icon">✨</span> ویژگیها</h2> |
| <div class="features-grid"> |
| <div class="feature-card active" onclick="toggleFeature(this, 'welcome')"> |
| <div class="icon">👋</div> |
| <div class="title">خوشآمدگویی</div> |
| <div class="desc">پیام خوشآمد برای اعضای جدید</div> |
| </div> |
| <div class="feature-card active" onclick="toggleFeature(this, 'greeting')"> |
| <div class="icon">🙏</div> |
| <div class="title">پاسخ به سلام</div> |
| <div class="desc">پاسخ "سلام علیکم" به سلام</div> |
| </div> |
| <div class="feature-card active" onclick="toggleFeature(this, 'google')"> |
| <div class="icon">🔍</div> |
| <div class="title">جستجوی گوگل</div> |
| <div class="desc">دستور /google</div> |
| </div> |
| <div class="feature-card active" onclick="toggleFeature(this, 'help')"> |
| <div class="icon">❓</div> |
| <div class="title">راهنما</div> |
| <div class="desc">دستور /help</div> |
| </div> |
| <div class="feature-card active" onclick="toggleFeature(this, 'time')"> |
| <div class="icon">🕐</div> |
| <div class="title">ساعت و تاریخ</div> |
| <div class="desc">دستور /time</div> |
| </div> |
| <div class="feature-card active" onclick="toggleFeature(this, 'quote')"> |
| <div class="icon">💬</div> |
| <div class="title">نقل قول</div> |
| <div class="desc">دستور /quote</div> |
| </div> |
| <div class="feature-card active" onclick="toggleFeature(this, 'ping')"> |
| <div class="icon">🏓</div> |
| <div class="title">پینگ</div> |
| <div class="desc">دستور /ping</div> |
| </div> |
| <div class="feature-card active" onclick="toggleFeature(this, 'filter')"> |
| <div class="icon">🚫</div> |
| <div class="title">فیلتر کلمات</div> |
| <div class="desc">حذف پیامهای نامناسب</div> |
| </div> |
| </div> |
| </div> |
|
|
| |
| <div class="panel"> |
| <h2><span class="icon">📊</span> لاگ فعالیتها</h2> |
| |
| <div class="tab-buttons"> |
| <button class="tab-btn active" onclick="switchTab('logs')">📜 لاگها</button> |
| <button class="tab-btn" onclick="switchTab('settings')">⚙️ تنظیمات</button> |
| <button class="tab-btn" onclick="switchTab('keywords')">🔑 کلمات کلیدی</button> |
| </div> |
|
|
| <div class="tab-content active" id="tab-logs"> |
| <div class="log-container" id="logContainer"> |
| <div class="log-entry info"> |
| <div class="time">سیستم آماده است</div> |
| <div class="message">برای شروع، توکن و شناسه گروه را وارد کنید</div> |
| </div> |
| </div> |
| </div> |
|
|
| <div class="tab-content" id="tab-settings"> |
| <div class="setting-row"> |
| <div class="info"> |
| <div class="title">پیام خوشآمدگویی</div> |
| <div class="desc">متن پیام برای اعضای جدید</div> |
| </div> |
| </div> |
| <textarea id="welcomeMessage" rows="3" style="width: 100%; padding: 12px; background: rgba(255,255,255,0.07); border: 2px solid rgba(255,255,255,0.1); border-radius: 10px; color: #fff; font-family: inherit; outline: none; resize: vertical;">👋 سلام {name} عزیز! |
| به گروه ما خوش آمدی 🎉 |
| لطفاً قوانین گروه را رعایت کنید.</textarea> |
|
|
| <div class="setting-row" style="margin-top: 15px;"> |
| <div class="info"> |
| <div class="title">پاسخ به سلام</div> |
| <div class="desc">متن پاسخ به کلمه "سلام"</div> |
| </div> |
| </div> |
| <input type="text" id="greetingResponse" value="سلام علیکم 🙏" style="width: 100%; padding: 12px; background: rgba(255,255,255,0.07); border: 2px solid rgba(255,255,255,0.1); border-radius: 10px; color: #fff; font-family: inherit; outline: none;"> |
|
|
| <div class="setting-row" style="margin-top: 15px;"> |
| <div class="info"> |
| <div class="title">فاصله بررسی پیامها (میلیثانیه)</div> |
| <div class="desc">هر چند وقت یکبار پیامهای جدید بررسی شود</div> |
| </div> |
| </div> |
| <input type="number" id="pollInterval" value="3000" min="1000" step="500" style="width: 100%; padding: 12px; background: rgba(255,255,255,0.07); border: 2px solid rgba(255,255,255,0.1); border-radius: 10px; color: #fff; font-family: inherit; outline: none;"> |
|
|
| <button class="btn btn-success" onclick="saveSettings()" style="margin-top: 15px;"> |
| <span>💾</span> ذخیره تنظیمات |
| </button> |
| </div> |
|
|
| <div class="tab-content" id="tab-keywords"> |
| <h3 style="font-size: 14px; margin-bottom: 10px;">🚫 کلمات ممنوعه</h3> |
| <p style="font-size: 12px; color: rgba(255,255,255,0.5); margin-bottom: 10px;"> |
| پیامهای حاوی این کلمات به صورت خودکار حذف میشوند |
| </p> |
| <div class="keyword-list" id="bannedWordsList"></div> |
| <div class="add-keyword"> |
| <input type="text" id="newBannedWord" placeholder="کلمه جدید..."> |
| <button onclick="addBannedWord()">افزودن</button> |
| </div> |
|
|
| <h3 style="font-size: 14px; margin-top: 25px; margin-bottom: 10px;">💡 کلمات پاسخ خودکار</h3> |
| <p style="font-size: 12px; color: rgba(255,255,255,0.5); margin-bottom: 10px;"> |
| وقتی این کلمات گفته شود، پاسخ مشخص داده میشود |
| </p> |
| <div class="keyword-list" id="autoResponsesList"></div> |
| <div class="add-keyword"> |
| <input type="text" id="newAutoKeyword" placeholder="کلمه..."> |
| <input type="text" id="newAutoResponse" placeholder="پاسخ..."> |
| <button onclick="addAutoResponse()">افزودن</button> |
| </div> |
| </div> |
| </div> |
| </div> |
|
|
| <script> |
| |
| let botConfig = { |
| token: '', |
| chatId: '', |
| running: false, |
| lastUpdateId: 0, |
| pollInterval: 3000, |
| startTime: null, |
| stats: { |
| messages: 0, |
| responses: 0, |
| errors: 0 |
| }, |
| features: { |
| welcome: true, |
| greeting: true, |
| google: true, |
| help: true, |
| time: true, |
| quote: true, |
| ping: true, |
| filter: true |
| }, |
| bannedWords: ['کلمه1', 'کلمه2'], |
| autoResponses: { |
| 'سلام': 'سلام علیکم 🙏', |
| 'صبح بخیر': 'صبح شما هم بخیر ☀️', |
| 'شب بخیر': 'شب شما هم بخیر 🌙' |
| }, |
| welcomeMessage: '👋 سلام {name} عزیز!\nبه گروه ما خوش آمدی 🎉\nلطفاً قوانین گروه را رعایت کنید.', |
| greetingResponse: 'سلام علیکم 🙏' |
| }; |
| |
| let pollTimer = null; |
| let uptimeTimer = null; |
| |
| |
| const quotes = [ |
| '💡 "تنها راه انجام کار بزرگ، عشق به کاری است که انجام میدهید." - استیو جابز', |
| '🌟 "موفقیت نهایی نیست، شکست کشنده نیست، شجاعت ادامه دادن مهم است." - چرچیل', |
| '🚀 "آینده به کسانی تعلق دارد که به زیبایی رویاهایشان ایمان دارند." - النور روزولت', |
| '💪 "هر روز یک فرصت جدید برای تغییر است."', |
| '🎯 "تمرکز یعنی نه گفتن به صد ایده خوب دیگر." - استیو جابز', |
| '🌈 "بعد از هر شب تاریک، صبح روشن در راه است."', |
| '🔥 "بزرگترین ماجراجویی، زندگی کردن رویاهایت است."', |
| '✨ "تو قویتر از چیزی هستی که فکر میکنی."' |
| ]; |
| |
| |
| function loadSettings() { |
| const saved = localStorage.getItem('eitaBotConfig'); |
| if (saved) { |
| const config = JSON.parse(saved); |
| botConfig = { ...botConfig, ...config }; |
| document.getElementById('apiToken').value = botConfig.token || ''; |
| document.getElementById('chatId').value = botConfig.chatId || ''; |
| document.getElementById('pollInterval').value = botConfig.pollInterval; |
| document.getElementById('welcomeMessage').value = botConfig.welcomeMessage; |
| document.getElementById('greetingResponse').value = botConfig.greetingResponse; |
| updateFeatureCards(); |
| renderBannedWords(); |
| renderAutoResponses(); |
| } |
| } |
| |
| |
| function saveSettings() { |
| botConfig.pollInterval = parseInt(document.getElementById('pollInterval').value); |
| botConfig.welcomeMessage = document.getElementById('welcomeMessage').value; |
| botConfig.greetingResponse = document.getElementById('greetingResponse').value; |
| localStorage.setItem('eitaBotConfig', JSON.stringify(botConfig)); |
| addLog('success', '✅ تنظیمات ذخیره شد'); |
| } |
| |
| |
| async function startBot() { |
| const token = document.getElementById('apiToken').value.trim(); |
| const chatId = document.getElementById('chatId').value.trim(); |
| |
| if (!token || !chatId) { |
| addLog('error', '❌ لطفاً توکن و شناسه گروه را وارد کنید'); |
| return; |
| } |
| |
| botConfig.token = token; |
| botConfig.chatId = chatId; |
| botConfig.running = true; |
| botConfig.startTime = Date.now(); |
| |
| document.getElementById('startBtn').style.display = 'none'; |
| document.getElementById('stopBtn').style.display = 'block'; |
| updateStatus(true); |
| |
| addLog('success', '🚀 ربات شروع به کار کرد'); |
| addLog('info', `📍 شناسه گروه: ${chatId}`); |
| |
| |
| try { |
| const me = await apiCall('getMe', {}); |
| if (me.ok) { |
| addLog('success', `✅ اتصال موفق - نام ربات: ${me.result.name || 'نامشخص'}`); |
| } |
| } catch (error) { |
| addLog('error', '❌ خطا در اتصال: ' + error.message); |
| stopBot(); |
| return; |
| } |
| |
| |
| startPolling(); |
| startUptimeTimer(); |
| saveSettings(); |
| } |
| |
| |
| function stopBot() { |
| botConfig.running = false; |
| if (pollTimer) clearTimeout(pollTimer); |
| if (uptimeTimer) clearInterval(uptimeTimer); |
| |
| document.getElementById('startBtn').style.display = 'block'; |
| document.getElementById('stopBtn').style.display = 'none'; |
| updateStatus(false); |
| |
| addLog('warning', '⏹️ ربات متوقف شد'); |
| } |
| |
| |
| function updateStatus(online) { |
| const indicator = document.getElementById('statusIndicator'); |
| const text = document.getElementById('statusText'); |
| indicator.className = 'status-indicator ' + (online ? 'online' : 'offline'); |
| text.textContent = online ? 'آنلاین' : 'آفلاین'; |
| } |
| |
| |
| function startPolling() { |
| if (!botConfig.running) return; |
| |
| pollMessages().then(() => { |
| if (botConfig.running) { |
| pollTimer = setTimeout(startPolling, botConfig.pollInterval); |
| } |
| }).catch(error => { |
| botConfig.stats.errors++; |
| updateStats(); |
| addLog('error', '❌ خطا در دریافت پیام: ' + error.message); |
| if (botConfig.running) { |
| pollTimer = setTimeout(startPolling, botConfig.pollInterval * 2); |
| } |
| }); |
| } |
| |
| |
| async function pollMessages() { |
| const data = await apiCall('getUpdates', { |
| offset: botConfig.lastUpdateId + 1, |
| limit: 100 |
| }); |
| |
| if (!data.ok) { |
| throw new Error(data.description || 'خطای نامشخص'); |
| } |
| |
| const updates = data.result || []; |
| |
| for (const update of updates) { |
| botConfig.lastUpdateId = update.update_id; |
| botConfig.stats.messages++; |
| updateStats(); |
| |
| if (update.message) { |
| await processMessage(update.message); |
| } |
| } |
| } |
| |
| |
| async function processMessage(message) { |
| const text = message.text || ''; |
| const chatId = message.chat.id; |
| const from = message.from; |
| const userName = from.first_name || from.username || 'کاربر'; |
| |
| addLog('info', `📨 پیام از ${userName}: ${text.substring(0, 50)}...`); |
| |
| |
| if (message.new_chat_members && botConfig.features.welcome) { |
| for (const member of message.new_chat_members) { |
| const welcomeText = botConfig.welcomeMessage.replace(/{name}/g, member.first_name || 'کاربر'); |
| await sendMessage(chatId, welcomeText); |
| addLog('success', `👋 خوشآمدگویی به ${member.first_name}`); |
| } |
| return; |
| } |
| |
| |
| if (botConfig.features.filter && shouldFilter(text)) { |
| try { |
| await apiCall('deleteMessage', { |
| chat_id: chatId, |
| message_id: message.message_id |
| }); |
| await sendMessage(chatId, `⚠️ ${userName}، لطفاً از کلمات مناسب استفاده کنید.`); |
| addLog('warning', `🚫 پیام فیلتر شد از ${userName}`); |
| } catch (e) { |
| addLog('error', '❌ خطا در حذف پیام: ' + e.message); |
| } |
| return; |
| } |
| |
| |
| if (text.startsWith('/')) { |
| await processCommand(text, chatId, userName); |
| return; |
| } |
| |
| |
| for (const [keyword, response] of Object.entries(botConfig.autoResponses)) { |
| if (text.includes(keyword)) { |
| await sendMessage(chatId, response); |
| addLog('success', `💬 پاسخ خودکار: ${keyword}`); |
| return; |
| } |
| } |
| |
| |
| if (botConfig.features.greeting && text.match(/سلام|درود|hello|hi/i)) { |
| await sendMessage(chatId, botConfig.greetingResponse); |
| addLog('success', '🙏 پاسخ به سلام'); |
| } |
| } |
| |
| |
| async function processCommand(text, chatId, userName) { |
| const command = text.split(' ')[0].toLowerCase(); |
| const args = text.substring(command.length).trim(); |
| |
| switch (command) { |
| case '/help': |
| case '/start': |
| if (botConfig.features.help) { |
| const helpText = `🤖 *دستورات ربات:* |
| |
| 👋 /help - راهنما |
| 🔍 /google [عبارت] - جستجوی گوگل |
| 🕐 /time - ساعت و تاریخ |
| 💬 /quote - نقل قول انگیزشی |
| 🏓 /ping - تست سرعت |
| 👥 /info - اطلاعات گروه |
| |
| ✨ برای استفاده از جستجوی گوگل: |
| /google هوش مصنوعی`; |
| await sendMessage(chatId, helpText); |
| addLog('success', '❓ راهنما ارسال شد'); |
| } |
| break; |
| |
| case '/google': |
| if (botConfig.features.google && args) { |
| const searchUrl = `https://www.google.com/search?q=${encodeURIComponent(args)}`; |
| const response = `🔍 *جستجوی گوگل:* |
| |
| 📌 عبارت: ${args} |
| |
| 🔗 لینک نتایج: |
| ${searchUrl}`; |
| await sendMessage(chatId, response); |
| addLog('success', `🔍 جستجو: ${args}`); |
| } else if (!args) { |
| await sendMessage(chatId, '❗ لطفاً عبارت جستجو را وارد کنید.\nمثال: /google هوش مصنوعی'); |
| } |
| break; |
| |
| case '/time': |
| if (botConfig.features.time) { |
| const now = new Date(); |
| const timeStr = now.toLocaleString('fa-IR', { |
| year: 'numeric', month: 'long', day: 'numeric', |
| hour: '2-digit', minute: '2-digit', second: '2-digit' |
| }); |
| await sendMessage(chatId, `🕐 *ساعت و تاریخ:*\n\n${timeStr}`); |
| addLog('success', '🕐 ساعت ارسال شد'); |
| } |
| break; |
| |
| case '/quote': |
| if (botConfig.features.quote) { |
| const randomQuote = quotes[Math.floor(Math.random() * quotes.length)]; |
| await sendMessage(chatId, randomQuote); |
| addLog('success', '💬 نقل قول ارسال شد'); |
| } |
| break; |
| |
| case '/ping': |
| if (botConfig.features.ping) { |
| const start = Date.now(); |
| await sendMessage(chatId, '🏓 پینگ...'); |
| const latency = Date.now() - start; |
| await sendMessage(chatId, `🏓 پنگ!\n\n⏱️ تأخیر: ${latency}ms`); |
| addLog('success', `🏓 پینگ: ${latency}ms`); |
| } |
| break; |
| |
| case '/info': |
| const uptime = formatUptime(Date.now() - botConfig.startTime); |
| const infoText = `📊 *اطلاعات ربات:* |
| |
| ⏱️ زمان فعالیت: ${uptime} |
| 📨 پیامهای دریافتی: ${botConfig.stats.messages} |
| 💬 پاسخهای ارسال شده: ${botConfig.stats.responses} |
| ❌ خطاها: ${botConfig.stats.errors} |
| 🔧 نسخه: 1.0.0`; |
| await sendMessage(chatId, infoText); |
| addLog('success', '📊 اطلاعات ارسال شد'); |
| break; |
| |
| default: |
| |
| break; |
| } |
| } |
| |
| |
| function shouldFilter(text) { |
| const lowerText = text.toLowerCase(); |
| return botConfig.bannedWords.some(word => lowerText.includes(word.toLowerCase())); |
| } |
| |
| |
| async function sendMessage(chatId, text) { |
| try { |
| const result = await apiCall('sendMessage', { |
| chat_id: chatId, |
| text: text, |
| parse_mode: 'Markdown' |
| }); |
| |
| if (result.ok) { |
| botConfig.stats.responses++; |
| updateStats(); |
| return true; |
| } else { |
| throw new Error(result.description || 'خطا در ارسال'); |
| } |
| } catch (error) { |
| botConfig.stats.errors++; |
| updateStats(); |
| addLog('error', '❌ خطا در ارسال پیام: ' + error.message); |
| return false; |
| } |
| } |
| |
| |
| async function apiCall(method, params) { |
| const url = `https://eitaayar.ir/api/${botConfig.token}/${method}`; |
| |
| const response = await fetch(url, { |
| method: 'POST', |
| headers: { |
| 'Content-Type': 'application/json', |
| 'Accept': 'application/json' |
| }, |
| body: JSON.stringify(params) |
| }); |
| |
| if (!response.ok) { |
| throw new Error(`HTTP ${response.status}: ${response.statusText}`); |
| } |
| |
| return await response.json(); |
| } |
| |
| |
| function updateStats() { |
| document.getElementById('messagesCount').textContent = botConfig.stats.messages; |
| document.getElementById('responsesCount').textContent = botConfig.stats.responses; |
| document.getElementById('errorsCount').textContent = botConfig.stats.errors; |
| } |
| |
| |
| function startUptimeTimer() { |
| uptimeTimer = setInterval(() => { |
| if (botConfig.startTime) { |
| const uptime = formatUptime(Date.now() - botConfig.startTime); |
| document.getElementById('uptime').textContent = uptime; |
| } |
| }, 1000); |
| } |
| |
| |
| function formatUptime(ms) { |
| const seconds = Math.floor(ms / 1000); |
| const minutes = Math.floor(seconds / 60); |
| const hours = Math.floor(minutes / 60); |
| |
| if (hours > 0) { |
| return `${hours}h ${minutes % 60}m`; |
| } else if (minutes > 0) { |
| return `${minutes}m ${seconds % 60}s`; |
| } else { |
| return `${seconds}s`; |
| } |
| } |
| |
| |
| function addLog(type, message) { |
| const container = document.getElementById('logContainer'); |
| const time = new Date().toLocaleTimeString('fa-IR'); |
| |
| const entry = document.createElement('div'); |
| entry.className = `log-entry ${type}`; |
| entry.innerHTML = ` |
| <div class="time">${time}</div> |
| <div class="message">${message}</div> |
| `; |
| |
| container.insertBefore(entry, container.firstChild); |
| |
| |
| while (container.children.length > 100) { |
| container.removeChild(container.lastChild); |
| } |
| } |
| |
| |
| function toggleFeature(card, feature) { |
| card.classList.toggle('active'); |
| botConfig.features[feature] = card.classList.contains('active'); |
| saveSettings(); |
| addLog('info', `${card.classList.contains('active') ? '✅' : '❌'} ویژگی ${feature} ${card.classList.contains('active') ? 'فعال' : 'غیرفعال'} شد`); |
| } |
| |
| |
| function updateFeatureCards() { |
| document.querySelectorAll('.feature-card').forEach(card => { |
| const feature = card.getAttribute('onclick').match(/'(\w+)'/)[1]; |
| if (botConfig.features[feature]) { |
| card.classList.add('active'); |
| } else { |
| card.classList.remove('active'); |
| } |
| }); |
| } |
| |
| |
| function switchTab(tabName) { |
| document.querySelectorAll('.tab-btn').forEach(btn => btn.classList.remove('active')); |
| document.querySelectorAll('.tab-content').forEach(content => content.classList.remove('active')); |
| |
| event.target.classList.add('active'); |
| document.getElementById(`tab-${tabName}`).classList.add('active'); |
| } |
| |
| |
| function renderBannedWords() { |
| const list = document.getElementById('bannedWordsList'); |
| list.innerHTML = botConfig.bannedWords.map((word, index) => ` |
| <div class="keyword-item"> |
| <span class="text">${word}</span> |
| <button class="delete" onclick="removeBannedWord(${index})">✕</button> |
| </div> |
| `).join(''); |
| } |
| |
| function addBannedWord() { |
| const input = document.getElementById('newBannedWord'); |
| const word = input.value.trim(); |
| if (word && !botConfig.bannedWords.includes(word)) { |
| botConfig.bannedWords.push(word); |
| input.value = ''; |
| renderBannedWords(); |
| saveSettings(); |
| addLog('success', `✅ کلمه ممنوعه اضافه شد: ${word}`); |
| } |
| } |
| |
| function removeBannedWord(index) { |
| const word = botConfig.bannedWords[index]; |
| botConfig.bannedWords.splice(index, 1); |
| renderBannedWords(); |
| saveSettings(); |
| addLog('warning', `🗑️ کلمه ممنوعه حذف شد: ${word}`); |
| } |
| |
| |
| function renderAutoResponses() { |
| const list = document.getElementById('autoResponsesList'); |
| list.innerHTML = Object.entries(botConfig.autoResponses).map(([keyword, response]) => ` |
| <div class="keyword-item"> |
| <span class="text"><strong>${keyword}:</strong> ${response}</span> |
| <button class="delete" onclick="removeAutoResponse('${keyword}')">✕</button> |
| </div> |
| `).join(''); |
| } |
| |
| function addAutoResponse() { |
| const keywordInput = document.getElementById('newAutoKeyword'); |
| const responseInput = document.getElementById('newAutoResponse'); |
| const keyword = keywordInput.value.trim(); |
| const response = responseInput.value.trim(); |
| |
| if (keyword && response) { |
| botConfig.autoResponses[keyword] = response; |
| keywordInput.value = ''; |
| responseInput.value = ''; |
| renderAutoResponses(); |
| saveSettings(); |
| addLog('success', `✅ پاسخ خودکار اضافه شد: ${keyword}`); |
| } |
| } |
| |
| function removeAutoResponse(keyword) { |
| delete botConfig.autoResponses[keyword]; |
| renderAutoResponses(); |
| saveSettings(); |
| addLog('warning', `🗑️ پاسخ خودکار حذف شد: ${keyword}`); |
| } |
| |
| |
| window.addEventListener('load', loadSettings); |
| |
| |
| window.addEventListener('beforeunload', () => { |
| if (botConfig.running) { |
| stopBot(); |
| } |
| saveSettings(); |
| }); |
| </script> |
| </body> |
| </html> |