Personal Telegram developer console for GitHub
fix: show rejected approval feedback in Telegram
davoodmehraban89 committed
Oct 3, 2026 at 08:34 UTC
04855abeeefdc249fccf513b8b39cf0b6a28095b
1 file changed
+43
-1
src/bot.js
+43
-1
@@ -43,6 +43,34 @@ function approvalView({ label, token, repoId, runId }) {
43
};
44
}
45
46
+function approvalRejectedView(message, error) {
47
+ const reason = String(error?.message || 'Approval rejected');
48
+ const expired = /expired/i.test(reason);
49
+ const used = /already used|replay/i.test(reason);
50
+ const fallback = message?.reply_markup?.inline_keyboard
51
+ ?.flat()
52
+ .map(button => String(button?.callback_data || ''))
53
+ .find(callback => callback && !callback.startsWith('approve:')) || 'menu:main';
54
+
55
+ let detail = 'این تأیید معتبر نیست و هیچ تغییری اجرا نشد.';
56
+ if (expired) detail = 'مهلت این تأیید تمام شده است و هیچ تغییری اجرا نشد.';
57
+ if (used) detail = 'این تأیید قبلاً استفاده شده است و دوباره اجرا نمیشود.';
58
+
59
+ return {
60
+ text:
61
+`⚠️ <b>عملیات اجرا نشد</b>
62
+➖➖➖➖➖➖➖➖➖➖
63
+${detail}
64
+
65
+برای ادامه به صفحهٔ Run برگردید و در صورت نیاز یک تأیید تازه ایجاد کنید.`,
66
+ reply_markup: {
67
+ inline_keyboard: [
68
+ [{ text: '↩️ بازگشت به Run', callback_data: fallback }]
69
+ ]
70
+ }
71
+ };
72
+}
73
+
74
export class NexaDevBot {
75
constructor(env = {}) {
76
this.env = env;
@@ -123,7 +151,21 @@ export class NexaDevBot {
151
outcome: 'rejected',
152
error: error?.message || 'Approval rejected'
153
});
126
- throw error;
154
+ const view = approvalRejectedView(message, error);
155
+ const res = await this.telegram.editMessageText(
156
+ chatId,
157
+ messageId,
158
+ view.text,
159
+ view.reply_markup
160
+ );
161
+ return {
162
+ ok: false,
163
+ approvalRejected: true,
164
+ error: error?.message || 'Approval rejected',
165
+ callbackAnswered,
166
+ edited: true,
167
+ res
168
+ };
169
}
170
171
this.audit.log({