@minhvuong/pirate-storage-telegram-worker
v0.1.0
Published
Cloudflare Worker adapter using mtcute over Telegram's WebSocket transport. Run it inside one Durable Object per Telegram connection; do not create an unrelated client in every Worker isolate.
Readme
@minhvuong/pirate-storage-telegram-worker
Cloudflare Worker adapter using mtcute over Telegram's WebSocket transport. Run it inside one Durable Object per Telegram connection; do not create an unrelated client in every Worker isolate.
const sessionStore = new DurableObjectTelegramSessionStore(ctx.storage);
const journal = new DurableObjectUploadJournal(ctx.storage);
const channel = createTelegramInputChannel({
channelId: env.TELEGRAM_CHANNEL_ID,
accessHash: env.TELEGRAM_CHANNEL_ACCESS_HASH,
});
const telegram = createTelegramWorkerProvider({
apiId: env.TELEGRAM_API_ID,
apiHash: env.TELEGRAM_API_HASH,
botToken: env.TELEGRAM_BOT_TOKEN,
sessionStore,
channel,
channelId: env.TELEGRAM_CHANNEL_ID,
manifestSecret: env.STORAGE_MANIFEST_SECRET,
});The Durable Object storage keeps both the exported Telegram auth session and browser multipart journal across isolate reloads. The media bytes remain temporary Telegram upload parts until the final sendMedia, which creates one message.
This adapter is intentionally self-hosted and does not provide a client-visible upload URL: API credentials, auth keys, and bot/user sessions must remain server-side.
