@pipedream/telegram_bot_api 0.3.3 → 0.3.5
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/README.md +12 -0
- package/actions/create-chat-invite-link/create-chat-invite-link.mjs +1 -1
- package/actions/delete-message/delete-message.mjs +1 -1
- package/actions/edit-media-message/edit-media-message.mjs +2 -2
- 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-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 +2 -2
- package/actions/send-audio-file/send-audio-file.mjs +2 -2
- package/actions/send-document-or-image/send-document-or-image.mjs +2 -2
- package/actions/send-media-by-url-or-id/send-media-by-url-or-id.mjs +2 -2
- package/actions/send-photo/send-photo.mjs +2 -2
- 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 +2 -2
- package/actions/send-video-note/send-video-note.mjs +2 -2
- package/actions/send-voice-message/send-voice-message.mjs +2 -2
- package/actions/set-chat-permissions/set-chat-permissions.mjs +88 -0
- package/actions/unpin-message/unpin-message.mjs +1 -1
- package/{constants.mjs → common/constants.mjs} +0 -0
- package/{content-types.mjs → common/content-types.mjs} +0 -0
- package/{env.mjs → common/env.mjs} +0 -0
- package/{update-types.mjs → common/update-types.mjs} +12 -0
- package/{utils.mjs → common/utils.mjs} +0 -0
- package/package.json +3 -2
- package/sources/channel-updates/channel-updates.mjs +26 -40
- package/sources/common/constants.mjs +3 -0
- package/sources/common/webhooks.mjs +88 -0
- package/sources/message-updates/message-updates.mjs +19 -38
- package/sources/new-updates/new-updates.mjs +23 -42
- package/telegram_bot_api.app.mjs +31 -6
package/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Overview
|
|
2
|
+
|
|
3
|
+
With the Telegram Bot API, you can build bots that perform a variety of tasks,
|
|
4
|
+
including:
|
|
5
|
+
|
|
6
|
+
- Sending and receiving messages
|
|
7
|
+
- Social networking
|
|
8
|
+
- Content management
|
|
9
|
+
- File sharing
|
|
10
|
+
- Location sharing
|
|
11
|
+
- Bot administration
|
|
12
|
+
- And more!
|
|
@@ -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.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
telegramBotApi,
|
|
@@ -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.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
telegramBotApi,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TELEGRAM_BOT_API_MEDIA_PHOTO,
|
|
3
3
|
TELEGRAM_BOT_API_MEDIA_VIDEO,
|
|
4
|
-
} from "../../constants.mjs";
|
|
4
|
+
} from "../../common/constants.mjs";
|
|
5
5
|
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
6
6
|
|
|
7
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.4",
|
|
12
12
|
type: "action",
|
|
13
13
|
props: {
|
|
14
14
|
telegramBotApi,
|
|
@@ -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.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
telegramBotApi,
|
|
@@ -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.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
telegramBotApi,
|
|
@@ -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.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
telegramBotApi,
|
|
@@ -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.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
telegramBotApi,
|
|
@@ -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.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
telegramBotApi,
|
|
@@ -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.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
telegramBotApi,
|
|
@@ -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.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
telegramBotApi,
|
|
@@ -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.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
telegramBotApi,
|
|
@@ -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.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
telegramBotApi,
|
|
@@ -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.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
telegramBotApi,
|
|
@@ -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.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
telegramBotApi,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
-
import { toSingleLineString } from "../../utils.mjs";
|
|
2
|
+
import { toSingleLineString } from "../../common/utils.mjs";
|
|
3
3
|
|
|
4
4
|
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.4",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
telegramBotApi,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
-
import contentTypes from "../../content-types.mjs";
|
|
2
|
+
import contentTypes from "../../common/content-types.mjs";
|
|
3
3
|
|
|
4
4
|
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.4",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
telegramBotApi,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
-
import contentTypes from "../../content-types.mjs";
|
|
2
|
+
import contentTypes from "../../common/content-types.mjs";
|
|
3
3
|
|
|
4
4
|
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.4",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
telegramBotApi,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
-
import { TELEGRAM_BOT_API_UI_MEDIA_TYPES } from "../../constants.mjs";
|
|
2
|
+
import { TELEGRAM_BOT_API_UI_MEDIA_TYPES } from "../../common/constants.mjs";
|
|
3
3
|
|
|
4
4
|
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.4",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
telegramBotApi,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
-
import contentTypes from "../../content-types.mjs";
|
|
2
|
+
import contentTypes from "../../common/content-types.mjs";
|
|
3
3
|
|
|
4
4
|
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.4",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
telegramBotApi,
|
|
@@ -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.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
telegramBotApi,
|
|
@@ -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.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
telegramBotApi,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
-
import contentTypes from "../../content-types.mjs";
|
|
2
|
+
import contentTypes from "../../common/content-types.mjs";
|
|
3
3
|
|
|
4
4
|
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.4",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
telegramBotApi,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
-
import contentTypes from "../../content-types.mjs";
|
|
2
|
+
import contentTypes from "../../common/content-types.mjs";
|
|
3
3
|
|
|
4
4
|
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.4",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
telegramBotApi,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
-
import contentTypes from "../../content-types.mjs";
|
|
2
|
+
import contentTypes from "../../common/content-types.mjs";
|
|
3
3
|
|
|
4
4
|
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.4",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
telegramBotApi,
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "telegram_bot_api-set-chat-permissions",
|
|
5
|
+
name: "Set Chat Permissions",
|
|
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.3",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
telegramBotApi,
|
|
11
|
+
chatId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
telegramBotApi,
|
|
14
|
+
"chatId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
canSendMessages: {
|
|
18
|
+
type: "boolean",
|
|
19
|
+
label: "Send text messages",
|
|
20
|
+
description: "If the user is allowed to send text messages, contacts, locations and venues",
|
|
21
|
+
optional: true,
|
|
22
|
+
},
|
|
23
|
+
canSendMediaMessages: {
|
|
24
|
+
type: "boolean",
|
|
25
|
+
label: "Send media messages",
|
|
26
|
+
description: "If the user is allowed to send audios, documents, photos, videos, video notes and voice notes",
|
|
27
|
+
optional: true,
|
|
28
|
+
},
|
|
29
|
+
canSendPolls: {
|
|
30
|
+
type: "boolean",
|
|
31
|
+
label: "Send polls",
|
|
32
|
+
description: "If the user is allowed to send polls",
|
|
33
|
+
optional: true,
|
|
34
|
+
},
|
|
35
|
+
canSendOtherMessages: {
|
|
36
|
+
type: "boolean",
|
|
37
|
+
label: "Send other messages",
|
|
38
|
+
description: "If the user is allowed to send animations, games, stickers and use inline bots",
|
|
39
|
+
optional: true,
|
|
40
|
+
},
|
|
41
|
+
canAddWebPagePreviews: {
|
|
42
|
+
type: "boolean",
|
|
43
|
+
label: "Add web page previews",
|
|
44
|
+
description: "If the user is allowed to add web page previews to their messages",
|
|
45
|
+
optional: true,
|
|
46
|
+
},
|
|
47
|
+
canChangeInfo: {
|
|
48
|
+
type: "boolean",
|
|
49
|
+
label: "Change info",
|
|
50
|
+
description: "If the user is allowed to change the chat title, photo and other settings. Ignored in public SuperGroups",
|
|
51
|
+
optional: true,
|
|
52
|
+
},
|
|
53
|
+
canInviteUsers: {
|
|
54
|
+
type: "boolean",
|
|
55
|
+
label: "Send invite users",
|
|
56
|
+
description: "If the user is allowed to invite new users to the chat",
|
|
57
|
+
optional: true,
|
|
58
|
+
},
|
|
59
|
+
canPinMessages: {
|
|
60
|
+
type: "boolean",
|
|
61
|
+
label: "Pin messages",
|
|
62
|
+
description: "If the user is allowed to pin messages. Ignored in public SuperGroups",
|
|
63
|
+
optional: true,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
methods: {
|
|
67
|
+
setPermission(chatPermissions, prop, value) {
|
|
68
|
+
if (value !== null && value !== undefined) {
|
|
69
|
+
chatPermissions[prop] = value;
|
|
70
|
+
}
|
|
71
|
+
return chatPermissions;
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
async run({ $ }) {
|
|
75
|
+
let chatPermissions = {};
|
|
76
|
+
chatPermissions = this.setPermission(chatPermissions, "can_send_messages", this.canSendMessages);
|
|
77
|
+
chatPermissions = this.setPermission(chatPermissions, "can_send_media_messages", this.canSendMediaMessages);
|
|
78
|
+
chatPermissions = this.setPermission(chatPermissions, "can_send_polls", this.canSendPolls);
|
|
79
|
+
chatPermissions = this.setPermission(chatPermissions, "can_send_other_messages", this.canSendOtherMessages);
|
|
80
|
+
chatPermissions = this.setPermission(chatPermissions, "can_add_web_page_previews", this.canAddWebPagePreviews);
|
|
81
|
+
chatPermissions = this.setPermission(chatPermissions, "can_change_info", this.canChangeInfo);
|
|
82
|
+
chatPermissions = this.setPermission(chatPermissions, "can_invite_users", this.canInviteUsers);
|
|
83
|
+
chatPermissions = this.setPermission(chatPermissions, "can_pin_messages", this.canPinMessages);
|
|
84
|
+
const resp = await this.telegramBotApi.setChatPermissions(this.chatId, chatPermissions);
|
|
85
|
+
$.export("$summary", `Successfully set chat permissions, "${this.chatId}"`);
|
|
86
|
+
return resp;
|
|
87
|
+
},
|
|
88
|
+
};
|
|
@@ -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.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
telegramBotApi,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -47,4 +47,16 @@ export default [
|
|
|
47
47
|
label: "Poll Answer",
|
|
48
48
|
value: "poll_answer",
|
|
49
49
|
},
|
|
50
|
+
{
|
|
51
|
+
label: "My Chat Member",
|
|
52
|
+
value: "my_chat_member",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: "Chat Member",
|
|
56
|
+
value: "chat_member",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
label: "Chat Join Request",
|
|
60
|
+
value: "chat_join_request",
|
|
61
|
+
},
|
|
50
62
|
];
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/telegram_bot_api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Pipedream Telegram_bot_api Components",
|
|
5
5
|
"main": "telegram_bot_api.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@pipedream/platform": "^0.9.0",
|
|
15
|
-
"node-telegram-bot-api": "^0.54.0"
|
|
15
|
+
"node-telegram-bot-api": "^0.54.0",
|
|
16
|
+
"uuid": "^8.3.2"
|
|
16
17
|
},
|
|
17
18
|
"gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535",
|
|
18
19
|
"publishConfig": {
|
|
@@ -1,50 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
1
|
+
import base from "../common/webhooks.mjs";
|
|
3
2
|
|
|
4
3
|
export default {
|
|
5
|
-
|
|
4
|
+
...base,
|
|
6
5
|
key: "telegram_bot_api-channel-updates",
|
|
7
|
-
name: "Channel Updates (Instant)",
|
|
8
|
-
description: "Emit new event each time a channel
|
|
9
|
-
version: "0.
|
|
6
|
+
name: "New Channel Updates (Instant)",
|
|
7
|
+
description: "Emit new event each time a channel post is created or updated.",
|
|
8
|
+
version: "0.1.2",
|
|
9
|
+
type: "source",
|
|
10
10
|
dedupe: "unique",
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
type: "$.interface.http",
|
|
16
|
-
customResponse: true,
|
|
17
|
-
},
|
|
18
|
-
telegramBotApi,
|
|
19
|
-
},
|
|
20
|
-
hooks: {
|
|
21
|
-
async activate() {
|
|
22
|
-
await this.telegramBotApi.createHook(this.http.endpoint, [
|
|
11
|
+
methods: {
|
|
12
|
+
...base.methods,
|
|
13
|
+
getEventTypes() {
|
|
14
|
+
return [
|
|
23
15
|
"channel_post",
|
|
24
16
|
"edited_channel_post",
|
|
25
|
-
]
|
|
26
|
-
},
|
|
27
|
-
async deactivate() {
|
|
28
|
-
await this.telegramBotApi.deleteHook();
|
|
17
|
+
];
|
|
29
18
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
this.http.respond({
|
|
36
|
-
status: 200,
|
|
37
|
-
});
|
|
38
|
-
const { body } = event;
|
|
39
|
-
if (!body) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const channelPost = body.edited_channel_post ?? body.channel_post;
|
|
43
|
-
this.$emit(body,
|
|
44
|
-
{
|
|
45
|
-
id: body.update_id,
|
|
19
|
+
getMeta(event, channelPost) {
|
|
20
|
+
return {
|
|
21
|
+
id: event.update_id,
|
|
46
22
|
summary: `${channelPost.chat.title} - ${channelPost.text}`,
|
|
47
|
-
ts: Date.
|
|
48
|
-
}
|
|
23
|
+
ts: new Date(channelPost.edit_date ?? channelPost.date),
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
processEvent(event) {
|
|
27
|
+
const channelPost = event.edited_channel_post ?? event.channel_post;
|
|
28
|
+
|
|
29
|
+
if (!channelPost?.chat) {
|
|
30
|
+
throw new Error(`Expected event to contain a chat, but received: ${JSON.stringify(event)}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
this.$emit(event, this.getMeta(event, channelPost));
|
|
34
|
+
},
|
|
49
35
|
},
|
|
50
36
|
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
+
import constants from "./constants.mjs";
|
|
3
|
+
import { v4 as uuid } from "uuid";
|
|
4
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
props: {
|
|
8
|
+
telegramBotApi,
|
|
9
|
+
db: "$.service.db",
|
|
10
|
+
http: {
|
|
11
|
+
label: "HTTP Responder",
|
|
12
|
+
description: "Exposes a `respond()` method that lets the source issue HTTP responses",
|
|
13
|
+
type: "$.interface.http",
|
|
14
|
+
customResponse: true,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
hooks: {
|
|
18
|
+
async deploy() {
|
|
19
|
+
/*
|
|
20
|
+
* Telegram only supports a single webhook at a time for a given Bot. If a webhook
|
|
21
|
+
* for this Bot already exists, display configuration error.
|
|
22
|
+
*/
|
|
23
|
+
const { result } = await this.telegramBotApi.getWebhookInfo();
|
|
24
|
+
if (result.url?.length > 0) {
|
|
25
|
+
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).");
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* From the docs: https://core.telegram.org/bots/api#getting-updates
|
|
29
|
+
*
|
|
30
|
+
* Incoming updates are stored on the server until the bot receives them either way,
|
|
31
|
+
* but they will not be kept longer than 24 hours.
|
|
32
|
+
*
|
|
33
|
+
* So there's a big chance that no historical event is emitted.
|
|
34
|
+
*/
|
|
35
|
+
console.log("Fetching most recent events...");
|
|
36
|
+
const events = await this.telegramBotApi.getUpdates({
|
|
37
|
+
offset: constants.DEPLOY_OFFSET,
|
|
38
|
+
allowed_updates: this.getEventTypes(),
|
|
39
|
+
});
|
|
40
|
+
console.log(`Received ${events.length} event(s)`);
|
|
41
|
+
for (const event of events) {
|
|
42
|
+
this.processEvent(event);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
async activate() {
|
|
46
|
+
const secret = uuid();
|
|
47
|
+
this.setSecret(secret);
|
|
48
|
+
await this.telegramBotApi.createHook(this.http.endpoint, this.getEventTypes(), secret);
|
|
49
|
+
},
|
|
50
|
+
async deactivate() {
|
|
51
|
+
await this.telegramBotApi.deleteHook();
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
methods: {
|
|
55
|
+
getSecret() {
|
|
56
|
+
return this.db.get("secret");
|
|
57
|
+
},
|
|
58
|
+
setSecret(secret) {
|
|
59
|
+
this.db.set("secret", secret);
|
|
60
|
+
},
|
|
61
|
+
getEventTypes() {
|
|
62
|
+
throw new Error("getEventTypes is not implemented");
|
|
63
|
+
},
|
|
64
|
+
processEvent() {
|
|
65
|
+
throw new Error("processEvent is not implemented");
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
async run(event) {
|
|
69
|
+
// check if event has the same secret
|
|
70
|
+
if (event.headers["x-telegram-bot-api-secret-token"] !== this.getSecret()) {
|
|
71
|
+
console.log("Could not identify sender identity, exiting...");
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
this.http.respond({
|
|
76
|
+
status: 200,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const { body } = event;
|
|
80
|
+
|
|
81
|
+
if (!body) {
|
|
82
|
+
console.log("No body received, exiting...");
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this.processEvent(body);
|
|
87
|
+
},
|
|
88
|
+
};
|
|
@@ -1,50 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
1
|
+
import base from "../common/webhooks.mjs";
|
|
3
2
|
|
|
4
3
|
export default {
|
|
5
|
-
|
|
4
|
+
...base,
|
|
6
5
|
key: "telegram_bot_api-message-updates",
|
|
7
|
-
name: "Message Updates (Instant)",
|
|
6
|
+
name: "New Message Updates (Instant)",
|
|
8
7
|
description: "Emit new event each time a Telegram message is created or updated.",
|
|
9
|
-
version: "0.
|
|
8
|
+
version: "0.1.2",
|
|
9
|
+
type: "source",
|
|
10
10
|
dedupe: "unique",
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
methods: {
|
|
12
|
+
...base.methods,
|
|
13
|
+
getMeta(event, message) {
|
|
14
|
+
return {
|
|
15
|
+
id: event.update_id,
|
|
16
|
+
summary: message.text,
|
|
17
|
+
ts: new Date(message.edit_date ?? message.date),
|
|
18
|
+
};
|
|
17
19
|
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
hooks: {
|
|
21
|
-
async activate() {
|
|
22
|
-
await this.telegramBotApi.createHook(this.http.endpoint, [
|
|
20
|
+
getEventTypes() {
|
|
21
|
+
return [
|
|
23
22
|
"message",
|
|
24
23
|
"edited_message",
|
|
25
|
-
]
|
|
24
|
+
];
|
|
26
25
|
},
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
processEvent(event) {
|
|
27
|
+
const message = event.edited_message ?? event.message;
|
|
28
|
+
this.$emit(event, this.getMeta(event, message));
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
|
-
async run(event) {
|
|
32
|
-
if ((event.path).substring(1) !== this.telegramBotApi.$auth.token) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
this.http.respond({
|
|
36
|
-
status: 200,
|
|
37
|
-
});
|
|
38
|
-
const { body } = event;
|
|
39
|
-
if (!body) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const message = body.edited_message ?? body.message;
|
|
43
|
-
this.$emit(body,
|
|
44
|
-
{
|
|
45
|
-
id: body.update_id,
|
|
46
|
-
summary: message.text,
|
|
47
|
-
ts: Date.now(),
|
|
48
|
-
});
|
|
49
|
-
},
|
|
50
31
|
};
|
|
@@ -1,63 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
1
|
+
import base from "../common/webhooks.mjs";
|
|
3
2
|
|
|
4
3
|
export default {
|
|
4
|
+
...base,
|
|
5
5
|
key: "telegram_bot_api-new-updates",
|
|
6
6
|
name: "New Updates (Instant)",
|
|
7
7
|
description: "Emit new event for each new Telegram event.",
|
|
8
|
-
version: "0.
|
|
8
|
+
version: "0.1.2",
|
|
9
9
|
type: "source",
|
|
10
10
|
dedupe: "unique",
|
|
11
11
|
props: {
|
|
12
|
-
|
|
13
|
-
// eslint-disable-next-line pipedream/props-label,pipedream/props-description
|
|
14
|
-
http: {
|
|
15
|
-
label: "HTTP Responder",
|
|
16
|
-
description: "Exposes a `respond()` method that lets the source issue HTTP responses",
|
|
17
|
-
type: "$.interface.http",
|
|
18
|
-
customResponse: true,
|
|
19
|
-
},
|
|
20
|
-
telegramBotApi,
|
|
12
|
+
...base.props,
|
|
21
13
|
updateTypes: {
|
|
22
14
|
propDefinition: [
|
|
23
|
-
telegramBotApi,
|
|
15
|
+
base.props.telegramBotApi,
|
|
24
16
|
"updateTypes",
|
|
25
17
|
],
|
|
26
18
|
},
|
|
27
19
|
},
|
|
28
|
-
hooks: {
|
|
29
|
-
async activate() {
|
|
30
|
-
await this.telegramBotApi.createHook(this.http.endpoint, this.updateTypes);
|
|
31
|
-
},
|
|
32
|
-
async deactivate() {
|
|
33
|
-
await this.telegramBotApi.deleteHook();
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
20
|
methods: {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
21
|
+
...base.methods,
|
|
22
|
+
getMeta(event) {
|
|
23
|
+
const {
|
|
24
|
+
update_id: id,
|
|
25
|
+
...eventDetails
|
|
26
|
+
} = event;
|
|
27
|
+
const eventType = Object.keys(eventDetails).pop();
|
|
28
|
+
const summary = `New ${eventType} update: ${id}`;
|
|
29
|
+
const ts = eventDetails[eventType].edit_date ?? eventDetails[eventType].date;
|
|
30
|
+
|
|
43
31
|
return {
|
|
44
|
-
id
|
|
32
|
+
id,
|
|
45
33
|
summary,
|
|
46
|
-
ts
|
|
34
|
+
ts,
|
|
47
35
|
};
|
|
48
36
|
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
status: 200,
|
|
56
|
-
});
|
|
57
|
-
const { body } = event;
|
|
58
|
-
if (!body) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
this.$emit(body, this.getMeta(body));
|
|
37
|
+
getEventTypes() {
|
|
38
|
+
return this.updateTypes;
|
|
39
|
+
},
|
|
40
|
+
processEvent(event) {
|
|
41
|
+
this.$emit(event, this.getMeta(event));
|
|
42
|
+
},
|
|
62
43
|
},
|
|
63
44
|
};
|
package/telegram_bot_api.app.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./env.mjs";
|
|
1
|
+
import "./common/env.mjs";
|
|
2
2
|
import TelegramBot from "node-telegram-bot-api";
|
|
3
3
|
import { axios } from "@pipedream/platform";
|
|
4
4
|
import {
|
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
TELEGRAM_BOT_API_UI_MEDIA_STICKER,
|
|
11
11
|
TELEGRAM_BOT_API_UI_MEDIA_VOICE,
|
|
12
12
|
TELEGRAM_BOT_API_FORMATTING_MODES,
|
|
13
|
-
} from "./constants.mjs";
|
|
14
|
-
import updateTypes from "./update-types.mjs";
|
|
15
|
-
import { toSingleLineString } from "./utils.mjs";
|
|
13
|
+
} from "./common/constants.mjs";
|
|
14
|
+
import updateTypes from "./common/update-types.mjs";
|
|
15
|
+
import { toSingleLineString } from "./common/utils.mjs";
|
|
16
16
|
|
|
17
17
|
export default {
|
|
18
18
|
type: "app",
|
|
@@ -273,14 +273,15 @@ export default {
|
|
|
273
273
|
polling: false,
|
|
274
274
|
});
|
|
275
275
|
},
|
|
276
|
-
async createHook(url, allowedUpdates) {
|
|
276
|
+
async createHook(url, allowedUpdates, secret) {
|
|
277
277
|
const config = {
|
|
278
278
|
method: "POST",
|
|
279
279
|
url: `${this._getBaseUrl()}/setWebhook`,
|
|
280
280
|
headers: this._getHeaders(),
|
|
281
281
|
data: {
|
|
282
|
-
url
|
|
282
|
+
url,
|
|
283
283
|
allowed_updates: allowedUpdates,
|
|
284
|
+
secret_token: secret,
|
|
284
285
|
},
|
|
285
286
|
};
|
|
286
287
|
return axios(this, config);
|
|
@@ -293,6 +294,14 @@ export default {
|
|
|
293
294
|
};
|
|
294
295
|
return axios(this, config);
|
|
295
296
|
},
|
|
297
|
+
async getWebhookInfo() {
|
|
298
|
+
const config = {
|
|
299
|
+
method: "GET",
|
|
300
|
+
url: `${await this._getBaseUrl()}/getWebhookInfo`,
|
|
301
|
+
headers: await this._getHeaders(),
|
|
302
|
+
};
|
|
303
|
+
return axios(this, config);
|
|
304
|
+
},
|
|
296
305
|
/**
|
|
297
306
|
* Send a text message
|
|
298
307
|
*
|
|
@@ -408,6 +417,22 @@ export default {
|
|
|
408
417
|
message_id: messageId,
|
|
409
418
|
});
|
|
410
419
|
},
|
|
420
|
+
/**
|
|
421
|
+
* Use this method to set default chat permissions for all members.
|
|
422
|
+
* The bot must be an administrator in the group or a supergroup for this
|
|
423
|
+
* to work and must have the can_restrict_members administrator rights.
|
|
424
|
+
* Returns True on success.
|
|
425
|
+
*
|
|
426
|
+
* @param {Number|String} chatId - Unique identifier for the message
|
|
427
|
+
* recipient
|
|
428
|
+
* @param {TelegramBot.ChatPermissions} [chatPermissions] -
|
|
429
|
+
* A JSON-serialized object for new default chat permissions
|
|
430
|
+
* [the API docs](https://core.telegram.org/bots/api#setchatpermissions)
|
|
431
|
+
* @return `True` on success
|
|
432
|
+
*/
|
|
433
|
+
async setChatPermissions(chatId, chatPermissions) {
|
|
434
|
+
return this.sdk().setChatPermissions(chatId, chatPermissions);
|
|
435
|
+
},
|
|
411
436
|
/**
|
|
412
437
|
* Send a file (Document/Image, Photo, Audio, Video, Video Note, Voice,
|
|
413
438
|
* Sticker)
|