@pipedream/telegram_bot_api 0.4.0 → 0.5.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/actions/create-chat-invite-link/create-chat-invite-link.mjs +1 -1
- package/actions/delete-message/delete-message.mjs +1 -1
- package/actions/download-voice-message/download-voice-message.mjs +73 -0
- package/actions/edit-media-message/edit-media-message.mjs +1 -1
- package/actions/edit-text-message/edit-text-message.mjs +1 -1
- package/actions/export-chat-invite-link/export-chat-invite-link.mjs +1 -1
- package/actions/forward-message/forward-message.mjs +1 -1
- package/actions/get-num-members-in-chat/get-num-members-in-chat.mjs +1 -1
- package/actions/kick-chat-member/kick-chat-member.mjs +1 -1
- package/actions/list-administrators-in-chat/list-administrators-in-chat.mjs +1 -1
- package/actions/list-chats/list-chats.mjs +1 -1
- package/actions/list-commands-options/list-commands-options.mjs +1 -1
- package/actions/list-updates/list-updates.mjs +1 -1
- package/actions/pin-message/pin-message.mjs +1 -1
- package/actions/promote-chat-member/promote-chat-member.mjs +1 -1
- package/actions/restrict-chat-member/restrict-chat-member.mjs +1 -1
- package/actions/send-album/send-album.mjs +1 -1
- package/actions/send-audio-file/send-audio-file.mjs +1 -1
- package/actions/send-document-or-image/send-document-or-image.mjs +1 -1
- package/actions/send-media-by-url-or-id/send-media-by-url-or-id.mjs +1 -1
- package/actions/send-photo/send-photo.mjs +1 -1
- package/actions/send-sticker/send-sticker.mjs +1 -1
- package/actions/send-text-message-or-reply/send-text-message-or-reply.mjs +1 -1
- package/actions/send-video/send-video.mjs +1 -1
- package/actions/send-video-note/send-video-note.mjs +1 -1
- package/actions/send-voice-message/send-voice-message.mjs +1 -1
- package/actions/set-chat-permissions/set-chat-permissions.mjs +1 -1
- package/actions/unpin-message/unpin-message.mjs +1 -1
- package/package.json +1 -1
- package/sources/channel-updates/channel-updates.mjs +1 -1
- package/sources/common/webhooks.mjs +63 -4
- package/sources/message-updates/message-updates.mjs +1 -1
- package/sources/new-bot-command-received/new-bot-command-received.mjs +1 -1
- package/sources/new-updates/new-updates.mjs +1 -1
- package/telegram_bot_api.app.mjs +6 -0
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "telegram_bot_api-create-chat-invite-link",
|
|
5
5
|
name: "Create Chat Invite Link",
|
|
6
6
|
description: "Create an additional invite link for a chat, [See the docs](https://core.telegram.org/bots/api#createchatinvitelink) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "telegram_bot_api-delete-message",
|
|
5
5
|
name: "Delete a Message",
|
|
6
6
|
description: "Deletes a message. [See the docs](https://core.telegram.org/bots/api#deletemessage) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: true,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { axios } from "@pipedream/platform";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
key: "telegram_bot_api-download-voice-message",
|
|
8
|
+
name: "Download Voice Message",
|
|
9
|
+
description: "Downloads a Telegram voice message to the `/tmp` directory using its `file_id`. Use this after receiving a voice message update to persist the audio locally. [See the documentation](https://core.telegram.org/bots/api#getfile)",
|
|
10
|
+
version: "0.0.1",
|
|
11
|
+
annotations: {
|
|
12
|
+
destructiveHint: false,
|
|
13
|
+
openWorldHint: true,
|
|
14
|
+
readOnlyHint: false,
|
|
15
|
+
},
|
|
16
|
+
type: "action",
|
|
17
|
+
props: {
|
|
18
|
+
telegramBotApi,
|
|
19
|
+
syncDir: {
|
|
20
|
+
type: "dir",
|
|
21
|
+
accessMode: "write",
|
|
22
|
+
sync: true,
|
|
23
|
+
},
|
|
24
|
+
fileId: {
|
|
25
|
+
type: "string",
|
|
26
|
+
label: "File ID",
|
|
27
|
+
description: "The `file_id` of the voice message to download. You can get this from a voice message update (e.g., `msg.voice.file_id`).",
|
|
28
|
+
},
|
|
29
|
+
filename: {
|
|
30
|
+
propDefinition: [
|
|
31
|
+
telegramBotApi,
|
|
32
|
+
"filename",
|
|
33
|
+
],
|
|
34
|
+
description: "Optional filename for the downloaded file (without extension). Defaults to the original file name.",
|
|
35
|
+
optional: true,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
async run({ $ }) {
|
|
39
|
+
const file = await this.telegramBotApi.getFile(this.fileId);
|
|
40
|
+
|
|
41
|
+
if (!file.file_path) {
|
|
42
|
+
throw new Error("Telegram did not return a file path. The file may exceed the 20MB download limit.");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const fileLink = await this.telegramBotApi.getFileLink(this.fileId);
|
|
46
|
+
|
|
47
|
+
const ext = path.extname(file.file_path) || ".oga";
|
|
48
|
+
const fileName = this.filename
|
|
49
|
+
? path.extname(this.filename)
|
|
50
|
+
? this.filename
|
|
51
|
+
: `${this.filename}${ext}`
|
|
52
|
+
: path.basename(file.file_path);
|
|
53
|
+
|
|
54
|
+
const tmpPath = path.join(process.env.STASH_DIR || "/tmp", fileName);
|
|
55
|
+
|
|
56
|
+
const response = await axios(this, {
|
|
57
|
+
url: fileLink,
|
|
58
|
+
responseType: "arraybuffer",
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
fs.writeFileSync(tmpPath, Buffer.from(response));
|
|
62
|
+
|
|
63
|
+
$.export("$summary", `Successfully downloaded voice message to "${tmpPath}"`);
|
|
64
|
+
return {
|
|
65
|
+
fileId: file.file_id,
|
|
66
|
+
fileUniqueId: file.file_unique_id,
|
|
67
|
+
fileSize: file.file_size,
|
|
68
|
+
originalPath: file.file_path,
|
|
69
|
+
downloadedPath: tmpPath,
|
|
70
|
+
fileName: fileName,
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
};
|
|
@@ -8,7 +8,7 @@ export default {
|
|
|
8
8
|
key: "telegram_bot_api-edit-media-message",
|
|
9
9
|
name: "Edit a Media Message",
|
|
10
10
|
description: "Edits photo or video messages. [See the docs](https://core.telegram.org/bots/api#editmessagemedia) for more information",
|
|
11
|
-
version: "0.0.
|
|
11
|
+
version: "0.0.8",
|
|
12
12
|
annotations: {
|
|
13
13
|
destructiveHint: true,
|
|
14
14
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "telegram_bot_api-edit-text-message",
|
|
5
5
|
name: "Edit a Text Message",
|
|
6
6
|
description: "Edits text or game messages. [See the docs](https://core.telegram.org/bots/api#editmessagetext) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: true,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "telegram_bot_api-export-chat-invite-link",
|
|
5
5
|
name: "Export Chat Invite Link",
|
|
6
6
|
description: "Generate a new primary invite link for a chat, [See the docs](https://core.telegram.org/bots/api#createchatinvitelink) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "telegram_bot_api-forward-message",
|
|
5
5
|
name: "Forward a Message",
|
|
6
6
|
description: "Forwards messages of any kind. [See the docs](https://core.telegram.org/bots/api#forwardmessage) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "telegram_bot_api-get-num-members-in-chat",
|
|
5
5
|
name: "Get the Number of Members in a Chat",
|
|
6
6
|
description: "Use this module to get the number of members in a chat. [See the docs](https://core.telegram.org/bots/api#getchatmembercount) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "telegram_bot_api-kick-chat-member",
|
|
5
5
|
name: "Kick a Chat Member",
|
|
6
6
|
description: "Use this method to kick a user from a group, a supergroup or channel. [See the docs](https://core.telegram.org/bots/api#banchatmember) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "telegram_bot_api-list-administrators-in-chat",
|
|
5
5
|
name: "List Administrators In Chat",
|
|
6
6
|
description: "Use this module to get a list of administrators in a chat. [See the docs](https://core.telegram.org/bots/api#getchatadministrators) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "telegram_bot_api-list-chats",
|
|
5
5
|
name: "List Chats",
|
|
6
6
|
description: "List available Telegram chats. [See the docs](https://core.telegram.org/bots/api#getupdates) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "telegram_bot_api-list-commands-options",
|
|
5
5
|
name: "List Commands Options",
|
|
6
6
|
description: "Retrieves available options for the Commands field.",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.2",
|
|
8
8
|
type: "action",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "telegram_bot_api-list-updates",
|
|
5
5
|
name: "List Updates",
|
|
6
6
|
description: "Retrieves a list of updates from the Telegram server. [See the docs](https://core.telegram.org/bots/api#getupdates) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "telegram_bot_api-pin-message",
|
|
5
5
|
name: "Pin a Message",
|
|
6
6
|
description: "Pins a message. [See the docs](https://core.telegram.org/bots/api#pinchatmessage) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "telegram_bot_api-promote-chat-member",
|
|
5
5
|
name: "Promote a Chat Member",
|
|
6
6
|
description: "Use this method to promote or demote a user in a supergroup or a channel. [See the docs](https://core.telegram.org/bots/api#promotechatmember) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "telegram_bot_api-restrict-chat-member",
|
|
5
5
|
name: "Restrict a Chat Member",
|
|
6
6
|
description: "Use this method to restrict a user in a supergroup. [See the docs](https://core.telegram.org/bots/api#restrictchatmember) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "telegram_bot_api-send-album",
|
|
6
6
|
name: "Send an Album (Media Group)",
|
|
7
7
|
description: "Sends a group of photos or videos as an album. [See the docs](https://core.telegram.org/bots/api#sendmediagroup) for more information",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.8",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "telegram_bot_api-send-audio-file",
|
|
6
6
|
name: "Send an Audio File",
|
|
7
7
|
description: "Sends an audio file to your Telegram Desktop application. [See the docs](https://core.telegram.org/bots/api#sendaudio) for more information",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.8",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "telegram_bot_api-send-document-or-image",
|
|
6
6
|
name: "Send a Document/Image",
|
|
7
7
|
description: "Sends a document or an image to your Telegram Desktop application. [See the docs](https://core.telegram.org/bots/api#senddocument) for more information",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.8",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "telegram_bot_api-send-media-by-url-or-id",
|
|
6
6
|
name: "Send Media by URL or ID",
|
|
7
7
|
description: "Sends a file (document, photo, video, audio, ...) by HTTP URL or by ID that exists on the Telegram servers. [See the docs](https://core.telegram.org/bots/api#inputmedia) for more information",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.8",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "telegram_bot_api-send-photo",
|
|
6
6
|
name: "Send a Photo",
|
|
7
7
|
description: "Sends a photo to your Telegram Desktop application. [See the docs](https://core.telegram.org/bots/api#sendphoto) for more information",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.8",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "telegram_bot_api-send-sticker",
|
|
5
5
|
name: "Send a Sticker",
|
|
6
6
|
description: "Sends a .webp sticker to you Telegram Desktop application. [See the docs](https://core.telegram.org/bots/api#sendsticker) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "telegram_bot_api-send-text-message-or-reply",
|
|
5
5
|
name: "Send a Text Message or Reply",
|
|
6
6
|
description: "Sends a text message or a reply to your Telegram Desktop application. [See the docs](https://core.telegram.org/bots/api#sendmessage) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "telegram_bot_api-send-video",
|
|
6
6
|
name: "Send a Video",
|
|
7
7
|
description: "Sends a video file to your Telegram Desktop application. [See the docs](https://core.telegram.org/bots/api#sendvideo) for more information",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.8",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "telegram_bot_api-send-video-note",
|
|
6
6
|
name: "Send a Video Note",
|
|
7
7
|
description: "As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages. [See the docs](https://core.telegram.org/bots/api#sendvideonote) for more information",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.8",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "telegram_bot_api-send-voice-message",
|
|
6
6
|
name: "Send a Voice Message",
|
|
7
7
|
description: "Sends a voice message. [See the docs](https://core.telegram.org/bots/api#sendvoice) for more information",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.8",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "telegram_bot_api-set-chat-permissions",
|
|
5
5
|
name: "Set Chat Permissions",
|
|
6
6
|
description: "Set default chat permissions for all members. [See the docs](https://core.telegram.org/bots/api#setchatpermissions) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: true,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "telegram_bot_api-unpin-message",
|
|
5
5
|
name: "Unpin a Message",
|
|
6
6
|
description: "Unpins a message. [See the docs](https://core.telegram.org/bots/api#unpinchatmessage) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
package/package.json
CHANGED
|
@@ -3,6 +3,37 @@ import constants from "./constants.mjs";
|
|
|
3
3
|
import { v4 as uuid } from "uuid";
|
|
4
4
|
import { ConfigurationError } from "@pipedream/platform";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Origin + path of `url`, with any trailing slash removed, or `null` when the
|
|
8
|
+
* value is not a parseable absolute URL. Comparing the parsed form rather than
|
|
9
|
+
* the raw string avoids both false negatives from a trailing slash and
|
|
10
|
+
* substring-based spoofing such as `https://evil.com/?u=<our endpoint>`.
|
|
11
|
+
*/
|
|
12
|
+
function normalizeUrl(url) {
|
|
13
|
+
try {
|
|
14
|
+
const {
|
|
15
|
+
origin, pathname,
|
|
16
|
+
} = new URL(url);
|
|
17
|
+
return `${origin}${pathname.replace(/\/+$/, "")}`;
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Returns true only when the webhook currently registered on the bot is this
|
|
25
|
+
* source's own endpoint. Ownership is decided by exact endpoint identity, so a
|
|
26
|
+
* webhook belonging to an external service — or to a different Pipedream source
|
|
27
|
+
* sharing the same bot token — is never treated as ours and is left untouched.
|
|
28
|
+
*/
|
|
29
|
+
function isOwnWebhook(currentUrl, ownEndpoint) {
|
|
30
|
+
const current = normalizeUrl(currentUrl);
|
|
31
|
+
const own = ownEndpoint
|
|
32
|
+
? normalizeUrl(ownEndpoint)
|
|
33
|
+
: null;
|
|
34
|
+
return !!current && !!own && current === own;
|
|
35
|
+
}
|
|
36
|
+
|
|
6
37
|
export default {
|
|
7
38
|
props: {
|
|
8
39
|
telegramBotApi,
|
|
@@ -16,13 +47,27 @@ export default {
|
|
|
16
47
|
},
|
|
17
48
|
hooks: {
|
|
18
49
|
async deploy() {
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
*
|
|
50
|
+
/**
|
|
51
|
+
* Telegram supports only one webhook per bot. If a stale registration for
|
|
52
|
+
* *this* source survives from a prior deploy (e.g. the source was removed
|
|
53
|
+
* with ignoreHookErrors so deactivate() never ran), clear it before
|
|
54
|
+
* registering again — otherwise activate() stores a fresh secret while
|
|
55
|
+
* Telegram keeps signing with the old one, and run() silently rejects
|
|
56
|
+
* every incoming event.
|
|
57
|
+
*
|
|
58
|
+
* Any webhook that is not this source's own endpoint — external services
|
|
59
|
+
* and other Pipedream sources alike — is left intact, and the original
|
|
60
|
+
* ConfigurationError is thrown so the user is warned before an existing
|
|
61
|
+
* integration is disrupted.
|
|
22
62
|
*/
|
|
23
63
|
const { result } = await this.telegramBotApi.getWebhookInfo();
|
|
24
64
|
if (result.url?.length > 0) {
|
|
25
|
-
|
|
65
|
+
if (isOwnWebhook(result.url, this.http?.endpoint)) {
|
|
66
|
+
console.log(`Removing stale webhook for this source (${result.url}) before deploying...`);
|
|
67
|
+
await this.telegramBotApi.deleteHook();
|
|
68
|
+
} else {
|
|
69
|
+
throw new ConfigurationError("[Telegram only supports](https://core.telegram.org/bots/api#setwebhook) a single webhook at a time, for a given Bot. To get around this, you can reuse an existing Telegram Bot source or disable the active source and try again. [View all your sources here](https://pipedream.com/sources).");
|
|
70
|
+
}
|
|
26
71
|
}
|
|
27
72
|
/**
|
|
28
73
|
* From the docs: https://core.telegram.org/bots/api#getting-updates
|
|
@@ -45,6 +90,20 @@ export default {
|
|
|
45
90
|
async activate() {
|
|
46
91
|
const secret = uuid();
|
|
47
92
|
this.setSecret(secret);
|
|
93
|
+
/**
|
|
94
|
+
* Clear this source's own stale registration before registering again.
|
|
95
|
+
* Anything else is owned by another integration, so throw
|
|
96
|
+
* ConfigurationError before createHook() runs — Telegram's setWebhook
|
|
97
|
+
* would otherwise overwrite it and silently break that integration.
|
|
98
|
+
*/
|
|
99
|
+
const { result } = await this.telegramBotApi.getWebhookInfo();
|
|
100
|
+
if (result.url?.length > 0) {
|
|
101
|
+
if (isOwnWebhook(result.url, this.http?.endpoint)) {
|
|
102
|
+
await this.telegramBotApi.deleteHook();
|
|
103
|
+
} else {
|
|
104
|
+
throw new ConfigurationError("[Telegram only supports](https://core.telegram.org/bots/api#setwebhook) a single webhook at a time, for a given Bot. To get around this, you can reuse an existing Telegram Bot source or disable the active source and try again. [View all your sources here](https://pipedream.com/sources).");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
48
107
|
await this.telegramBotApi.createHook(this.http.endpoint, this.getEventTypes(), secret);
|
|
49
108
|
},
|
|
50
109
|
async deactivate() {
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "telegram_bot_api-message-updates",
|
|
7
7
|
name: "New Message Updates (Instant)",
|
|
8
8
|
description: "Emit new event each time a Telegram message is created or updated.",
|
|
9
|
-
version: "0.1.
|
|
9
|
+
version: "0.1.8",
|
|
10
10
|
type: "source",
|
|
11
11
|
dedupe: "unique",
|
|
12
12
|
props: {
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "telegram_bot_api-new-bot-command-received",
|
|
7
7
|
name: "New Bot Command Received (Instant)",
|
|
8
8
|
description: "Emit new event each time a Telegram Bot command is received.",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.7",
|
|
10
10
|
type: "source",
|
|
11
11
|
dedupe: "unique",
|
|
12
12
|
props: {
|
package/telegram_bot_api.app.mjs
CHANGED
|
@@ -724,5 +724,11 @@ export default {
|
|
|
724
724
|
async getMyCommands() {
|
|
725
725
|
return this.sdk().getMyCommands();
|
|
726
726
|
},
|
|
727
|
+
async getFile(fileId) {
|
|
728
|
+
return this.sdk().getFile(fileId);
|
|
729
|
+
},
|
|
730
|
+
async getFileLink(fileId) {
|
|
731
|
+
return this.sdk().getFileLink(fileId);
|
|
732
|
+
},
|
|
727
733
|
},
|
|
728
734
|
};
|