@coffer-org/plugin-telegram 2.2.0 → 2.2.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.
@@ -7,7 +7,6 @@ import { NewMessage } from 'teleproto/events/index.js';
7
7
  import { handleIncoming, loadGatePolicy, makeLiveChannel, chunk } from '@coffer-org/plugin-orchestrator/runtime';
8
8
  import { recordUser, recordAssistant, buildChain } from "./chain-store.js";
9
9
  import { loadBotConfig, hasCredentials, loadReasoningDisplay } from "./config.js";
10
- import { saveUploadBytes } from '@coffer-org/server/uploads';
11
10
  import { getLogger } from '@coffer-org/sdk/logger';
12
11
  const log = getLogger('telegram');
13
12
  const FALLBACK_REPLY_WINDOW_MS = 1_800_000;
@@ -89,13 +88,13 @@ function mediaInfo(message) {
89
88
  return { mime: 'image/jpeg', label: 'photo.jpg' };
90
89
  return null;
91
90
  }
92
- async function downloadAttachment(tg, message, info) {
91
+ async function downloadAttachment(tg, message, info, materializer) {
93
92
  const downloaded = await tg.downloadMedia(message, {});
94
93
  if (!downloaded || typeof downloaded === 'string')
95
94
  throw new Error('Telegram returned no in-memory media bytes');
96
95
  const bytes = Buffer.isBuffer(downloaded) ? downloaded : Buffer.from(downloaded);
97
- const stored = await saveUploadBytes(bytes, { originalName: info.label, mime: info.mime });
98
- return { name: stored.name, ...(stored.mime ? { mime: stored.mime } : {}), size: stored.size, label: info.label };
96
+ const stored = await materializer.store(bytes, { originalName: info.label, mime: info.mime });
97
+ return { ...stored, label: info.label };
99
98
  }
100
99
  function loadSessionString(file) {
101
100
  try {
@@ -258,10 +257,10 @@ export async function startBot(opts = {}) {
258
257
  const messages = await buildChain(incomingMsgId, { chatId, fetch, botId: meId ?? '' });
259
258
  let preparedMessages;
260
259
  const prepareAttachments = attachmentInfo
261
- ? async () => {
260
+ ? async (materializer) => {
262
261
  if (preparedMessages)
263
262
  return preparedMessages;
264
- const attachment = await downloadAttachment(tg, message, attachmentInfo);
263
+ const attachment = await downloadAttachment(tg, message, attachmentInfo, materializer);
265
264
  await recordUser({
266
265
  chatId,
267
266
  msgId: incomingMsgId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffer-org/plugin-telegram",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24"
@@ -25,7 +25,7 @@
25
25
  "test": "node --import tsx --test \"src/runtime/*.test.ts\""
26
26
  },
27
27
  "dependencies": {
28
- "@coffer-org/plugin-orchestrator": "^2.2.0",
28
+ "@coffer-org/plugin-orchestrator": "^2.2.1",
29
29
  "@coffer-org/sdk": "^2.1.1",
30
30
  "@coffer-org/server": "^2.3.0",
31
31
  "input": "^1.0.1",