Personal Telegram developer console for GitHub
feat/studio-g0-foundation
audit/commit-drilldown
audit/finalize-workspace-menu-security
audit/ops-actionability
audit/pr-menu-consolidation
audit/status-menu-consolidation
audit/telegram-menu-e2e
audit/telegram-menu-e2e-wave2
chore/actions-node24-runtime
cleanup/remove-diag
design/cloudflare-ops-read
docs/control-plane-2-7-design
docs/guide-v2-1-sync
docs/menu-audit-final-sync
docs/phase2-acceptance-closeout
docs/phase2-multifile-design
feat/bootstrap-worker
feat/cloudflare-ops-read
feat/cp2-multifile-final
feat/cp2-multifile-workspace
feat/cp3-github-write-final
feat/cp4-cloudflare-ops-final
feat/cp5-cicd-control-plane
feat/cp6-incident-manager
feat/cp7-automation-engine
feat/deep-file-browser
feat/final-delivery-16-20
feat/github-advanced-read
feat/in-app-guide-v2
feat/navigation-recovery-ux-v2
feat/ops-console-v2-1
feat/persistent-menu-code-input
feat/phase2-multifile-workspace
feat/phase2-multifile-workspace-v2
feat/plugin-foundation-v1
feat/safe-github-ops
feat/self-register-webhook
feat/studio-g0-foundation
feat/telegram-main-inline-menu
feat/telegram-pr-merge
feat/ux-platform-8-12
feat/v3a-readonly-copilot
feat/workspace-file-upload
feature/mobile-repo-browser
feature/multi-file-change-set
fix/approval-expiry-feedback
fix/callback-resilience-and-docs
fix/ci-actions-pagination
fix/cloudflare-fetch-binding
fix/editor-request-body-cap
fix/editor-safe-file-options
fix/issues-permission-release-empty-ux
fix/main-menu-callback-fallback
fix/phase2-file-editor-selection
fix/phase2-final-ux
fix/phase2-workspace-ref-persistence
fix/production-auto-deploy
fix/provider-write-error-feedback
fix/repository-id-navigation-fallback
fix/repository-pr-navigation
fix/telegram-callback-updates
fix/telegram-runtime-diagnostics
fix/workspace-editor-flow-v2
fix/workspace-recovery-validation
hardening/ci-zero-test-telegram-token
hardening/pr1-destructive-totp
hardening/pr2-kill-switch
main
multifile-workspace
nexa/edit-BwJEIIY3PW
nexa/edit-IPHT8irO7b
nexa/edit-b4Od3BIMYd
p2-multifile
phase2-20261005
phase2-20261005-a
phase2-20261005-b
phase2-20261005-c
phase2-20261005-d
phase2-20261005-e
phase2-20261005-f
phase2-20261005-g
phase2-20261005-h
phase2-20261005-i
phase2-20261005-j
phase2-20261005-k
phase2-20261005-l
phase2-20261005-m
phase2-20261005-n
phase2-20261005-o
phase2-20261005-p
phase2-20261005-q
phase2-20261005-r
phase2-20261005-s
phase2-20261005-t
phase2-20261005-u
phase2-20261005-v
phase2-20261005-w
phase2-20261005-x
phase2-20261005-y
phase2-20261005-z
phase2-acceptance-closeout
phase2-add-file-hotfix
phase2-change-set
phase2-design-20261005
phase2-design-final
phase2-implementation
phase2-multifile-implementation
phase2-multifile-spec
phase2-spec-final
phase2-workspace
phase2/multifile-workspace
plan/nexa-studio-v2-reviewed
security/remove-telegram-setup
spec/repository-workspace-editor
v3a/multifile
work/multifile
| 1 | import { DEFAULT_CONFIG } from './config.js'; |
| 2 | |
| 3 | function escapeHtml(value = '') { |
| 4 | return String(value) |
| 5 | .replaceAll('&', '&') |
| 6 | .replaceAll('<', '<') |
| 7 | .replaceAll('>', '>') |
| 8 | .replaceAll('"', '"'); |
| 9 | } |
| 10 | |
| 11 | function callbackFits(value) { |
| 12 | return new TextEncoder().encode(String(value)).length <= 64; |
| 13 | } |
| 14 | |
| 15 | function fileItemRows(repoId, items) { |
| 16 | const rows = []; |
| 17 | for (const item of items.slice(0, 30)) { |
| 18 | const action = item.type === 'dir' ? 'tree' : 'blob'; |
| 19 | const callbackData = `${action}:${repoId}:${item.sha}`; |
| 20 | if (!item.sha || !callbackFits(callbackData)) continue; |
| 21 | rows.push([ |
| 22 | { |
| 23 | text: `${item.type === 'dir' ? '📁' : '📄'} ${item.name}`, |
| 24 | callback_data: callbackData |
| 25 | } |
| 26 | ]); |
| 27 | } |
| 28 | return rows; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Menu Router and UI Generator for Nexa Dev Bot. |
| 33 | * Views never claim external service health unless that view was built from a live API response. |
| 34 | */ |
| 35 | export class MenuManager { |
| 36 | constructor(githubService) { |
| 37 | this.github = githubService; |
| 38 | } |
| 39 | |
| 40 | getMainMenuView() { |
| 41 | const text = `⚡ <b>Nexa Dev Bot | پنل مدیریت توسعه</b> |
| 42 | ➖➖➖➖➖➖➖➖➖➖ |
| 43 | یکی از بخشهای زیر را انتخاب کنید. |
| 44 | اتصال GitHub هنگام باز کردن مخزنها بهصورت زنده بررسی میشود.`; |
| 45 | |
| 46 | return { |
| 47 | text, |
| 48 | reply_markup: { |
| 49 | inline_keyboard: [ |
| 50 | [ |
| 51 | { text: '📁 مخزنها (پروژهها)', callback_data: 'menu:repos' }, |
| 52 | { text: '📊 وضعیت سرویس', callback_data: 'menu:status' } |
| 53 | ], |
| 54 | [ |
| 55 | { text: '🔧 ابزارهای توسعه', callback_data: 'menu:tools' }, |
| 56 | { text: '⚙️ تنظیمات', callback_data: 'menu:settings' } |
| 57 | ], |
| 58 | [{ text: '🔐 امنیت', callback_data: 'menu:security' }] |
| 59 | ] |
| 60 | } |
| 61 | }; |
| 62 | } |
| 63 | |
| 64 | async getReposListView() { |
| 65 | const repos = await this.github.listRepositories(); |
| 66 | const text = `📁 <b>فهرست مخزنها و پروژهها</b> |
| 67 | <code>🏠 Nexa Dev > 📁 مخزنها</code> |
| 68 | ➖➖➖➖➖➖➖➖➖➖ |
| 69 | این فهرست از GitHub API دریافت شده است. پروژه مورد نظر را انتخاب کنید:`; |
| 70 | |
| 71 | const inlineKeyboard = []; |
| 72 | for (let i = 0; i < repos.length; i += 2) { |
| 73 | const row = []; |
| 74 | row.push({ |
| 75 | text: `${repos[i].private ? '🔒' : '🌐'} ${repos[i].name}`, |
| 76 | callback_data: `repo:${repos[i].id}` |
| 77 | }); |
| 78 | if (repos[i + 1]) { |
| 79 | row.push({ |
| 80 | text: `${repos[i + 1].private ? '🔒' : '🌐'} ${repos[i + 1].name}`, |
| 81 | callback_data: `repo:${repos[i + 1].id}` |
| 82 | }); |
| 83 | } |
| 84 | inlineKeyboard.push(row); |
| 85 | } |
| 86 | |
| 87 | if (!repos.length) { |
| 88 | inlineKeyboard.push([ |
| 89 | { text: '🔄 بررسی مجدد', callback_data: 'menu:repos' } |
| 90 | ]); |
| 91 | } |
| 92 | inlineKeyboard.push([ |
| 93 | { text: '🔙 بازگشت به منوی اصلی', callback_data: 'menu:main' } |
| 94 | ]); |
| 95 | |
| 96 | return { text, reply_markup: { inline_keyboard: inlineKeyboard } }; |
| 97 | } |
| 98 | |
| 99 | async getRepoDetailView(repoId) { |
| 100 | const repo = await this.github.getRepository(repoId); |
| 101 | const visibility = repo.private ? '🔒 خصوصی' : '🌐 عمومی'; |
| 102 | const archived = repo.archived ? '\n⚠️ وضعیت: آرشیوشده' : ''; |
| 103 | const description = repo.description |
| 104 | ? `\n📝 ${escapeHtml(repo.description)}` |
| 105 | : ''; |
| 106 | const text = `📦 <b>پروژه: ${escapeHtml(repo.name)}</b> |
| 107 | <code>🏠 Nexa Dev > 📁 مخزنها > ${escapeHtml(repo.name)}</code> |
| 108 | ➖➖➖➖➖➖➖➖➖➖ |
| 109 | 👤 مخزن: <code>${escapeHtml(repo.fullName)}</code> |
| 110 | 👁 دسترسی: ${visibility} |
| 111 | 🌿 شاخه پیشفرض: <code>${escapeHtml(repo.defaultBranch)}</code>${archived}${description} |
| 112 | |
| 113 | اطلاعات بالا از GitHub API دریافت شد. یک عملیات را انتخاب کنید:`; |
| 114 | |
| 115 | return { |
| 116 | text, |
| 117 | reply_markup: { |
| 118 | inline_keyboard: [ |
| 119 | [ |
| 120 | { text: '📂 فایلها', callback_data: `files:${repoId}` }, |
| 121 | { text: '🔀 Pull Requestها', callback_data: `pr:${repoId}` } |
| 122 | ], |
| 123 | [ |
| 124 | { text: '📝 Commitها', callback_data: `commits:${repoId}` }, |
| 125 | { text: '📊 وضعیت / تستها', callback_data: `status:${repoId}` } |
| 126 | ], |
| 127 | [{ text: '🔙 بازگشت به لیست پروژهها', callback_data: 'menu:repos' }] |
| 128 | ] |
| 129 | } |
| 130 | }; |
| 131 | } |
| 132 | |
| 133 | async getPullRequestsView(repoId) { |
| 134 | const [repo, prs] = await Promise.all([ |
| 135 | this.github.getRepository(repoId), |
| 136 | this.github.listPullRequests(repoId) |
| 137 | ]); |
| 138 | const prListText = prs.length |
| 139 | ? prs |
| 140 | .map((pr) => { |
| 141 | const state = pr.merged |
| 142 | ? '🟣 Merged' |
| 143 | : pr.state === 'open' |
| 144 | ? '🟢 Open' |
| 145 | : '🔴 Closed'; |
| 146 | return `• <b>#${pr.number}</b> ${escapeHtml(pr.title)}\n └ <i>${escapeHtml(pr.author)} | ${state}</i>`; |
| 147 | }) |
| 148 | .join('\n\n') |
| 149 | : '<i>Pull Requestی در پاسخ GitHub یافت نشد.</i>'; |
| 150 | |
| 151 | const text = `🔀 <b>Pull Requestهای پروژه ${escapeHtml(repo.name)}</b> |
| 152 | <code>🏠 Nexa Dev > 📁 مخزنها > ${escapeHtml(repo.name)} > 🔀 Pull Request</code> |
| 153 | ➖➖➖➖➖➖➖➖➖➖ |
| 154 | ${prListText}`; |
| 155 | |
| 156 | return { |
| 157 | text, |
| 158 | reply_markup: { |
| 159 | inline_keyboard: [ |
| 160 | [ |
| 161 | { text: '🔄 بروزرسانی', callback_data: `pr:${repoId}` }, |
| 162 | { text: '🔙 بازگشت به پروژه', callback_data: `repo:${repoId}` } |
| 163 | ] |
| 164 | ] |
| 165 | } |
| 166 | }; |
| 167 | } |
| 168 | |
| 169 | async getCommitsView(repoId) { |
| 170 | const [repo, commits] = await Promise.all([ |
| 171 | this.github.getRepository(repoId), |
| 172 | this.github.listCommits(repoId) |
| 173 | ]); |
| 174 | const commitListText = commits.length |
| 175 | ? commits |
| 176 | .map( |
| 177 | (c) => |
| 178 | `• <code>${escapeHtml(c.sha)}</code> - ${escapeHtml(c.message)}\n └ <i>${escapeHtml(c.author)}${c.date ? ` | ${escapeHtml(c.date)}` : ''}</i>` |
| 179 | ) |
| 180 | .join('\n\n') |
| 181 | : '<i>کامیتی در پاسخ GitHub یافت نشد.</i>'; |
| 182 | |
| 183 | const text = `📝 <b>آخرین Commitهای پروژه ${escapeHtml(repo.name)}</b> |
| 184 | <code>🏠 Nexa Dev > 📁 مخزنها > ${escapeHtml(repo.name)} > 📝 Commitها</code> |
| 185 | ➖➖➖➖➖➖➖➖➖➖ |
| 186 | ${commitListText}`; |
| 187 | |
| 188 | return { |
| 189 | text, |
| 190 | reply_markup: { |
| 191 | inline_keyboard: [ |
| 192 | [ |
| 193 | { text: '🔄 بروزرسانی', callback_data: `commits:${repoId}` }, |
| 194 | { text: '🔙 بازگشت به پروژه', callback_data: `repo:${repoId}` } |
| 195 | ] |
| 196 | ] |
| 197 | } |
| 198 | }; |
| 199 | } |
| 200 | |
| 201 | async getFilesView(repoId, subpath = '') { |
| 202 | const [repo, files] = await Promise.all([ |
| 203 | this.github.getRepository(repoId), |
| 204 | this.github.listFiles(repoId, subpath) |
| 205 | ]); |
| 206 | const visibleItems = files.slice(0, 30); |
| 207 | const itemsText = visibleItems.length |
| 208 | ? visibleItems |
| 209 | .map((f) => { |
| 210 | const icon = f.type === 'dir' ? '📁' : '📄'; |
| 211 | const size = f.type === 'file' && f.size ? ` (${f.size} B)` : ''; |
| 212 | return `${icon} <code>${escapeHtml(f.name)}</code>${size}`; |
| 213 | }) |
| 214 | .join('\n') |
| 215 | : '<i>پوشه خالی است.</i>'; |
| 216 | const omitted = |
| 217 | files.length > visibleItems.length |
| 218 | ? `\n\n<i>${files.length - visibleItems.length} مورد دیگر در این نما نمایش داده نشده است.</i>` |
| 219 | : ''; |
| 220 | |
| 221 | const text = `📂 <b>ساختار فایلهای پروژه ${escapeHtml(repo.name)}</b> |
| 222 | <code>🏠 Nexa Dev > 📁 مخزنها > ${escapeHtml(repo.name)} > 📂 فایلها${subpath ? ` > ${escapeHtml(subpath)}` : ''}</code> |
| 223 | ➖➖➖➖➖➖➖➖➖➖ |
| 224 | ${itemsText}${omitted}`; |
| 225 | |
| 226 | const inlineKeyboard = fileItemRows(repoId, visibleItems); |
| 227 | inlineKeyboard.push([ |
| 228 | { |
| 229 | text: '🔄 بروزرسانی', |
| 230 | callback_data: `files:${repoId}${subpath ? `:${subpath}` : ''}` |
| 231 | }, |
| 232 | { text: '🔙 بازگشت به پروژه', callback_data: `repo:${repoId}` } |
| 233 | ]); |
| 234 | |
| 235 | return { text, reply_markup: { inline_keyboard: inlineKeyboard } }; |
| 236 | } |
| 237 | |
| 238 | async getTreeView(repoId, sha) { |
| 239 | const [repo, items] = await Promise.all([ |
| 240 | this.github.getRepository(repoId), |
| 241 | this.github.listTree(repoId, sha) |
| 242 | ]); |
| 243 | const visibleItems = items.slice(0, 30); |
| 244 | const itemsText = visibleItems.length |
| 245 | ? visibleItems |
| 246 | .map((item) => { |
| 247 | const icon = item.type === 'dir' ? '📁' : '📄'; |
| 248 | const size = |
| 249 | item.type === 'file' && item.size ? ` (${item.size} B)` : ''; |
| 250 | return `${icon} <code>${escapeHtml(item.name)}</code>${size}`; |
| 251 | }) |
| 252 | .join('\n') |
| 253 | : '<i>این پوشه خالی است.</i>'; |
| 254 | const omitted = |
| 255 | items.length > visibleItems.length |
| 256 | ? `\n\n<i>${items.length - visibleItems.length} مورد دیگر در این نما نمایش داده نشده است.</i>` |
| 257 | : ''; |
| 258 | |
| 259 | const text = `📁 <b>پوشه در ${escapeHtml(repo.name)}</b> |
| 260 | <code>🏠 Nexa Dev > 📁 مخزنها > ${escapeHtml(repo.name)} > 📂 فایلها > پوشه</code> |
| 261 | ➖➖➖➖➖➖➖➖➖➖ |
| 262 | ${itemsText}${omitted}`; |
| 263 | |
| 264 | const inlineKeyboard = fileItemRows(repoId, visibleItems); |
| 265 | inlineKeyboard.push([ |
| 266 | { text: '🔙 ریشه فایلها', callback_data: `files:${repoId}` }, |
| 267 | { text: '📦 پروژه', callback_data: `repo:${repoId}` } |
| 268 | ]); |
| 269 | |
| 270 | return { text, reply_markup: { inline_keyboard: inlineKeyboard } }; |
| 271 | } |
| 272 | |
| 273 | async getBlobView(repoId, sha) { |
| 274 | const repo = await this.github.getRepository(repoId); |
| 275 | const body = |
| 276 | 'محتوای فایل در پیام تلگرام ارسال نمیشود. از مسیر فایلها، فایل را در Mini App باز کنید.'; |
| 277 | |
| 278 | const text = `📄 <b>پیشنمایش فایل در ${escapeHtml(repo.name)}</b> |
| 279 | <code>🏠 Nexa Dev > 📁 مخزنها > ${escapeHtml(repo.name)} > 📂 فایلها > فایل</code> |
| 280 | ➖➖➖➖➖➖➖➖➖➖ |
| 281 | ${body} |
| 282 | Ref: <code>${escapeHtml(String(sha || '').slice(0, 10))}</code>`; |
| 283 | |
| 284 | return { |
| 285 | text, |
| 286 | reply_markup: { |
| 287 | inline_keyboard: [ |
| 288 | [ |
| 289 | { text: '🔙 ریشه فایلها', callback_data: `files:${repoId}` }, |
| 290 | { text: '📦 پروژه', callback_data: `repo:${repoId}` } |
| 291 | ] |
| 292 | ] |
| 293 | } |
| 294 | }; |
| 295 | } |
| 296 | |
| 297 | async getRepoStatusView(repoId) { |
| 298 | const status = await this.github.getRepoStatus(repoId); |
| 299 | const runsText = status.lastRuns.length |
| 300 | ? status.lastRuns |
| 301 | .map((r) => { |
| 302 | const icon = |
| 303 | r.conclusion === 'success' |
| 304 | ? '✅' |
| 305 | : r.conclusion === 'failure' |
| 306 | ? '❌' |
| 307 | : '⏳'; |
| 308 | return `• ${icon} <b>${escapeHtml(r.name)}</b>: ${escapeHtml(r.conclusion || r.status || 'unknown')}\n └ <i>${escapeHtml(r.commit || '')}</i>`; |
| 309 | }) |
| 310 | .join('\n') |
| 311 | : '<i>Workflow runی در پاسخ GitHub یافت نشد.</i>'; |
| 312 | |
| 313 | const label = status.repoName || repoId; |
| 314 | const text = `📊 <b>وضعیت پایپلاین ${escapeHtml(label)}</b> |
| 315 | <code>🏠 Nexa Dev > 📁 مخزنها > ${escapeHtml(label)} > 📊 وضعیت</code> |
| 316 | ➖➖➖➖➖➖➖➖➖➖ |
| 317 | شاخه پیشفرض: <code>${escapeHtml(status.defaultBranch)}</code> |
| 318 | آخرین نتایج GitHub Actions: |
| 319 | |
| 320 | ${runsText}`; |
| 321 | |
| 322 | return { |
| 323 | text, |
| 324 | reply_markup: { |
| 325 | inline_keyboard: [ |
| 326 | [ |
| 327 | { text: '🔄 بروزرسانی', callback_data: `status:${repoId}` }, |
| 328 | { text: '🔙 بازگشت به پروژه', callback_data: `repo:${repoId}` } |
| 329 | ] |
| 330 | ] |
| 331 | } |
| 332 | }; |
| 333 | } |
| 334 | |
| 335 | getServiceStatusView() { |
| 336 | const text = `📊 <b>وضعیت سیستم و سرویسها</b> |
| 337 | <code>🏠 Nexa Dev > 📊 وضعیت سرویس</code> |
| 338 | ➖➖➖➖➖➖➖➖➖➖ |
| 339 | • <b>Cloudflare Worker:</b> این درخواست توسط Worker پاسخ داده شد. |
| 340 | • <b>Telegram Webhook:</b> secret و owner در مرز ورودی Worker enforce میشوند؛ مقادیر محرمانه نمایش داده نمیشوند. |
| 341 | • <b>GitHub API:</b> هنگام باز کردن مخزنها و وضعیت پروژه بهصورت زنده فراخوانی میشود. |
| 342 | • <b>CI/CD:</b> نتیجه هر مخزن از GitHub Actions خوانده میشود. |
| 343 | |
| 344 | این صفحه SLA، latency یا سلامت سرویس خارجی را بدون اندازهگیری واقعی اعلام نمیکند.`; |
| 345 | |
| 346 | return { |
| 347 | text, |
| 348 | reply_markup: { |
| 349 | inline_keyboard: [ |
| 350 | [ |
| 351 | { text: '🔄 بررسی مجدد', callback_data: 'menu:status' }, |
| 352 | { text: '🔙 بازگشت به منوی اصلی', callback_data: 'menu:main' } |
| 353 | ] |
| 354 | ] |
| 355 | } |
| 356 | }; |
| 357 | } |
| 358 | |
| 359 | getToolsView() { |
| 360 | const tools = DEFAULT_CONFIG.devTools |
| 361 | .map((t) => `• <b>${t.title}</b>\n └ <i>${t.desc}</i>`) |
| 362 | .join('\n\n'); |
| 363 | const text = `🔧 <b>ابزارهای توسعه</b> |
| 364 | <code>🏠 Nexa Dev > 🔧 ابزارهای توسعه</code> |
| 365 | ➖➖➖➖➖➖➖➖➖➖ |
| 366 | ${tools}`; |
| 367 | |
| 368 | return { |
| 369 | text, |
| 370 | reply_markup: { |
| 371 | inline_keyboard: [ |
| 372 | [{ text: '🏓 بررسی مسیر داخلی', callback_data: 'tool:ping' }], |
| 373 | [{ text: '🔙 بازگشت به منوی اصلی', callback_data: 'menu:main' }] |
| 374 | ] |
| 375 | } |
| 376 | }; |
| 377 | } |
| 378 | |
| 379 | getSettingsView() { |
| 380 | const text = `⚙️ <b>تنظیمات Nexa Dev</b> |
| 381 | <code>🏠 Nexa Dev > ⚙️ تنظیمات</code> |
| 382 | ➖➖➖➖➖➖➖➖➖➖ |
| 383 | • مالک GitHub پیشفرض: <code>${escapeHtml(DEFAULT_CONFIG.defaultOwner)}</code> |
| 384 | • Runtime: <b>Cloudflare Worker</b> |
| 385 | • ناوبری: <b>Single-message / editMessageText</b> |
| 386 | • زبان رابط: <b>فارسی</b> |
| 387 | |
| 388 | مقادیر Secret از این رابط نمایش داده نمیشوند.`; |
| 389 | |
| 390 | return { |
| 391 | text, |
| 392 | reply_markup: { |
| 393 | inline_keyboard: [ |
| 394 | [{ text: '🔙 بازگشت به منوی اصلی', callback_data: 'menu:main' }] |
| 395 | ] |
| 396 | } |
| 397 | }; |
| 398 | } |
| 399 | |
| 400 | getSecurityView() { |
| 401 | const text = `🔐 <b>امنیت و دسترسیها</b> |
| 402 | <code>🏠 Nexa Dev > 🔐 امنیت</code> |
| 403 | ➖➖➖➖➖➖➖➖➖➖ |
| 404 | • Webhook secret: <b>اجباری در Worker</b> |
| 405 | • Owner-only access: <b>اجباری با OWNER_TELEGRAM_ID</b> |
| 406 | • Credentials: <b>خارج از مخزن و خارج از پیامهای ربات</b> |
| 407 | • Diagnostic ID endpoint: <b>غیرفعال</b> |
| 408 | |
| 409 | این صفحه وجود یا مقدار Secretهای runtime را افشا نمیکند.`; |
| 410 | |
| 411 | return { |
| 412 | text, |
| 413 | reply_markup: { |
| 414 | inline_keyboard: [ |
| 415 | [{ text: '🔙 بازگشت به منوی اصلی', callback_data: 'menu:main' }] |
| 416 | ] |
| 417 | } |
| 418 | }; |
| 419 | } |
| 420 | |
| 421 | async renderByCallback(callbackData) { |
| 422 | const [action, target, ...extra] = String(callbackData || '').split(':'); |
| 423 | |
| 424 | switch (action) { |
| 425 | case 'menu': |
| 426 | if (target === 'repos') return this.getReposListView(); |
| 427 | if (target === 'status') return this.getServiceStatusView(); |
| 428 | if (target === 'tools') return this.getToolsView(); |
| 429 | if (target === 'settings') return this.getSettingsView(); |
| 430 | if (target === 'security') return this.getSecurityView(); |
| 431 | return this.getMainMenuView(); |
| 432 | case 'repo': |
| 433 | return this.getRepoDetailView(target); |
| 434 | case 'pr': |
| 435 | return this.getPullRequestsView(target); |
| 436 | case 'commits': |
| 437 | return this.getCommitsView(target); |
| 438 | case 'files': |
| 439 | return this.getFilesView(target, extra.join(':')); |
| 440 | case 'tree': |
| 441 | return this.getTreeView(target, extra[0]); |
| 442 | case 'blob': |
| 443 | return this.getBlobView(target, extra[0]); |
| 444 | case 'status': |
| 445 | return this.getRepoStatusView(target); |
| 446 | case 'tool': |
| 447 | if (target === 'ping') { |
| 448 | return { |
| 449 | text: '🏓 <b>Pong</b>\nمسیر داخلی ربات پاسخ داد. latency شبکه یا سلامت سرویس خارجی در این عملیات اندازهگیری نشده است.', |
| 450 | reply_markup: { |
| 451 | inline_keyboard: [ |
| 452 | [{ text: '🔙 بازگشت به ابزارها', callback_data: 'menu:tools' }] |
| 453 | ] |
| 454 | } |
| 455 | }; |
| 456 | } |
| 457 | return this.getToolsView(); |
| 458 | default: |
| 459 | return this.getMainMenuView(); |
| 460 | } |
| 461 | } |
| 462 | } |