Personal Telegram developer console for GitHub

fix: show Advanced read provider failures in Telegram

davoodmehraban89 committed Oct 3, 2026 at 09:30 UTC 1f67f065c9ab65ab05772e9511e075a2e8454e6d
1 file changed +47
src/bot.js
+47
@@ -99,6 +99,30 @@ ${detail}
99 };
100 }
101
102 +function callbackReadFailedView(data, error) {
103 + const reason = String(error?.message || 'Provider read failed');
104 + const permissionDenied = /403|resource not accessible by personal access token/i.test(reason);
105 + const repoMatch = String(data || '').match(/^[^:]+:(\d+)/);
106 + const fallback = repoMatch ? `repo:${repoMatch[1]}` : 'menu:main';
107 + const detail = permissionDenied
108 + ? 'GitHub این درخواست خواندنی را با خطای 403 رد کرد. مجوز Read مربوط به این بخش در توکن فعلی کافی نیست.'
109 + : 'دریافت اطلاعات از سرویس با خطا مواجه شد. هیچ تغییری انجام نشد.';
110 +
111 + return {
112 + text:
113 +`⚠️ <b>دریافت اطلاعات با خطا مواجه شد</b>
114 +➖➖➖➖➖➖➖➖➖➖
115 +${detail}
116 +
117 +این خطا هیچ عملیات تغییردهنده‌ای اجرا نکرد.`,
118 + reply_markup: {
119 + inline_keyboard: [
120 + [{ text: repoMatch ? '↩️ بازگشت به پروژه' : '↩️ منوی اصلی', callback_data: fallback }]
121 + ]
122 + }
123 + };
124 +}
125 +
126 export class NexaDevBot {
127 constructor(env = {}) {
128 this.env = env;
@@ -323,6 +347,29 @@ export class NexaDevBot {
347 if (err.message && err.message.includes('message is not modified')) {
348 return { ok: true, unmodified: true, callbackAnswered };
349 }
350 +
351 + if (!data.startsWith('approve:')) {
352 + try {
353 + const view = callbackReadFailedView(data, err);
354 + const res = await this.telegram.editMessageText(
355 + chatId,
356 + messageId,
357 + view.text,
358 + view.reply_markup
359 + );
360 + return {
361 + ok: false,
362 + error: err.message,
363 + providerError: true,
364 + callbackAnswered,
365 + edited: true,
366 + res
367 + };
368 + } catch {
369 + // Preserve the original provider/navigation error when feedback delivery also fails.
370 + }
371 + }
372 +
373 return { ok: false, error: err.message, callbackAnswered };
374 }
375 }