@mastra/telegram 0.2.1-alpha.0 → 0.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.
- package/dist/index.cjs +5 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -24648,16 +24648,12 @@ var TelegramProvider = class {
|
|
|
24648
24648
|
const baseUrl = this.#getBaseUrl();
|
|
24649
24649
|
const mode = this.#resolveMode(baseUrl);
|
|
24650
24650
|
if (mode === "webhook" && !baseUrl) throw new Error("TelegramProvider needs a baseUrl to register a webhook. Set `baseUrl`, configure the Mastra server, or use `mode: \"polling\"`.");
|
|
24651
|
-
if (
|
|
24652
|
-
|
|
24653
|
-
this.#connectingBotTokens.add(botToken);
|
|
24654
|
-
}
|
|
24651
|
+
if (this.#connectingBotTokens.has(botToken)) throw new Error("This Telegram bot is already being connected. Wait for that connection to finish.");
|
|
24652
|
+
this.#connectingBotTokens.add(botToken);
|
|
24655
24653
|
try {
|
|
24656
24654
|
const me = await getMe(botToken, this.#apiBaseUrl());
|
|
24657
|
-
|
|
24658
|
-
|
|
24659
|
-
if (duplicate) throw new Error(`This Telegram bot is already connected to agent "${duplicate.agentId}". Disconnect it before connecting another agent.`);
|
|
24660
|
-
}
|
|
24655
|
+
const duplicate = (await store.list()).find((i) => i.status === "active" && i.agentId !== agentId && (i.botUserId !== void 0 ? i.botUserId === me.id : i.botToken === botToken));
|
|
24656
|
+
if (duplicate) throw new Error(`This Telegram bot is already connected to agent "${duplicate.agentId}". Disconnect it before connecting another agent.`);
|
|
24661
24657
|
const installationId = existing?.id ?? globalThis.crypto.randomUUID();
|
|
24662
24658
|
const webhookId = existing?.webhookId ?? globalThis.crypto.randomUUID();
|
|
24663
24659
|
const webhookUrl = mode === "webhook" ? `${baseUrl}/${PLATFORM}/events/${webhookId}` : void 0;
|
|
@@ -24686,7 +24682,7 @@ var TelegramProvider = class {
|
|
|
24686
24682
|
installationId
|
|
24687
24683
|
};
|
|
24688
24684
|
} finally {
|
|
24689
|
-
|
|
24685
|
+
this.#connectingBotTokens.delete(botToken);
|
|
24690
24686
|
}
|
|
24691
24687
|
}
|
|
24692
24688
|
/** Disconnect an agent from Telegram, removing its webhook and installation. */
|