opencode-telegram-mirror 0.5.0 → 0.6.0
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 +1 -1
- package/src/main.ts +37 -4
package/package.json
CHANGED
package/src/main.ts
CHANGED
|
@@ -289,6 +289,7 @@ async function main() {
|
|
|
289
289
|
{ command: "build", description: "Switch to build mode" },
|
|
290
290
|
{ command: "review", description: "Review changes [commit|branch|pr]" },
|
|
291
291
|
{ command: "rename", description: "Rename the session" },
|
|
292
|
+
{ command: "version", description: "Show mirror bot version" },
|
|
292
293
|
])
|
|
293
294
|
if (commandsResult.status === "error") {
|
|
294
295
|
log("warn", "Failed to set bot commands", { error: commandsResult.error.message })
|
|
@@ -496,6 +497,16 @@ interface TelegramUpdate {
|
|
|
496
497
|
mime_type?: string
|
|
497
498
|
file_size?: number
|
|
498
499
|
}
|
|
500
|
+
video?: {
|
|
501
|
+
file_id: string
|
|
502
|
+
file_unique_id: string
|
|
503
|
+
duration: number
|
|
504
|
+
}
|
|
505
|
+
video_note?: {
|
|
506
|
+
file_id: string
|
|
507
|
+
file_unique_id: string
|
|
508
|
+
duration: number
|
|
509
|
+
}
|
|
499
510
|
from?: { id: number; username?: string }
|
|
500
511
|
chat: { id: number }
|
|
501
512
|
}
|
|
@@ -694,7 +705,7 @@ async function handleTelegramMessage(
|
|
|
694
705
|
msg: NonNullable<TelegramUpdate["message"]>,
|
|
695
706
|
) {
|
|
696
707
|
const messageText = msg.text || msg.caption
|
|
697
|
-
if (!messageText && !msg.photo && !msg.voice) return
|
|
708
|
+
if (!messageText && !msg.photo && !msg.voice && !msg.video && !msg.video_note) return
|
|
698
709
|
|
|
699
710
|
// Ignore all bot messages - context is sent directly via OpenCode API
|
|
700
711
|
if (msg.from?.id === state.botUserId) {
|
|
@@ -757,6 +768,19 @@ async function handleTelegramMessage(
|
|
|
757
768
|
return
|
|
758
769
|
}
|
|
759
770
|
|
|
771
|
+
if (messageText?.trim() === "/version") {
|
|
772
|
+
const pkg = await import("../package.json")
|
|
773
|
+
const sendResult = await state.telegram.sendMessage(
|
|
774
|
+
`opencode-telegram-mirror v${pkg.version}`
|
|
775
|
+
)
|
|
776
|
+
if (sendResult.status === "error") {
|
|
777
|
+
log("error", "Failed to send version response", {
|
|
778
|
+
error: sendResult.error.message,
|
|
779
|
+
})
|
|
780
|
+
}
|
|
781
|
+
return
|
|
782
|
+
}
|
|
783
|
+
|
|
760
784
|
if (messageText?.trim() === "/interrupt") {
|
|
761
785
|
log("info", "Received /interrupt command")
|
|
762
786
|
if (state.sessionId) {
|
|
@@ -849,7 +873,7 @@ async function handleTelegramMessage(
|
|
|
849
873
|
})
|
|
850
874
|
|
|
851
875
|
// Check for freetext answer
|
|
852
|
-
const threadId = state.threadId ??
|
|
876
|
+
const threadId = state.threadId ?? null
|
|
853
877
|
|
|
854
878
|
if (isAwaitingFreetext(msg.chat.id, threadId) && messageText) {
|
|
855
879
|
const result = await handleFreetextAnswer({
|
|
@@ -901,6 +925,14 @@ async function handleTelegramMessage(
|
|
|
901
925
|
}
|
|
902
926
|
}
|
|
903
927
|
|
|
928
|
+
if (msg.video || msg.video_note) {
|
|
929
|
+
log("info", "Rejecting video message - not supported")
|
|
930
|
+
await state.telegram.sendMessage(
|
|
931
|
+
"Video files are not supported. Please send screenshots or audio files instead."
|
|
932
|
+
)
|
|
933
|
+
return
|
|
934
|
+
}
|
|
935
|
+
|
|
904
936
|
// Build prompt parts
|
|
905
937
|
const parts: Array<
|
|
906
938
|
| { type: "text"; text: string }
|
|
@@ -977,7 +1009,8 @@ async function handleTelegramMessage(
|
|
|
977
1009
|
|
|
978
1010
|
const transcribedText = transcriptionResult.value
|
|
979
1011
|
log("info", "Voice transcribed", { preview: transcribedText.slice(0, 50) })
|
|
980
|
-
|
|
1012
|
+
const voiceContext = `[Voice message transcript - may contain transcription inaccuracies]\n\n${transcribedText}`
|
|
1013
|
+
parts.push({ type: "text", text: voiceContext })
|
|
981
1014
|
}
|
|
982
1015
|
|
|
983
1016
|
if (messageText) {
|
|
@@ -1451,7 +1484,7 @@ async function handleOpenCodeEvent(state: BotState, ev: OpenCodeEvent) {
|
|
|
1451
1484
|
}
|
|
1452
1485
|
}
|
|
1453
1486
|
|
|
1454
|
-
const threadId = state.threadId ??
|
|
1487
|
+
const threadId = state.threadId ?? null
|
|
1455
1488
|
|
|
1456
1489
|
if (ev.type === "question.asked") {
|
|
1457
1490
|
await showQuestionButtons({
|