Personal Telegram developer console for GitHub

fix: make menu status source-backed and non-fabricated

davoodmehraban89 committed Oct 2, 2026 at 22:16 UTC b9a2b6dd21e07bcd41882f2e245a60fcd3ccaf70
1 file changed +213 -247
src/menu.js
+213 -247
@@ -1,316 +1,299 @@
1 import { DEFAULT_CONFIG } from './config.js';
2
3 +function escapeHtml(value = '') {
4 + return String(value)
5 + .replaceAll('&', '&')
6 + .replaceAll('<', '&lt;')
7 + .replaceAll('>', '&gt;')
8 + .replaceAll('"', '&quot;');
9 +}
10 +
11 /**
4 - * Menu Router and UI Generator for Nexa Dev Bot
12 + * Menu Router and UI Generator for Nexa Dev Bot.
13 + * Views never claim external service health unless that view was built from a live API response.
14 */
15 export class MenuManager {
16 constructor(githubService) {
17 this.github = githubService;
18 }
19
11 - /**
12 - * Main Menu (Home)
13 - */
20 getMainMenuView() {
15 - const text =
21 + const text =
22 `⚡ <b>Nexa Dev Bot | پنل مدیریت توسعه</b>
23 ➖➖➖➖➖➖➖➖➖➖
18 -خوش آمدید! یکی از بخش‌های زیر را انتخاب کنید:
19 -وضعیت اتصال گیت‌هاب: ✅ متصل (davoodmehraban89)
20 -مدیریت مخازن، وضعیت سرویس‌ها و پایش یکپارچه.`;
21 -
22 - const inlineKeyboard = [
23 - [
24 - { text: '📁 مخزن‌ها (پروژه‌ها)', callback_data: 'menu:repos' },
25 - { text: '📊 وضعیت سرویس', callback_data: 'menu:status' }
26 - ],
27 - [
28 - { text: '🔧 ابزارهای توسعه', callback_data: 'menu:tools' },
29 - { text: '⚙️ تنظیمات', callback_data: 'menu:settings' }
30 - ],
31 - [
32 - { text: '🔐 امنیت و توکن‌ها', callback_data: 'menu:security' }
33 - ]
34 - ];
35 -
36 - return { text, reply_markup: { inline_keyboard: inlineKeyboard } };
24 +یکی از بخش‌های زیر را انتخاب کنید.
25 +اتصال GitHub هنگام باز کردن مخزن‌ها به‌صورت زنده بررسی می‌شود.`;
26 +
27 + return {
28 + text,
29 + reply_markup: {
30 + inline_keyboard: [
31 + [
32 + { text: '📁 مخزن‌ها (پروژه‌ها)', callback_data: 'menu:repos' },
33 + { text: '📊 وضعیت سرویس', callback_data: 'menu:status' }
34 + ],
35 + [
36 + { text: '🔧 ابزارهای توسعه', callback_data: 'menu:tools' },
37 + { text: '⚙️ تنظیمات', callback_data: 'menu:settings' }
38 + ],
39 + [
40 + { text: '🔐 امنیت', callback_data: 'menu:security' }
41 + ]
42 + ]
43 + }
44 + };
45 }
46
39 - /**
40 - * Repositories List Menu
41 - */
47 async getReposListView() {
48 const repos = await this.github.listRepositories();
44 - const text =
49 + const text =
50 `📁 <b>فهرست مخزن‌ها و پروژه‌ها</b>
46 -<code>🏠 Nexa Dev > 📁 مخزن‌ها</code>
51 +<code>🏠 Nexa Dev &gt; 📁 مخزن‌ها</code>
52 ➖➖➖➖➖➖➖➖➖➖
48 -لطفاً پروژه مورد نظر خود را جهت مشاهده جزئیات، فایل‌ها، کامیت‌ها و PRها انتخاب کنید:`;
53 +این فهرست از GitHub API دریافت شده است. پروژه مورد نظر را انتخاب کنید:`;
54
55 const inlineKeyboard = [];
56 for (let i = 0; i < repos.length; i += 2) {
57 const row = [];
53 - row.push({ text: `📦 ${repos[i].name}`, callback_data: `repo:${repos[i].id}` });
58 + row.push({
59 + text: `${repos[i].private ? '🔒' : '🌐'} ${repos[i].name}`,
60 + callback_data: `repo:${repos[i].id}`
61 + });
62 if (repos[i + 1]) {
55 - row.push({ text: `📦 ${repos[i + 1].name}`, callback_data: `repo:${repos[i + 1].id}` });
63 + row.push({
64 + text: `${repos[i + 1].private ? '🔒' : '🌐'} ${repos[i + 1].name}`,
65 + callback_data: `repo:${repos[i + 1].id}`
66 + });
67 }
68 inlineKeyboard.push(row);
69 }
70
60 - // Navigation row
61 - inlineKeyboard.push([
62 - { text: '🔙 بازگشت به منوی اصلی', callback_data: 'menu:main' }
63 - ]);
71 + if (!repos.length) {
72 + inlineKeyboard.push([{ text: '🔄 بررسی مجدد', callback_data: 'menu:repos' }]);
73 + }
74 + inlineKeyboard.push([{ text: '🔙 بازگشت به منوی اصلی', callback_data: 'menu:main' }]);
75
76 return { text, reply_markup: { inline_keyboard: inlineKeyboard } };
77 }
78
68 - /**
69 - * Single Repository Detail Menu
70 - */
79 async getRepoDetailView(repoId) {
72 - const text =
73 -`📦 <b>پروژه: ${repoId}</b>
74 -<code>🏠 Nexa Dev > 📁 مخزن‌ها > ${repoId}</code>
80 + const repo = await this.github.getRepository(repoId);
81 + const visibility = repo.private ? '🔒 خصوصی' : '🌐 عمومی';
82 + const archived = repo.archived ? '\n⚠️ وضعیت: آرشیوشده' : '';
83 + const description = repo.description ? `\n📝 ${escapeHtml(repo.description)}` : '';
84 + const text =
85 +`📦 <b>پروژه: ${escapeHtml(repo.name)}</b>
86 +<code>🏠 Nexa Dev &gt; 📁 مخزن‌ها &gt; ${escapeHtml(repo.name)}</code>
87 ➖➖➖➖➖➖➖➖➖➖
76 -👤 مخزن: <code>${this.github.owner}/${repoId}</code>
77 -🔗 وضعیت اتصال GitHub: ✅ تایید شده
78 -یک عملیات را انتخاب کنید:`;
79 -
80 - const inlineKeyboard = [
81 - [
82 - { text: '📂 فایل‌ها', callback_data: `files:${repoId}` },
83 - { text: '🔀 Pull Requestها', callback_data: `pr:${repoId}` }
84 - ],
85 - [
86 - { text: '📝 Commitها', callback_data: `commits:${repoId}` },
87 - { text: '📊 وضعیت / تست‌ها', callback_data: `status:${repoId}` }
88 - ],
89 - [
90 - { text: '🔙 بازگشت به لیست پروژه‌ها', callback_data: 'menu:repos' }
91 - ]
92 - ];
93 -
94 - return { text, reply_markup: { inline_keyboard: inlineKeyboard } };
88 +👤 مخزن: <code>${escapeHtml(repo.fullName)}</code>
89 +👁 دسترسی: ${visibility}
90 +🌿 شاخه پیش‌فرض: <code>${escapeHtml(repo.defaultBranch)}</code>${archived}${description}
91 +
92 +اطلاعات بالا از GitHub API دریافت شد. یک عملیات را انتخاب کنید:`;
93 +
94 + return {
95 + text,
96 + reply_markup: {
97 + inline_keyboard: [
98 + [
99 + { text: '📂 فایل‌ها', callback_data: `files:${repoId}` },
100 + { text: '🔀 Pull Requestها', callback_data: `pr:${repoId}` }
101 + ],
102 + [
103 + { text: '📝 Commitها', callback_data: `commits:${repoId}` },
104 + { text: '📊 وضعیت / تست‌ها', callback_data: `status:${repoId}` }
105 + ],
106 + [{ text: '🔙 بازگشت به لیست پروژه‌ها', callback_data: 'menu:repos' }]
107 + ]
108 + }
109 + };
110 }
111
97 - /**
98 - * Pull Requests View
99 - */
112 async getPullRequestsView(repoId) {
113 const prs = await this.github.listPullRequests(repoId);
102 -
103 - let prListText = '';
104 - if (prs.length === 0) {
105 - prListText = '<i>هیچ Pull Request بازی یافت نشد.</i>';
106 - } else {
107 - prListText = prs.map(pr => {
108 - const stateEmoji = pr.merged ? '🟣 [Merged]' : (pr.state === 'open' ? '🟢 [Open]' : '🔴 [Closed]');
109 - return `• <b>#${pr.number}</b> ${pr.title}\n └ <i>نویسنده: @${pr.author} | وضعیت: ${stateEmoji}</i>`;
110 - }).join('\n\n');
111 - }
112 -
113 - const text =
114 -`🔀 <b>Pull Requestهای پروژه ${repoId}</b>
115 -<code>🏠 Nexa Dev > 📁 مخزن‌ها > ${repoId} > 🔀 Pull Request</code>
114 + const prListText = prs.length
115 + ? prs.map(pr => {
116 + const state = pr.merged ? '🟣 Merged' : (pr.state === 'open' ? '🟢 Open' : '🔴 Closed');
117 + return `• <b>#${pr.number}</b> ${escapeHtml(pr.title)}\n └ <i>${escapeHtml(pr.author)} | ${state}</i>`;
118 + }).join('\n\n')
119 + : '<i>Pull Requestی در پاسخ GitHub یافت نشد.</i>';
120 +
121 + const text =
122 +`🔀 <b>Pull Requestهای پروژه ${escapeHtml(repoId)}</b>
123 +<code>🏠 Nexa Dev &gt; 📁 مخزن‌ها &gt; ${escapeHtml(repoId)} &gt; 🔀 Pull Request</code>
124 ➖➖➖➖➖➖➖➖➖➖
117 -✅ دریافت لیست PRها از GitHub
118 -✅ نمایش شماره، عنوان، نویسنده و وضعیت:
119 -
125 ${prListText}`;
126
122 - const inlineKeyboard = [
123 - [
124 - { text: '🔄 بروزرسانی', callback_data: `pr:${repoId}` },
125 - { text: '🔙 بازگشت به پروژه', callback_data: `repo:${repoId}` }
126 - ]
127 - ];
128 -
129 - return { text, reply_markup: { inline_keyboard: inlineKeyboard } };
127 + return {
128 + text,
129 + reply_markup: {
130 + inline_keyboard: [[
131 + { text: '🔄 بروزرسانی', callback_data: `pr:${repoId}` },
132 + { text: '🔙 بازگشت به پروژه', callback_data: `repo:${repoId}` }
133 + ]]
134 + }
135 + };
136 }
137
132 - /**
133 - * Commits View
134 - */
138 async getCommitsView(repoId) {
139 const commits = await this.github.listCommits(repoId);
137 -
138 - let commitListText = commits.map(c => {
139 - return `• <code>${c.sha}</code> - ${c.message}\n └ <i>توسط @${c.author} در ${c.date}</i>`;
140 - }).join('\n\n');
141 -
142 - const text =
143 -`📝 <b>آخرین Commitهای پروژه ${repoId}</b>
144 -<code>🏠 Nexa Dev > 📁 مخزن‌ها > ${repoId} > 📝 Commitها</code>
140 + const commitListText = commits.length
141 + ? commits.map(c => `• <code>${escapeHtml(c.sha)}</code> - ${escapeHtml(c.message)}\n └ <i>${escapeHtml(c.author)}${c.date ? ` | ${escapeHtml(c.date)}` : ''}</i>`).join('\n\n')
142 + : '<i>کامیتی در پاسخ GitHub یافت نشد.</i>';
143 +
144 + const text =
145 +`📝 <b>آخرین Commitهای پروژه ${escapeHtml(repoId)}</b>
146 +<code>🏠 Nexa Dev &gt; 📁 مخزن‌ها &gt; ${escapeHtml(repoId)} &gt; 📝 Commitها</code>
147 ➖➖➖➖➖➖➖➖➖➖
148 ${commitListText}`;
149
148 - const inlineKeyboard = [
149 - [
150 - { text: '🔄 بروزرسانی', callback_data: `commits:${repoId}` },
151 - { text: '🔙 بازگشت به پروژه', callback_data: `repo:${repoId}` }
152 - ]
153 - ];
154 -
155 - return { text, reply_markup: { inline_keyboard: inlineKeyboard } };
150 + return {
151 + text,
152 + reply_markup: {
153 + inline_keyboard: [[
154 + { text: '🔄 بروزرسانی', callback_data: `commits:${repoId}` },
155 + { text: '🔙 بازگشت به پروژه', callback_data: `repo:${repoId}` }
156 + ]]
157 + }
158 + };
159 }
160
158 - /**
159 - * Files View
160 - */
161 async getFilesView(repoId, subpath = '') {
162 const files = await this.github.listFiles(repoId, subpath);
163 -
164 - const itemsText = files.map(f => {
165 - const icon = f.type === 'dir' ? '📁' : '📄';
166 - const size = f.size ? ` (${f.size} B)` : '';
167 - return `${icon} <code>${f.name}</code>${size}`;
168 - }).join('\n');
169 -
170 - const text =
171 -`📂 <b>ساختار فایل‌های پروژه ${repoId}</b>
172 -<code>🏠 Nexa Dev > 📁 مخزن‌ها > ${repoId} > 📂 فایل‌ها${subpath ? ` > ${subpath}` : ''}</code>
163 + const itemsText = files.length
164 + ? files.map(f => {
165 + const icon = f.type === 'dir' ? '📁' : '📄';
166 + const size = f.type === 'file' && f.size ? ` (${f.size} B)` : '';
167 + return `${icon} <code>${escapeHtml(f.name)}</code>${size}`;
168 + }).join('\n')
169 + : '<i>پوشه خالی است.</i>';
170 +
171 + const text =
172 +`📂 <b>ساختار فایل‌های پروژه ${escapeHtml(repoId)}</b>
173 +<code>🏠 Nexa Dev &gt; 📁 مخزن‌ها &gt; ${escapeHtml(repoId)} &gt; 📂 فایل‌ها${subpath ? ` &gt; ${escapeHtml(subpath)}` : ''}</code>
174 ➖➖➖➖➖➖➖➖➖➖
174 -${itemsText || '<i>پوشه خالی است.</i>'}`;
175 -
176 - const inlineKeyboard = [
177 - [
178 - { text: '🔄 بروزرسانی', callback_data: `files:${repoId}` },
179 - { text: '🔙 بازگشت به پروژه', callback_data: `repo:${repoId}` }
180 - ]
181 - ];
182 -
183 - return { text, reply_markup: { inline_keyboard: inlineKeyboard } };
175 +${itemsText}`;
176 +
177 + return {
178 + text,
179 + reply_markup: {
180 + inline_keyboard: [[
181 + { text: '🔄 بروزرسانی', callback_data: `files:${repoId}${subpath ? `:${subpath}` : ''}` },
182 + { text: '🔙 بازگشت به پروژه', callback_data: `repo:${repoId}` }
183 + ]]
184 + }
185 + };
186 }
187
186 - /**
187 - * Repository Status & Tests View
188 - */
188 async getRepoStatusView(repoId) {
189 const status = await this.github.getRepoStatus(repoId);
191 -
192 - const runsText = status.lastRuns.map(r => {
193 - const icon = r.conclusion === 'success' ? '✅' : (r.conclusion === 'failure' ? '❌' : '⏳');
194 - return `• ${icon} <b>${r.name}</b>: ${r.conclusion || r.status}\n └ <i>کامیت: ${r.commit}</i>`;
195 - }).join('\n');
196 -
197 - const text =
198 -`📊 <b>وضعیت سیستم و پایپ‌لاین ${repoId}</b>
199 -<code>🏠 Nexa Dev > 📁 مخزن‌ها > ${repoId} > 📊 وضعیت</code>
190 + const runsText = status.lastRuns.length
191 + ? status.lastRuns.map(r => {
192 + const icon = r.conclusion === 'success' ? '✅' : (r.conclusion === 'failure' ? '❌' : '⏳');
193 + return `• ${icon} <b>${escapeHtml(r.name)}</b>: ${escapeHtml(r.conclusion || r.status || 'unknown')}\n └ <i>${escapeHtml(r.commit || '')}</i>`;
194 + }).join('\n')
195 + : '<i>Workflow runی در پاسخ GitHub یافت نشد.</i>';
196 +
197 + const text =
198 +`📊 <b>وضعیت پایپ‌لاین ${escapeHtml(repoId)}</b>
199 +<code>🏠 Nexa Dev &gt; 📁 مخزن‌ها &gt; ${escapeHtml(repoId)} &gt; 📊 وضعیت</code>
200 ➖➖➖➖➖➖➖➖➖➖
201 -شاخه پیش‌فرض: <code>${status.defaultBranch}</code>
202 -آخرین نتایج Workflow و تست‌ها:
201 +شاخه پیش‌فرض: <code>${escapeHtml(status.defaultBranch)}</code>
202 +آخرین نتایج GitHub Actions:
203
204 ${runsText}`;
205
206 - const inlineKeyboard = [
207 - [
208 - { text: '🔄 بروزرسانی', callback_data: `status:${repoId}` },
209 - { text: '🔙 بازگشت به پروژه', callback_data: `repo:${repoId}` }
210 - ]
211 - ];
212 -
213 - return { text, reply_markup: { inline_keyboard: inlineKeyboard } };
206 + return {
207 + text,
208 + reply_markup: {
209 + inline_keyboard: [[
210 + { text: '🔄 بروزرسانی', callback_data: `status:${repoId}` },
211 + { text: '🔙 بازگشت به پروژه', callback_data: `repo:${repoId}` }
212 + ]]
213 + }
214 + };
215 }
216
216 - /**
217 - * System & Service Status View
218 - */
217 getServiceStatusView() {
220 - const services = DEFAULT_CONFIG.systemServices.map(s => `• <b>${s.name}</b>:\n └ ${s.status}`).join('\n\n');
221 - const text =
222 -`📊 <b>وضعیت سیستم و سرویس‌های فعال</b>
223 -<code>🏠 Nexa Dev > 📊 وضعیت سرویس</code>
218 + const text =
219 +`📊 <b>وضعیت سیستم و سرویس‌ها</b>
220 +<code>🏠 Nexa Dev &gt; 📊 وضعیت سرویس</code>
221 ➖➖➖➖➖➖➖➖➖➖
225 -${services}
226 -
227 -⏰ آخرین بررسی: هم‌اکنون (Realtime)`;
228 -
229 - const inlineKeyboard = [
230 - [
231 - { text: '🔄 بررسی مجدد', callback_data: 'menu:status' },
232 - { text: '🔙 بازگشت به منوی اصلی', callback_data: 'menu:main' }
233 - ]
234 - ];
235 -
236 - return { text, reply_markup: { inline_keyboard: inlineKeyboard } };
222 +• <b>Cloudflare Worker:</b> این درخواست توسط Worker پاسخ داده شد.
223 +• <b>Telegram Webhook:</b> secret و owner در مرز ورودی Worker enforce می‌شوند؛ مقادیر محرمانه نمایش داده نمی‌شوند.
224 +• <b>GitHub API:</b> هنگام باز کردن مخزن‌ها و وضعیت پروژه به‌صورت زنده فراخوانی می‌شود.
225 +• <b>CI/CD:</b> نتیجه هر مخزن از GitHub Actions خوانده می‌شود.
226 +
227 +این صفحه SLA، latency یا سلامت سرویس خارجی را بدون اندازه‌گیری واقعی اعلام نمی‌کند.`;
228 +
229 + return {
230 + text,
231 + reply_markup: {
232 + inline_keyboard: [[
233 + { text: '🔄 بررسی مجدد', callback_data: 'menu:status' },
234 + { text: '🔙 بازگشت به منوی اصلی', callback_data: 'menu:main' }
235 + ]]
236 + }
237 + };
238 }
239
239 - /**
240 - * Developer Tools View
241 - */
240 getToolsView() {
243 - const tools = DEFAULT_CONFIG.devTools.map(t => `• <b>${t.title}</b>:\n └ <i>${t.desc}</i>`).join('\n\n');
244 - const text =
245 -`🔧 <b>ابزارهای توسعه (Dev Tools)</b>
246 -<code>🏠 Nexa Dev > 🔧 ابزارهای توسعه</code>
241 + const tools = DEFAULT_CONFIG.devTools.map(t => `• <b>${t.title}</b>\n └ <i>${t.desc}</i>`).join('\n\n');
242 + const text =
243 +`🔧 <b>ابزارهای توسعه</b>
244 +<code>🏠 Nexa Dev &gt; 🔧 ابزارهای توسعه</code>
245 ➖➖➖➖➖➖➖➖➖➖
246 ${tools}`;
247
250 - const inlineKeyboard = [
251 - [
252 - { text: '🏓 پینگ سرور', callback_data: 'tool:ping' },
253 - { text: '🧹 پاکسازی سشن', callback_data: 'tool:cache_clear' }
254 - ],
255 - [
256 - { text: '🔙 بازگشت به منوی اصلی', callback_data: 'menu:main' }
257 - ]
258 - ];
259 -
260 - return { text, reply_markup: { inline_keyboard: inlineKeyboard } };
248 + return {
249 + text,
250 + reply_markup: {
251 + inline_keyboard: [
252 + [{ text: '🏓 بررسی مسیر داخلی', callback_data: 'tool:ping' }],
253 + [{ text: '🔙 بازگشت به منوی اصلی', callback_data: 'menu:main' }]
254 + ]
255 + }
256 + };
257 }
258
263 - /**
264 - * Settings View
265 - */
259 getSettingsView() {
267 - const text =
268 -`⚙️ <b>تنظیمات ربات Nexa Dev</b>
269 -<code>🏠 Nexa Dev > ⚙️ تنظیمات</code>
260 + const text =
261 +`⚙️ <b>تنظیمات Nexa Dev</b>
262 +<code>🏠 Nexa Dev &gt; ⚙️ تنظیمات</code>
263 ➖➖➖➖➖➖➖➖➖➖
271 -• اکانت گیت‌هاب هدف: <code>${DEFAULT_CONFIG.defaultOwner}</code>
272 -• حالت وب‌هوک: <b>Cloudflare Worker Event Handler</b>
273 -• نحوه ناوبری: <b>Single-Message In-Place Edit (حذف پیام‌های هرز)</b>
274 -• زبان رابط کاربری: <b>فارسی (پیش‌فرض)</b>`;
264 +• مالک GitHub پیش‌فرض: <code>${escapeHtml(DEFAULT_CONFIG.defaultOwner)}</code>
265 +• Runtime: <b>Cloudflare Worker</b>
266 +• ناوبری: <b>Single-message / editMessageText</b>
267 +• زبان رابط: <b>فارسی</b>
268
276 - const inlineKeyboard = [
277 - [
278 - { text: '🔙 بازگشت به منوی اصلی', callback_data: 'menu:main' }
279 - ]
280 - ];
269 +مقادیر Secret از این رابط نمایش داده نمی‌شوند.`;
270
282 - return { text, reply_markup: { inline_keyboard: inlineKeyboard } };
271 + return {
272 + text,
273 + reply_markup: { inline_keyboard: [[{ text: '🔙 بازگشت به منوی اصلی', callback_data: 'menu:main' }]] }
274 + };
275 }
276
285 - /**
286 - * Security & Tokens View
287 - */
277 getSecurityView() {
289 - const sec = DEFAULT_CONFIG.securityStatus;
290 - const text =
278 + const text =
279 `🔐 <b>امنیت و دسترسی‌ها</b>
292 -<code>🏠 Nexa Dev > 🔐 امنیت</code>
280 +<code>🏠 Nexa Dev &gt; 🔐 امنیت</code>
281 ➖➖➖➖➖➖➖➖➖➖
294 -• وضعیت توکن: <b>${sec.status}</b>
295 -• نوع دسترسی: <code>${sec.tokenType}</code>
296 -• کاربران مجاز: <code>${sec.allowedUsers.join(', ')}</code>
297 -• محدودیت نرخ (Rate Limit): <code>${sec.rateLimit}</code>
298 -• حفاظت در برابر پیام‌های تکراری و Spam: <b>فعال ✅</b>`;
299 -
300 - const inlineKeyboard = [
301 - [
302 - { text: '🔙 بازگشت به منوی اصلی', callback_data: 'menu:main' }
303 - ]
304 - ];
282 +• Webhook secret: <b>اجباری در Worker</b>
283 +• Owner-only access: <b>اجباری با OWNER_TELEGRAM_ID</b>
284 +• Credentials: <b>خارج از مخزن و خارج از پیام‌های ربات</b>
285 +• Diagnostic ID endpoint: <b>غیرفعال</b>
286
306 - return { text, reply_markup: { inline_keyboard: inlineKeyboard } };
287 +این صفحه وجود یا مقدار Secretهای runtime را افشا نمی‌کند.`;
288 +
289 + return {
290 + text,
291 + reply_markup: { inline_keyboard: [[{ text: '🔙 بازگشت به منوی اصلی', callback_data: 'menu:main' }]] }
292 + };
293 }
294
309 - /**
310 - * Route callback data to corresponding view
311 - */
295 async renderByCallback(callbackData) {
313 - const [action, target, ...extra] = callbackData.split(':');
296 + const [action, target, ...extra] = String(callbackData || '').split(':');
297
298 switch (action) {
299 case 'menu':
@@ -320,41 +303,24 @@ ${tools}`;
303 if (target === 'settings') return this.getSettingsView();
304 if (target === 'security') return this.getSecurityView();
305 return this.getMainMenuView();
323 -
306 case 'repo':
307 return this.getRepoDetailView(target);
326 -
308 case 'pr':
309 return this.getPullRequestsView(target);
329 -
310 case 'commits':
311 return this.getCommitsView(target);
332 -
312 case 'files':
313 return this.getFilesView(target, extra.join(':'));
335 -
314 case 'status':
315 return this.getRepoStatusView(target);
338 -
316 case 'tool':
317 if (target === 'ping') {
318 return {
342 - text: `🏓 <b>Pong!</b>\nپاسخ سرور در <b>12ms</b> دریافت شد.\nاتصال تلگرام و ورکر پایدار است.`,
343 - reply_markup: {
344 - inline_keyboard: [[{ text: '🔙 بازگشت به ابزارها', callback_data: 'menu:tools' }]]
345 - }
346 - };
347 - }
348 - if (target === 'cache_clear') {
349 - return {
350 - text: `🧹 <b>حافظه موقت پاکسازی شد.</b>\nوضعیت ناوبری ریست شد.`,
351 - reply_markup: {
352 - inline_keyboard: [[{ text: '🔙 بازگشت به ابزارها', callback_data: 'menu:tools' }]]
353 - }
319 + text: '🏓 <b>Pong</b>\nمسیر داخلی ربات پاسخ داد. latency شبکه یا سلامت سرویس خارجی در این عملیات اندازه‌گیری نشده است.',
320 + reply_markup: { inline_keyboard: [[{ text: '🔙 بازگشت به ابزارها', callback_data: 'menu:tools' }]] }
321 };
322 }
323 return this.getToolsView();
357 -
324 default:
325 return this.getMainMenuView();
326 }