@llblab/pi-telegram 0.6.3 → 0.7.1
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/AGENTS.md +153 -0
- package/BACKLOG.md +5 -0
- package/CHANGELOG.md +148 -0
- package/README.md +40 -39
- package/docs/README.md +1 -0
- package/docs/architecture.md +36 -27
- package/docs/attachment-handlers.md +4 -6
- package/docs/callback-namespaces.md +36 -0
- package/docs/command-templates.md +53 -9
- package/docs/locks.md +4 -0
- package/docs/outbound-handlers.md +6 -5
- package/index.ts +60 -7
- package/lib/api.ts +1 -0
- package/lib/attachment-handlers.ts +21 -10
- package/lib/attachments.ts +1 -0
- package/lib/command-templates.ts +37 -3
- package/lib/commands.ts +363 -88
- package/lib/config.ts +6 -2
- package/lib/keyboard.ts +14 -0
- package/lib/lifecycle.ts +26 -0
- package/lib/locks.ts +3 -2
- package/lib/media.ts +1 -0
- package/lib/menu-model.ts +881 -0
- package/lib/menu-queue.ts +610 -0
- package/lib/menu-status.ts +226 -0
- package/lib/menu-thinking.ts +171 -0
- package/lib/menu.ts +143 -1019
- package/lib/model.ts +1 -0
- package/lib/outbound-handlers.ts +28 -19
- package/lib/pi.ts +8 -0
- package/lib/polling.ts +1 -0
- package/lib/preview.ts +97 -50
- package/lib/prompt-templates.ts +150 -0
- package/lib/prompts.ts +2 -0
- package/lib/queue.ts +60 -15
- package/lib/rendering.ts +1 -0
- package/lib/replies.ts +90 -2
- package/lib/routing.ts +106 -14
- package/lib/runtime.ts +2 -0
- package/lib/setup.ts +1 -0
- package/lib/status.ts +18 -6
- package/lib/turns.ts +1 -0
- package/lib/updates.ts +55 -6
- package/package.json +5 -2
package/lib/updates.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Telegram updates domain helpers
|
|
3
|
+
* Zones: telegram inbound, authorization, routing plans
|
|
3
4
|
* Owns update extraction, authorization, classification, execution planning, and runtime execution for Telegram updates
|
|
4
5
|
*/
|
|
5
6
|
|
|
@@ -25,6 +26,19 @@ export type TelegramReactionType =
|
|
|
25
26
|
| TelegramReactionTypeEmoji
|
|
26
27
|
| TelegramReactionTypeNonEmoji;
|
|
27
28
|
|
|
29
|
+
export const TELEGRAM_PRIORITY_REACTION_EMOJIS = [
|
|
30
|
+
"👍",
|
|
31
|
+
"⚡",
|
|
32
|
+
"❤",
|
|
33
|
+
"🕊",
|
|
34
|
+
] as const;
|
|
35
|
+
export const TELEGRAM_REMOVAL_REACTION_EMOJIS = [
|
|
36
|
+
"👎",
|
|
37
|
+
"👻",
|
|
38
|
+
"💔",
|
|
39
|
+
"💩",
|
|
40
|
+
] as const;
|
|
41
|
+
|
|
28
42
|
export interface TelegramUpdateDeletion {
|
|
29
43
|
deleted_business_messages?: { message_ids?: unknown };
|
|
30
44
|
}
|
|
@@ -50,6 +64,23 @@ export function collectTelegramReactionEmojis(
|
|
|
50
64
|
);
|
|
51
65
|
}
|
|
52
66
|
|
|
67
|
+
function hasAnyTelegramReactionEmoji(
|
|
68
|
+
emojis: Set<string>,
|
|
69
|
+
candidates: readonly string[],
|
|
70
|
+
): boolean {
|
|
71
|
+
return candidates.some((emoji) => emojis.has(emoji));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function hasAddedTelegramReactionEmoji(
|
|
75
|
+
oldEmojis: Set<string>,
|
|
76
|
+
newEmojis: Set<string>,
|
|
77
|
+
candidates: readonly string[],
|
|
78
|
+
): boolean {
|
|
79
|
+
return candidates.some(
|
|
80
|
+
(emoji) => !oldEmojis.has(emoji) && newEmojis.has(emoji),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
53
84
|
export function extractDeletedTelegramMessageIds(
|
|
54
85
|
update: TelegramUpdateDeletion,
|
|
55
86
|
): number[] {
|
|
@@ -579,8 +610,13 @@ export async function handleAuthorizedTelegramReactionUpdate<TContext>(
|
|
|
579
610
|
}
|
|
580
611
|
const oldEmojis = collectTelegramReactionEmojis(reactionUpdate.old_reaction);
|
|
581
612
|
const newEmojis = collectTelegramReactionEmojis(reactionUpdate.new_reaction);
|
|
582
|
-
|
|
583
|
-
|
|
613
|
+
if (
|
|
614
|
+
hasAddedTelegramReactionEmoji(
|
|
615
|
+
oldEmojis,
|
|
616
|
+
newEmojis,
|
|
617
|
+
TELEGRAM_REMOVAL_REACTION_EMOJIS,
|
|
618
|
+
)
|
|
619
|
+
) {
|
|
584
620
|
deps.removePendingMediaGroupMessages([reactionUpdate.message_id]);
|
|
585
621
|
deps.removeQueuedTelegramTurnsByMessageIds(
|
|
586
622
|
[reactionUpdate.message_id],
|
|
@@ -588,15 +624,28 @@ export async function handleAuthorizedTelegramReactionUpdate<TContext>(
|
|
|
588
624
|
);
|
|
589
625
|
return;
|
|
590
626
|
}
|
|
591
|
-
const
|
|
592
|
-
|
|
627
|
+
const hadPriorityReaction = hasAnyTelegramReactionEmoji(
|
|
628
|
+
oldEmojis,
|
|
629
|
+
TELEGRAM_PRIORITY_REACTION_EMOJIS,
|
|
630
|
+
);
|
|
631
|
+
const hasPriorityReaction = hasAnyTelegramReactionEmoji(
|
|
632
|
+
newEmojis,
|
|
633
|
+
TELEGRAM_PRIORITY_REACTION_EMOJIS,
|
|
634
|
+
);
|
|
635
|
+
if (hadPriorityReaction && !hasPriorityReaction) {
|
|
593
636
|
deps.clearQueuedTelegramTurnPriorityByMessageId(
|
|
594
637
|
reactionUpdate.message_id,
|
|
595
638
|
deps.ctx,
|
|
596
639
|
);
|
|
597
640
|
}
|
|
598
|
-
|
|
599
|
-
|
|
641
|
+
if (
|
|
642
|
+
!hasAddedTelegramReactionEmoji(
|
|
643
|
+
oldEmojis,
|
|
644
|
+
newEmojis,
|
|
645
|
+
TELEGRAM_PRIORITY_REACTION_EMOJIS,
|
|
646
|
+
)
|
|
647
|
+
)
|
|
648
|
+
return;
|
|
600
649
|
deps.prioritizeQueuedTelegramTurnByMessageId(
|
|
601
650
|
reactionUpdate.message_id,
|
|
602
651
|
deps.ctx,
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@llblab/pi-telegram",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "Better Telegram DM bridge extension for
|
|
5
|
+
"description": "Better Telegram DM bridge extension for π",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"pi-package",
|
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
"index.ts",
|
|
32
32
|
"lib/",
|
|
33
33
|
"README.md",
|
|
34
|
+
"AGENTS.md",
|
|
35
|
+
"BACKLOG.md",
|
|
36
|
+
"CHANGELOG.md",
|
|
34
37
|
"docs/",
|
|
35
38
|
"screenshot.png"
|
|
36
39
|
],
|