@pipedream/telegram_bot_api 0.3.3
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/LICENSE +7 -0
- package/actions/create-chat-invite-link/create-chat-invite-link.mjs +52 -0
- package/actions/delete-message/delete-message.mjs +29 -0
- package/actions/edit-media-message/edit-media-message.mjs +89 -0
- package/actions/edit-text-message/edit-text-message.mjs +45 -0
- package/actions/export-chat-invite-link/export-chat-invite-link.mjs +23 -0
- package/actions/forward-message/forward-message.mjs +48 -0
- package/actions/get-num-members-in-chat/get-num-members-in-chat.mjs +23 -0
- package/actions/kick-chat-member/kick-chat-member.mjs +38 -0
- package/actions/list-administrators-in-chat/list-administrators-in-chat.mjs +25 -0
- package/actions/list-chats/list-chats.mjs +73 -0
- package/actions/list-updates/list-updates.mjs +49 -0
- package/actions/pin-message/pin-message.mjs +37 -0
- package/actions/promote-chat-member/promote-chat-member.mjs +86 -0
- package/actions/restrict-chat-member/restrict-chat-member.mjs +66 -0
- package/actions/send-album/send-album.mjs +53 -0
- package/actions/send-audio-file/send-audio-file.mjs +98 -0
- package/actions/send-document-or-image/send-document-or-image.mjs +83 -0
- package/actions/send-media-by-url-or-id/send-media-by-url-or-id.mjs +73 -0
- package/actions/send-photo/send-photo.mjs +84 -0
- package/actions/send-sticker/send-sticker.mjs +53 -0
- package/actions/send-text-message-or-reply/send-text-message-or-reply.mjs +66 -0
- package/actions/send-video/send-video.mjs +86 -0
- package/actions/send-video-note/send-video-note.mjs +76 -0
- package/actions/send-voice-message/send-voice-message.mjs +85 -0
- package/actions/unpin-message/unpin-message.mjs +29 -0
- package/constants.mjs +198 -0
- package/content-types.mjs +115 -0
- package/env.mjs +14 -0
- package/package.json +21 -0
- package/sources/channel-updates/channel-updates.mjs +50 -0
- package/sources/message-updates/message-updates.mjs +50 -0
- package/sources/new-updates/new-updates.mjs +63 -0
- package/telegram_bot_api.app.mjs +682 -0
- package/update-types.mjs +50 -0
- package/utils.mjs +27 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2020 Pipedream, Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "telegram_bot_api-create-chat-invite-link",
|
|
5
|
+
name: "Create Chat Invite Link",
|
|
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.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
telegramBotApi,
|
|
11
|
+
chatId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
telegramBotApi,
|
|
14
|
+
"chatId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
name: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
telegramBotApi,
|
|
20
|
+
"link_name",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
expire_date: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
telegramBotApi,
|
|
26
|
+
"expire_date",
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
member_limit: {
|
|
30
|
+
propDefinition: [
|
|
31
|
+
telegramBotApi,
|
|
32
|
+
"member_limit",
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
creates_join_request: {
|
|
36
|
+
propDefinition: [
|
|
37
|
+
telegramBotApi,
|
|
38
|
+
"creates_join_request",
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
async run({ $ }) {
|
|
43
|
+
const resp = await this.telegramBotApi.createChatInviteLink(this.chatId, {
|
|
44
|
+
name: this.name,
|
|
45
|
+
expire_date: this.expire_date,
|
|
46
|
+
member_limit: this.member_limit,
|
|
47
|
+
creates_join_request: this.creates_join_request,
|
|
48
|
+
});
|
|
49
|
+
$.export("$summary", `Successfully created chat invite link, "${this.chatId}"`);
|
|
50
|
+
return resp;
|
|
51
|
+
},
|
|
52
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "telegram_bot_api-delete-message",
|
|
5
|
+
name: "Delete a Message",
|
|
6
|
+
description: "Deletes a message. [See the docs](https://core.telegram.org/bots/api#deletemessage) for more information",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
telegramBotApi,
|
|
11
|
+
chatId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
telegramBotApi,
|
|
14
|
+
"chatId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
messageId: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
telegramBotApi,
|
|
20
|
+
"messageId",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
async run({ $ }) {
|
|
25
|
+
const resp = await this.telegramBotApi.deleteMessage(this.chatId, this.messageId);
|
|
26
|
+
$.export("$summary", `Successfully deleted the message from chat, "${this.chatId}"`);
|
|
27
|
+
return resp;
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TELEGRAM_BOT_API_MEDIA_PHOTO,
|
|
3
|
+
TELEGRAM_BOT_API_MEDIA_VIDEO,
|
|
4
|
+
} from "../../constants.mjs";
|
|
5
|
+
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
key: "telegram_bot_api-edit-media-message",
|
|
9
|
+
name: "Edit a Media Message",
|
|
10
|
+
description: "Edits photo or video messages. [See the docs](https://core.telegram.org/bots/api#editmessagemedia) for more information",
|
|
11
|
+
version: "0.0.1",
|
|
12
|
+
type: "action",
|
|
13
|
+
props: {
|
|
14
|
+
telegramBotApi,
|
|
15
|
+
chatId: {
|
|
16
|
+
propDefinition: [
|
|
17
|
+
telegramBotApi,
|
|
18
|
+
"chatId",
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
messageId: {
|
|
22
|
+
propDefinition: [
|
|
23
|
+
telegramBotApi,
|
|
24
|
+
"messageId",
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
type: {
|
|
28
|
+
propDefinition: [
|
|
29
|
+
telegramBotApi,
|
|
30
|
+
"type",
|
|
31
|
+
],
|
|
32
|
+
options: [
|
|
33
|
+
{
|
|
34
|
+
label: "Photo",
|
|
35
|
+
value: TELEGRAM_BOT_API_MEDIA_PHOTO,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: "Video",
|
|
39
|
+
value: TELEGRAM_BOT_API_MEDIA_VIDEO,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
caption: {
|
|
44
|
+
propDefinition: [
|
|
45
|
+
telegramBotApi,
|
|
46
|
+
"caption",
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
filename: {
|
|
50
|
+
propDefinition: [
|
|
51
|
+
telegramBotApi,
|
|
52
|
+
"filename",
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
media: {
|
|
56
|
+
propDefinition: [
|
|
57
|
+
telegramBotApi,
|
|
58
|
+
"media",
|
|
59
|
+
],
|
|
60
|
+
label: "Media",
|
|
61
|
+
},
|
|
62
|
+
parse_mode: {
|
|
63
|
+
propDefinition: [
|
|
64
|
+
telegramBotApi,
|
|
65
|
+
"parse_mode",
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
reply_markup: {
|
|
69
|
+
propDefinition: [
|
|
70
|
+
telegramBotApi,
|
|
71
|
+
"reply_markup",
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
async run({ $ }) {
|
|
76
|
+
const resp = await this.telegramBotApi.editMessageMedia({
|
|
77
|
+
type: this.type,
|
|
78
|
+
media: this.media,
|
|
79
|
+
caption: this.caption,
|
|
80
|
+
parse_mode: this.parse_mode,
|
|
81
|
+
}, {
|
|
82
|
+
chatId: this.chatId,
|
|
83
|
+
messageId: this.messageId,
|
|
84
|
+
reply_markup: this.reply_markup,
|
|
85
|
+
});
|
|
86
|
+
$.export("$summary", `Successfully edited the ${this.type || "media"} message in chat, "${this.chatId}"`);
|
|
87
|
+
return resp;
|
|
88
|
+
},
|
|
89
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "telegram_bot_api-edit-text-message",
|
|
5
|
+
name: "Edit a Text Message",
|
|
6
|
+
description: "Edits text or game messages. [See the docs](https://core.telegram.org/bots/api#editmessagetext) for more information",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
telegramBotApi,
|
|
11
|
+
chatId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
telegramBotApi,
|
|
14
|
+
"chatId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
messageId: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
telegramBotApi,
|
|
20
|
+
"messageId",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
text: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
telegramBotApi,
|
|
26
|
+
"text",
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
disable_notification: {
|
|
30
|
+
propDefinition: [
|
|
31
|
+
telegramBotApi,
|
|
32
|
+
"disable_notification",
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
async run({ $ }) {
|
|
37
|
+
const resp = await this.telegramBotApi.editMessageText(this.text, {
|
|
38
|
+
chatId: this.chatId,
|
|
39
|
+
messageId: this.messageId,
|
|
40
|
+
disable_notification: this.disable_notification,
|
|
41
|
+
});
|
|
42
|
+
$.export("$summary", `Successfully edited the message in chat, "${this.chatId}"`);
|
|
43
|
+
return resp;
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "telegram_bot_api-export-chat-invite-link",
|
|
5
|
+
name: "Export Chat Invite Link",
|
|
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.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
telegramBotApi,
|
|
11
|
+
chatId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
telegramBotApi,
|
|
14
|
+
"chatId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
async run({ $ }) {
|
|
19
|
+
const resp = await this.telegramBotApi.exportChatInviteLink(this.chatId);
|
|
20
|
+
$.export("$summary", `Successfully exported chat invite link, "${this.chatId}"`);
|
|
21
|
+
return resp;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "telegram_bot_api-forward-message",
|
|
5
|
+
name: "Forward a Message",
|
|
6
|
+
description: "Forwards messages of any kind. [See the docs](https://core.telegram.org/bots/api#forwardmessage) for more information",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
telegramBotApi,
|
|
11
|
+
chatId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
telegramBotApi,
|
|
14
|
+
"chatId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
fromChatId: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
telegramBotApi,
|
|
20
|
+
"fromChatId",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
messageId: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
telegramBotApi,
|
|
26
|
+
"messageId",
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
disable_notification: {
|
|
30
|
+
propDefinition: [
|
|
31
|
+
telegramBotApi,
|
|
32
|
+
"disable_notification",
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
async run({ $ }) {
|
|
37
|
+
const resp = await this.telegramBotApi.forwardMessage(
|
|
38
|
+
this.chatId,
|
|
39
|
+
this.fromChatId,
|
|
40
|
+
this.messageId,
|
|
41
|
+
{
|
|
42
|
+
disable_notification: this.disable_notification,
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
$.export("$summary", `Successfully forwarded the message from chat, "${this.fromChatId}", to chat, "${this.chatId}"`);
|
|
46
|
+
return resp;
|
|
47
|
+
},
|
|
48
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "telegram_bot_api-get-num-members-in-chat",
|
|
5
|
+
name: "Get the Number of Members in a Chat",
|
|
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.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
telegramBotApi,
|
|
11
|
+
chatId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
telegramBotApi,
|
|
14
|
+
"chatId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
async run({ $ }) {
|
|
19
|
+
const resp = await this.telegramBotApi.getChatMemberCount(this.chatId);
|
|
20
|
+
$.export("$summary", `Successfully fetched the number of members in chat, "${this.chatId}"`);
|
|
21
|
+
return resp;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "telegram_bot_api-kick-chat-member",
|
|
5
|
+
name: "Kick a Chat Member",
|
|
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.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
telegramBotApi,
|
|
11
|
+
chatId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
telegramBotApi,
|
|
14
|
+
"chatId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
userId: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
telegramBotApi,
|
|
20
|
+
"userId",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
until_date: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
telegramBotApi,
|
|
26
|
+
"until_date",
|
|
27
|
+
],
|
|
28
|
+
description: "Enter the date when the user will be unbanned, in [unix time](https://en.wikipedia.org/wiki/Unix_time) (e.g. `1567780450`).",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
async run({ $ }) {
|
|
32
|
+
const resp = await this.telegramBotApi.banChatMember(this.chatId, this.userId, {
|
|
33
|
+
until_date: this.until_date,
|
|
34
|
+
});
|
|
35
|
+
$.export("$summary", `Successfully kicked user, "${this.userId}", from the chat, "${this.chatId}"`);
|
|
36
|
+
return resp;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "telegram_bot_api-list-administrators-in-chat",
|
|
5
|
+
name: "List Administrators In Chat",
|
|
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.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
telegramBotApi,
|
|
11
|
+
chatId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
telegramBotApi,
|
|
14
|
+
"chatId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
async run({ $ }) {
|
|
19
|
+
const resp = await this.telegramBotApi.getChatAdministrators(this.chatId);
|
|
20
|
+
$.export("$summary", `Successfully fetched ${resp.length} administrator${resp.length === 1
|
|
21
|
+
? ""
|
|
22
|
+
: "s"} in the chat, "${this.chatId}"`);
|
|
23
|
+
return resp;
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "telegram_bot_api-list-chats",
|
|
5
|
+
name: "List Chats",
|
|
6
|
+
description: "List available Telegram chats. [See the docs](https://core.telegram.org/bots/api#getupdates) for more information",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
telegramBotApi,
|
|
11
|
+
offset: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
telegramBotApi,
|
|
14
|
+
"offset",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
limit: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
telegramBotApi,
|
|
20
|
+
"limit",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
autoPaging: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
telegramBotApi,
|
|
26
|
+
"autoPaging",
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
methods: {
|
|
31
|
+
/**
|
|
32
|
+
* Uses an Update object to generate a result object containing chat
|
|
33
|
+
* metadata, representing the source of the update and chat in which the
|
|
34
|
+
* update was made
|
|
35
|
+
*
|
|
36
|
+
* @param {Object} update - an Update to use to generate a result
|
|
37
|
+
* @returns a result representing a chat
|
|
38
|
+
*/
|
|
39
|
+
generateResultFromUpdate(update) {
|
|
40
|
+
return {
|
|
41
|
+
update_id: update.update_id,
|
|
42
|
+
...Object.keys(update).reduce((resultPart, key) => {
|
|
43
|
+
return (resultPart.chat
|
|
44
|
+
? resultPart
|
|
45
|
+
: {
|
|
46
|
+
chat: update[key].chat,
|
|
47
|
+
from: update[key].from,
|
|
48
|
+
forward_from_chat: update[key].forward_from_chat,
|
|
49
|
+
});
|
|
50
|
+
}, {}),
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
async run({ $ }) {
|
|
55
|
+
const updates = await this.telegramBotApi.getUpdates({
|
|
56
|
+
offset: this.offset,
|
|
57
|
+
limit: this.limit,
|
|
58
|
+
});
|
|
59
|
+
if (this.autoPaging && updates.length > 0) {
|
|
60
|
+
const lastUpdateId = updates[updates.length - 1].update_id;
|
|
61
|
+
// "Confirm" updates by calling API to get updates using an offset of the
|
|
62
|
+
// last `update_id + 1` See [documentation for getUpdates in the Telegram
|
|
63
|
+
// Bot API reference](https://core.telegram.org/bots/api#getupdates)
|
|
64
|
+
await this.telegramBotApi.getUpdates({
|
|
65
|
+
offset: lastUpdateId + 1,
|
|
66
|
+
limit: 1,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
// eslint-disable-next-line multiline-ternary
|
|
70
|
+
$.export("$summary", `Successfully fetched ${updates.length} available Telegram chat${updates.length === 1 ? "" : "s"}`);
|
|
71
|
+
return updates.map(this.generateResultFromUpdate);
|
|
72
|
+
},
|
|
73
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "telegram_bot_api-list-updates",
|
|
5
|
+
name: "List Updates",
|
|
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.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
telegramBotApi,
|
|
11
|
+
offset: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
telegramBotApi,
|
|
14
|
+
"offset",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
limit: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
telegramBotApi,
|
|
20
|
+
"limit",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
autoPaging: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
telegramBotApi,
|
|
26
|
+
"autoPaging",
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
async run({ $ }) {
|
|
31
|
+
const updates = await this.telegramBotApi.getUpdates({
|
|
32
|
+
offset: this.offset,
|
|
33
|
+
limit: this.limit,
|
|
34
|
+
});
|
|
35
|
+
if (this.autoPaging && updates.length > 0) {
|
|
36
|
+
const lastUpdateId = updates[updates.length - 1].update_id;
|
|
37
|
+
// "Confirm" updates by calling API to get updates using an offset of the
|
|
38
|
+
// last `update_id + 1` See [documentation for getUpdates in the Telegram
|
|
39
|
+
// Bot API reference](https://core.telegram.org/bots/api#getupdates)
|
|
40
|
+
await this.telegramBotApi.getUpdates({
|
|
41
|
+
offset: lastUpdateId + 1,
|
|
42
|
+
limit: 1,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
// eslint-disable-next-line multiline-ternary
|
|
46
|
+
$.export("$summary", `Successfully fetched ${updates.length} update${updates.length === 1 ? "" : "s"}`);
|
|
47
|
+
return updates;
|
|
48
|
+
},
|
|
49
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "telegram_bot_api-pin-message",
|
|
5
|
+
name: "Pin a Message",
|
|
6
|
+
description: "Pins a message. [See the docs](https://core.telegram.org/bots/api#pinchatmessage) for more information",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
telegramBotApi,
|
|
11
|
+
chatId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
telegramBotApi,
|
|
14
|
+
"chatId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
messageId: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
telegramBotApi,
|
|
20
|
+
"messageId",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
disable_notification: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
telegramBotApi,
|
|
26
|
+
"disable_notification",
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
async run({ $ }) {
|
|
31
|
+
const resp = await this.telegramBotApi.pinChatMessage(this.chatId, this.messageId, {
|
|
32
|
+
disable_notification: this.disable_notification,
|
|
33
|
+
});
|
|
34
|
+
$.export("$summary", `Successfully pinned the message in chat, "${this.chatId}"`);
|
|
35
|
+
return resp;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import telegramBotApi from "../../telegram_bot_api.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "telegram_bot_api-promote-chat-member",
|
|
5
|
+
name: "Promote a Chat Member",
|
|
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.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
telegramBotApi,
|
|
11
|
+
chatId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
telegramBotApi,
|
|
14
|
+
"chatId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
userId: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
telegramBotApi,
|
|
20
|
+
"userId",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
can_change_info: {
|
|
24
|
+
type: "boolean",
|
|
25
|
+
label: "Set if the Administrator Can Change Info",
|
|
26
|
+
description: "Pass True, if the administrator can change chat title, photo and other settings.",
|
|
27
|
+
optional: true,
|
|
28
|
+
},
|
|
29
|
+
can_post_messages: {
|
|
30
|
+
type: "boolean",
|
|
31
|
+
label: "Set if the Administrator Can Create Channel Posts",
|
|
32
|
+
description: "Pass True, if the administrator can create channel posts [channels only].",
|
|
33
|
+
optional: true,
|
|
34
|
+
},
|
|
35
|
+
can_edit_messages: {
|
|
36
|
+
type: "boolean",
|
|
37
|
+
label: "Set if the Administrator Can Edit Messages",
|
|
38
|
+
description: "Pass True, if the administrator can edit messages of other users and can pin messages [channels only].",
|
|
39
|
+
optional: true,
|
|
40
|
+
},
|
|
41
|
+
can_delete_messages: {
|
|
42
|
+
type: "boolean",
|
|
43
|
+
label: "Set if the Administrator Can Delete Messages",
|
|
44
|
+
description: "Pass True, if the administrator can delete messages of other users [channels only].",
|
|
45
|
+
optional: true,
|
|
46
|
+
},
|
|
47
|
+
can_invite_users: {
|
|
48
|
+
type: "boolean",
|
|
49
|
+
label: "Set if the Administrator Can Invite Users",
|
|
50
|
+
description: "Pass True, if the administrator can invite new users to the chat.",
|
|
51
|
+
optional: true,
|
|
52
|
+
},
|
|
53
|
+
can_restrict_members: {
|
|
54
|
+
type: "boolean",
|
|
55
|
+
label: "Set if the Administrator Can Restrict Members",
|
|
56
|
+
description: "Pass True, if the administrator can restrict, ban or unban chat members.",
|
|
57
|
+
optional: true,
|
|
58
|
+
},
|
|
59
|
+
can_pin_messages: {
|
|
60
|
+
type: "boolean",
|
|
61
|
+
label: "Set if the Administrator Can Pin Messages",
|
|
62
|
+
description: "Pass True, if the administrator can pin messages [supergroups only].",
|
|
63
|
+
optional: true,
|
|
64
|
+
},
|
|
65
|
+
can_promote_members: {
|
|
66
|
+
type: "boolean",
|
|
67
|
+
label: "Set if the Administrator Can Promote Members",
|
|
68
|
+
description: "Pass True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by them).",
|
|
69
|
+
optional: true,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
async run({ $ }) {
|
|
73
|
+
const resp = await this.telegramBotApi.promoteChatMember(this.chatId, this.userId, {
|
|
74
|
+
can_change_info: this.can_change_info,
|
|
75
|
+
can_post_messages: this.can_post_messages,
|
|
76
|
+
can_edit_messages: this.can_edit_messages,
|
|
77
|
+
can_delete_messages: this.can_delete_messages,
|
|
78
|
+
can_invite_users: this.can_invite_users,
|
|
79
|
+
can_restrict_members: this.can_restrict_members,
|
|
80
|
+
can_pin_messages: this.can_pin_messages,
|
|
81
|
+
can_promote_members: this.can_promote_members,
|
|
82
|
+
});
|
|
83
|
+
$.export("$summary", `Successfully promoted the user, "${this.userId}", in chat, "${this.chatId}"`);
|
|
84
|
+
return resp;
|
|
85
|
+
},
|
|
86
|
+
};
|