@s0nderlabs/anima-plugin-telegram 0.21.13 → 0.21.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/listener.ts +15 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@s0nderlabs/anima-plugin-telegram",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Telegram gateway plugin for anima — long-poll bot, debounced dispatch, reactions, allowlist",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"test": "bun test"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@s0nderlabs/anima-core": "0.21.
|
|
42
|
+
"@s0nderlabs/anima-core": "0.21.15",
|
|
43
43
|
"grammy": "^1.42.0",
|
|
44
44
|
"zod": "^3.23.8"
|
|
45
45
|
}
|
package/src/listener.ts
CHANGED
|
@@ -122,8 +122,14 @@ export class TelegramListener {
|
|
|
122
122
|
private async handleCallbackQuery(ctx: Context): Promise<void> {
|
|
123
123
|
const q = ctx.callbackQuery
|
|
124
124
|
if (!q) return
|
|
125
|
+
console.log(
|
|
126
|
+
`[telegram] callback_query received from user=${q.from.id} data=${(q.data ?? '').slice(0, 80)}`,
|
|
127
|
+
)
|
|
125
128
|
const parsed = parseCallbackData(q.data)
|
|
126
129
|
if (!parsed) {
|
|
130
|
+
console.log(
|
|
131
|
+
`[telegram] callback_query dropped: malformed data=${(q.data ?? '').slice(0, 80)}`,
|
|
132
|
+
)
|
|
127
133
|
try {
|
|
128
134
|
await ctx.answerCallbackQuery({ text: 'malformed approval callback' })
|
|
129
135
|
} catch {
|
|
@@ -132,6 +138,9 @@ export class TelegramListener {
|
|
|
132
138
|
return
|
|
133
139
|
}
|
|
134
140
|
if (this.opts.allowedUserIds.length > 0 && !this.opts.allowedUserIds.includes(q.from.id)) {
|
|
141
|
+
console.log(
|
|
142
|
+
`[telegram] callback_query dropped: unauthorized user=${q.from.id} (allowlist=${this.opts.allowedUserIds.join(',')})`,
|
|
143
|
+
)
|
|
135
144
|
try {
|
|
136
145
|
await ctx.answerCallbackQuery({ text: '⛔ You are not authorized to approve commands.' })
|
|
137
146
|
} catch {
|
|
@@ -141,6 +150,9 @@ export class TelegramListener {
|
|
|
141
150
|
}
|
|
142
151
|
const resolver = this.approvalResolver
|
|
143
152
|
if (!resolver) {
|
|
153
|
+
console.log(
|
|
154
|
+
`[telegram] callback_query dropped: no resolver pending for approval=${parsed.approvalId} choice=${parsed.choice}`,
|
|
155
|
+
)
|
|
144
156
|
try {
|
|
145
157
|
await ctx.answerCallbackQuery({ text: 'no approval pending' })
|
|
146
158
|
} catch {
|
|
@@ -148,6 +160,9 @@ export class TelegramListener {
|
|
|
148
160
|
}
|
|
149
161
|
return
|
|
150
162
|
}
|
|
163
|
+
console.log(
|
|
164
|
+
`[telegram] callback_query resolved: approval=${parsed.approvalId} choice=${parsed.choice} from=${q.from.id}`,
|
|
165
|
+
)
|
|
151
166
|
resolver(parsed.approvalId, parsed.choice, q.from.id)
|
|
152
167
|
try {
|
|
153
168
|
await ctx.answerCallbackQuery({ text: `✓ ${parsed.choice}` })
|