polygram 0.12.0-rc.34 → 0.12.0-rc.35
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/lib/handlers/edit-redelivery.js +9 -5
- package/package.json +1 -1
- package/polygram.js +1 -2
|
@@ -25,18 +25,22 @@
|
|
|
25
25
|
* @param {Function} deps.shouldHandle (msg, chatConfig, botUsername) => boolean — the real gate
|
|
26
26
|
* @param {Function} deps.dispatchHandleMessage (sessionKey, chatId, msg, bot) => void
|
|
27
27
|
* @param {object} deps.bot
|
|
28
|
-
* @param {RegExp|null} [deps.mentionRe] strips the @bot mention from the new text for the body
|
|
29
|
-
* @param {string} deps.botUsername
|
|
30
28
|
* @param {Function} [deps.react] (chatId, msgId) => void|Promise — on-edit acknowledgment
|
|
31
29
|
* @param {Function} [deps.logEvent]
|
|
32
30
|
* @param {object} [deps.logger]
|
|
33
|
-
* @returns {(editedMsg
|
|
31
|
+
* @returns {(editedMsg, oldText, botUsername, mentionRe?) => boolean} true when a fresh turn was
|
|
32
|
+
* dispatched. botUsername / mentionRe are passed at CALL time (not construction): they are
|
|
33
|
+
* resolved asynchronously via getMe and live in the createBot scope, so capturing them in the
|
|
34
|
+
* factory (built in main()) would both be out of scope and freeze the empty initial values.
|
|
34
35
|
*/
|
|
35
36
|
function createEditRedelivery({
|
|
36
37
|
pm, config, getSessionKey, shouldHandle, dispatchHandleMessage, bot,
|
|
37
|
-
|
|
38
|
+
react, logEvent = () => {}, logger = console,
|
|
38
39
|
} = {}) {
|
|
39
|
-
|
|
40
|
+
// botUsername / mentionRe arrive at CALL time — see @returns. Constructing with them threw
|
|
41
|
+
// `ReferenceError: mentionRe is not defined` at boot (rc.34): the factory runs in main() where
|
|
42
|
+
// those createBot locals don't exist. The edited_message handler passes the live values.
|
|
43
|
+
return function maybePostTurnEdit(editedMsg, oldText, botUsername, mentionRe = null) {
|
|
40
44
|
try {
|
|
41
45
|
if (!editedMsg?.chat) return false;
|
|
42
46
|
const chatId = editedMsg.chat.id.toString();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polygram",
|
|
3
|
-
"version": "0.12.0-rc.
|
|
3
|
+
"version": "0.12.0-rc.35",
|
|
4
4
|
"description": "Telegram daemon for Claude Code that preserves the OpenClaw per-chat session model. Migration path for OpenClaw users moving to Claude Code.",
|
|
5
5
|
"main": "lib/ipc/client.js",
|
|
6
6
|
"bin": {
|
package/polygram.js
CHANGED
|
@@ -2073,7 +2073,7 @@ function createBot(token) {
|
|
|
2073
2073
|
// self-contained boundary fall-through.
|
|
2074
2074
|
try {
|
|
2075
2075
|
const injected = maybeInjectEditCorrection?.(ctx.editedMessage);
|
|
2076
|
-
if (!injected) maybePostTurnEdit?.(ctx.editedMessage, oldText);
|
|
2076
|
+
if (!injected) maybePostTurnEdit?.(ctx.editedMessage, oldText, botUsername, mentionRe);
|
|
2077
2077
|
} catch (err) {
|
|
2078
2078
|
console.error(`[${BOT_NAME}] edit handler error: ${err.message}`);
|
|
2079
2079
|
}
|
|
@@ -2516,7 +2516,6 @@ async function main() {
|
|
|
2516
2516
|
// pre-turn ack for the cold-spawn gap; the synthetic turn's own reactor then takes over the msg.
|
|
2517
2517
|
maybePostTurnEdit = createEditRedelivery({
|
|
2518
2518
|
pm, config, getSessionKey, shouldHandle, dispatchHandleMessage, bot,
|
|
2519
|
-
mentionRe, botUsername,
|
|
2520
2519
|
react: (chatId, msgId) => applyReactionToMessages({
|
|
2521
2520
|
tg, bot, chatId, msgIds: [msgId], emoji: '👀', botName: BOT_NAME,
|
|
2522
2521
|
}).catch(() => {}),
|