@divyacon/piece-telegram-bot 0.0.0-stage → 0.1.0
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.MIT-AP +24 -0
- package/README.md +8 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +122 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/action/answer-callback-query.action.d.ts +8 -0
- package/dist/lib/action/answer-callback-query.action.d.ts.map +1 -0
- package/dist/lib/action/answer-callback-query.action.js +63 -0
- package/dist/lib/action/answer-callback-query.action.js.map +1 -0
- package/dist/lib/action/create-invite-link.d.ts +9 -0
- package/dist/lib/action/create-invite-link.d.ts.map +1 -0
- package/dist/lib/action/create-invite-link.js +66 -0
- package/dist/lib/action/create-invite-link.js.map +1 -0
- package/dist/lib/action/delete-message.action.d.ts +6 -0
- package/dist/lib/action/delete-message.action.d.ts.map +1 -0
- package/dist/lib/action/delete-message.action.js +42 -0
- package/dist/lib/action/delete-message.action.js.map +1 -0
- package/dist/lib/action/edit-message-text.action.d.ts +12 -0
- package/dist/lib/action/edit-message-text.action.d.ts.map +1 -0
- package/dist/lib/action/edit-message-text.action.js +76 -0
- package/dist/lib/action/edit-message-text.action.js.map +1 -0
- package/dist/lib/action/forward-message.action.d.ts +10 -0
- package/dist/lib/action/forward-message.action.d.ts.map +1 -0
- package/dist/lib/action/forward-message.action.js +59 -0
- package/dist/lib/action/forward-message.action.js.map +1 -0
- package/dist/lib/action/get-chat-member.d.ts +6 -0
- package/dist/lib/action/get-chat-member.d.ts.map +1 -0
- package/dist/lib/action/get-chat-member.js +49 -0
- package/dist/lib/action/get-chat-member.js.map +1 -0
- package/dist/lib/action/get-chat.action.d.ts +5 -0
- package/dist/lib/action/get-chat.action.d.ts.map +1 -0
- package/dist/lib/action/get-chat.action.js +42 -0
- package/dist/lib/action/get-chat.action.js.map +1 -0
- package/dist/lib/action/get-file.action.d.ts +5 -0
- package/dist/lib/action/get-file.action.d.ts.map +1 -0
- package/dist/lib/action/get-file.action.js +69 -0
- package/dist/lib/action/get-file.action.js.map +1 -0
- package/dist/lib/action/pin-message.action.d.ts +7 -0
- package/dist/lib/action/pin-message.action.d.ts.map +1 -0
- package/dist/lib/action/pin-message.action.js +50 -0
- package/dist/lib/action/pin-message.action.js.map +1 -0
- package/dist/lib/action/request-approval-message.d.ts +7 -0
- package/dist/lib/action/request-approval-message.d.ts.map +1 -0
- package/dist/lib/action/request-approval-message.js +84 -0
- package/dist/lib/action/request-approval-message.js.map +1 -0
- package/dist/lib/action/send-audio.action.d.ts +18 -0
- package/dist/lib/action/send-audio.action.d.ts.map +1 -0
- package/dist/lib/action/send-audio.action.js +128 -0
- package/dist/lib/action/send-audio.action.js.map +1 -0
- package/dist/lib/action/send-chat-action.action.d.ts +7 -0
- package/dist/lib/action/send-chat-action.action.d.ts.map +1 -0
- package/dist/lib/action/send-chat-action.action.js +61 -0
- package/dist/lib/action/send-chat-action.action.js.map +1 -0
- package/dist/lib/action/send-document.action.d.ts +15 -0
- package/dist/lib/action/send-document.action.d.ts.map +1 -0
- package/dist/lib/action/send-document.action.js +104 -0
- package/dist/lib/action/send-document.action.js.map +1 -0
- package/dist/lib/action/send-location.action.d.ts +16 -0
- package/dist/lib/action/send-location.action.d.ts.map +1 -0
- package/dist/lib/action/send-location.action.js +83 -0
- package/dist/lib/action/send-location.action.js.map +1 -0
- package/dist/lib/action/send-media-group.action.d.ts +11 -0
- package/dist/lib/action/send-media-group.action.d.ts.map +1 -0
- package/dist/lib/action/send-media-group.action.js +97 -0
- package/dist/lib/action/send-media-group.action.js.map +1 -0
- package/dist/lib/action/send-media.action.d.ts +14 -0
- package/dist/lib/action/send-media.action.d.ts.map +1 -0
- package/dist/lib/action/send-media.action.js +198 -0
- package/dist/lib/action/send-media.action.js.map +1 -0
- package/dist/lib/action/send-poll.action.d.ts +21 -0
- package/dist/lib/action/send-poll.action.d.ts.map +1 -0
- package/dist/lib/action/send-poll.action.js +145 -0
- package/dist/lib/action/send-poll.action.js.map +1 -0
- package/dist/lib/action/send-text-message.action.d.ts +14 -0
- package/dist/lib/action/send-text-message.action.d.ts.map +1 -0
- package/dist/lib/action/send-text-message.action.js +63 -0
- package/dist/lib/action/send-text-message.action.js.map +1 -0
- package/dist/lib/action/telegram-answer-callback-query.d.ts +8 -0
- package/dist/lib/action/telegram-answer-callback-query.d.ts.map +1 -0
- package/dist/lib/action/telegram-answer-callback-query.js +68 -0
- package/dist/lib/action/telegram-answer-callback-query.js.map +1 -0
- package/dist/lib/action/telegram-create-invite-link.d.ts +8 -0
- package/dist/lib/action/telegram-create-invite-link.d.ts.map +1 -0
- package/dist/lib/action/telegram-create-invite-link.js +68 -0
- package/dist/lib/action/telegram-create-invite-link.js.map +1 -0
- package/dist/lib/action/telegram-delete-message.d.ts +5 -0
- package/dist/lib/action/telegram-delete-message.d.ts.map +1 -0
- package/dist/lib/action/telegram-delete-message.js +44 -0
- package/dist/lib/action/telegram-delete-message.js.map +1 -0
- package/dist/lib/action/telegram-edit-message-text.d.ts +10 -0
- package/dist/lib/action/telegram-edit-message-text.d.ts.map +1 -0
- package/dist/lib/action/telegram-edit-message-text.js +93 -0
- package/dist/lib/action/telegram-edit-message-text.js.map +1 -0
- package/dist/lib/action/telegram-forward-message.d.ts +9 -0
- package/dist/lib/action/telegram-forward-message.d.ts.map +1 -0
- package/dist/lib/action/telegram-forward-message.js +61 -0
- package/dist/lib/action/telegram-forward-message.js.map +1 -0
- package/dist/lib/action/telegram-get-bot-info.d.ts +2 -0
- package/dist/lib/action/telegram-get-bot-info.d.ts.map +1 -0
- package/dist/lib/action/telegram-get-bot-info.js +39 -0
- package/dist/lib/action/telegram-get-bot-info.js.map +1 -0
- package/dist/lib/action/telegram-get-chat-administrators.d.ts +4 -0
- package/dist/lib/action/telegram-get-chat-administrators.d.ts.map +1 -0
- package/dist/lib/action/telegram-get-chat-administrators.js +44 -0
- package/dist/lib/action/telegram-get-chat-administrators.js.map +1 -0
- package/dist/lib/action/telegram-get-chat-member-count.d.ts +4 -0
- package/dist/lib/action/telegram-get-chat-member-count.d.ts.map +1 -0
- package/dist/lib/action/telegram-get-chat-member-count.js +44 -0
- package/dist/lib/action/telegram-get-chat-member-count.js.map +1 -0
- package/dist/lib/action/telegram-get-chat-member.d.ts +5 -0
- package/dist/lib/action/telegram-get-chat-member.d.ts.map +1 -0
- package/dist/lib/action/telegram-get-chat-member.js +51 -0
- package/dist/lib/action/telegram-get-chat-member.js.map +1 -0
- package/dist/lib/action/telegram-get-chat.d.ts +4 -0
- package/dist/lib/action/telegram-get-chat.d.ts.map +1 -0
- package/dist/lib/action/telegram-get-chat.js +44 -0
- package/dist/lib/action/telegram-get-chat.js.map +1 -0
- package/dist/lib/action/telegram-get-file.d.ts +5 -0
- package/dist/lib/action/telegram-get-file.d.ts.map +1 -0
- package/dist/lib/action/telegram-get-file.js +72 -0
- package/dist/lib/action/telegram-get-file.js.map +1 -0
- package/dist/lib/action/telegram-pin-message.d.ts +6 -0
- package/dist/lib/action/telegram-pin-message.d.ts.map +1 -0
- package/dist/lib/action/telegram-pin-message.js +52 -0
- package/dist/lib/action/telegram-pin-message.js.map +1 -0
- package/dist/lib/action/telegram-send-audio.d.ts +16 -0
- package/dist/lib/action/telegram-send-audio.d.ts.map +1 -0
- package/dist/lib/action/telegram-send-audio.js +149 -0
- package/dist/lib/action/telegram-send-audio.js.map +1 -0
- package/dist/lib/action/telegram-send-chat-action.d.ts +6 -0
- package/dist/lib/action/telegram-send-chat-action.d.ts.map +1 -0
- package/dist/lib/action/telegram-send-chat-action.js +67 -0
- package/dist/lib/action/telegram-send-chat-action.js.map +1 -0
- package/dist/lib/action/telegram-send-document.d.ts +13 -0
- package/dist/lib/action/telegram-send-document.d.ts.map +1 -0
- package/dist/lib/action/telegram-send-document.js +125 -0
- package/dist/lib/action/telegram-send-document.js.map +1 -0
- package/dist/lib/action/telegram-send-location.d.ts +15 -0
- package/dist/lib/action/telegram-send-location.d.ts.map +1 -0
- package/dist/lib/action/telegram-send-location.js +93 -0
- package/dist/lib/action/telegram-send-location.js.map +1 -0
- package/dist/lib/action/telegram-send-media-group.d.ts +10 -0
- package/dist/lib/action/telegram-send-media-group.d.ts.map +1 -0
- package/dist/lib/action/telegram-send-media-group.js +115 -0
- package/dist/lib/action/telegram-send-media-group.js.map +1 -0
- package/dist/lib/action/telegram-send-message.d.ts +12 -0
- package/dist/lib/action/telegram-send-message.d.ts.map +1 -0
- package/dist/lib/action/telegram-send-message.js +84 -0
- package/dist/lib/action/telegram-send-message.js.map +1 -0
- package/dist/lib/action/telegram-send-photo-or-video.d.ts +12 -0
- package/dist/lib/action/telegram-send-photo-or-video.d.ts.map +1 -0
- package/dist/lib/action/telegram-send-photo-or-video.js +219 -0
- package/dist/lib/action/telegram-send-photo-or-video.js.map +1 -0
- package/dist/lib/action/telegram-send-poll.d.ts +20 -0
- package/dist/lib/action/telegram-send-poll.d.ts.map +1 -0
- package/dist/lib/action/telegram-send-poll.js +167 -0
- package/dist/lib/action/telegram-send-poll.js.map +1 -0
- package/dist/lib/action/telegram-unpin-message.d.ts +5 -0
- package/dist/lib/action/telegram-unpin-message.d.ts.map +1 -0
- package/dist/lib/action/telegram-unpin-message.js +45 -0
- package/dist/lib/action/telegram-unpin-message.js.map +1 -0
- package/dist/lib/action/unpin-message.action.d.ts +6 -0
- package/dist/lib/action/unpin-message.action.d.ts.map +1 -0
- package/dist/lib/action/unpin-message.action.js +43 -0
- package/dist/lib/action/unpin-message.action.js.map +1 -0
- package/dist/lib/common/index.d.ts +25 -0
- package/dist/lib/common/index.d.ts.map +1 -0
- package/dist/lib/common/index.js +104 -0
- package/dist/lib/common/index.js.map +1 -0
- package/dist/lib/output-schemas.d.ts +41 -0
- package/dist/lib/output-schemas.d.ts.map +1 -0
- package/dist/lib/output-schemas.js +1853 -0
- package/dist/lib/output-schemas.js.map +1 -0
- package/dist/lib/trigger/new-message.d.ts +15 -0
- package/dist/lib/trigger/new-message.d.ts.map +1 -0
- package/dist/lib/trigger/new-message.js +121 -0
- package/dist/lib/trigger/new-message.js.map +1 -0
- package/package.json +44 -3
- package/src/index.ts +119 -0
- package/src/lib/action/answer-callback-query.action.ts +58 -0
- package/src/lib/action/create-invite-link.ts +59 -0
- package/src/lib/action/delete-message.action.ts +34 -0
- package/src/lib/action/edit-message-text.action.ts +71 -0
- package/src/lib/action/forward-message.action.ts +50 -0
- package/src/lib/action/get-chat-member.ts +40 -0
- package/src/lib/action/get-chat.action.ts +33 -0
- package/src/lib/action/get-file.action.ts +79 -0
- package/src/lib/action/pin-message.action.ts +41 -0
- package/src/lib/action/request-approval-message.ts +85 -0
- package/src/lib/action/send-audio.action.ts +123 -0
- package/src/lib/action/send-chat-action.action.ts +53 -0
- package/src/lib/action/send-document.action.ts +105 -0
- package/src/lib/action/send-location.action.ts +76 -0
- package/src/lib/action/send-media-group.action.ts +98 -0
- package/src/lib/action/send-media.action.ts +209 -0
- package/src/lib/action/send-poll.action.ts +140 -0
- package/src/lib/action/send-text-message.action.ts +54 -0
- package/src/lib/action/telegram-answer-callback-query.ts +64 -0
- package/src/lib/action/telegram-create-invite-link.ts +62 -0
- package/src/lib/action/telegram-delete-message.ts +37 -0
- package/src/lib/action/telegram-edit-message-text.ts +92 -0
- package/src/lib/action/telegram-forward-message.ts +54 -0
- package/src/lib/action/telegram-get-bot-info.ts +31 -0
- package/src/lib/action/telegram-get-chat-administrators.ts +36 -0
- package/src/lib/action/telegram-get-chat-member-count.ts +36 -0
- package/src/lib/action/telegram-get-chat-member.ts +43 -0
- package/src/lib/action/telegram-get-chat.ts +36 -0
- package/src/lib/action/telegram-get-file.ts +83 -0
- package/src/lib/action/telegram-pin-message.ts +45 -0
- package/src/lib/action/telegram-send-audio.ts +157 -0
- package/src/lib/action/telegram-send-chat-action.ts +61 -0
- package/src/lib/action/telegram-send-document.ts +136 -0
- package/src/lib/action/telegram-send-location.ts +89 -0
- package/src/lib/action/telegram-send-media-group.ts +119 -0
- package/src/lib/action/telegram-send-message.ts +79 -0
- package/src/lib/action/telegram-send-photo-or-video.ts +238 -0
- package/src/lib/action/telegram-send-poll.ts +170 -0
- package/src/lib/action/telegram-unpin-message.ts +38 -0
- package/src/lib/action/unpin-message.action.ts +36 -0
- package/src/lib/common/index.ts +147 -0
- package/src/lib/output-schemas.ts +1909 -0
- package/src/lib/trigger/new-message.ts +127 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { httpClient, HttpMethod } from '@agnocon/pieces-common';
|
|
2
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
3
|
+
import { telegramBotAuth } from '../..';
|
|
4
|
+
import { telegramCommons } from '../common';
|
|
5
|
+
import { telegramCreateInviteLinkActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const telegramCreateInviteLink = createAction({
|
|
8
|
+
auth: telegramBotAuth,
|
|
9
|
+
name: 'telegram_create_invite_link',
|
|
10
|
+
displayName: 'Create Invite Link',
|
|
11
|
+
description: 'Create a new invite link for a Telegram chat.',
|
|
12
|
+
audience: 'ai',
|
|
13
|
+
aiMetadata: {
|
|
14
|
+
description:
|
|
15
|
+
'Creates a new invite link for a chat by chat_id (a numeric id or @channelusername the bot can reach), optionally with a name, expiry, member limit, or join-request approval. Use to generate a shareable join link; the bot must be an administrator with invite rights. Not idempotent: each call mints a distinct new link (it does not reuse or revoke prior links).',
|
|
16
|
+
idempotent: false,
|
|
17
|
+
},
|
|
18
|
+
outputSchema: telegramCreateInviteLinkActionOutputSchema,
|
|
19
|
+
props: {
|
|
20
|
+
chat_id: telegramCommons.chatIdProp(),
|
|
21
|
+
name: Property.ShortText({
|
|
22
|
+
displayName: 'Name',
|
|
23
|
+
description: 'Name of the invite link (max 32 chars).',
|
|
24
|
+
required: false,
|
|
25
|
+
}),
|
|
26
|
+
expire_date: Property.DateTime({
|
|
27
|
+
displayName: 'Expire Date',
|
|
28
|
+
description: 'Point in time when the link will expire.',
|
|
29
|
+
required: false,
|
|
30
|
+
}),
|
|
31
|
+
member_limit: Property.Number({
|
|
32
|
+
displayName: 'Member Limit',
|
|
33
|
+
description:
|
|
34
|
+
'Maximum number of users that can be members of the chat simultaneously after joining via this invite link; 1-99999.',
|
|
35
|
+
required: false,
|
|
36
|
+
}),
|
|
37
|
+
creates_join_request: Property.Checkbox({
|
|
38
|
+
displayName: 'Creates Join Request',
|
|
39
|
+
description:
|
|
40
|
+
'If True, users joining the chat via the link need to be approved by chat administrators.',
|
|
41
|
+
required: false,
|
|
42
|
+
defaultValue: false,
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
async run(ctx) {
|
|
46
|
+
const response = await httpClient.sendRequest<never>({
|
|
47
|
+
method: HttpMethod.POST,
|
|
48
|
+
url: telegramCommons.getApiUrl(ctx.auth, 'createChatInviteLink'),
|
|
49
|
+
headers: {},
|
|
50
|
+
body: {
|
|
51
|
+
chat_id: ctx.propsValue.chat_id,
|
|
52
|
+
name: ctx.propsValue.name ?? undefined,
|
|
53
|
+
expire_date: ctx.propsValue.expire_date
|
|
54
|
+
? Math.floor(new Date(ctx.propsValue.expire_date).getTime() / 1000)
|
|
55
|
+
: undefined,
|
|
56
|
+
member_limit: ctx.propsValue.member_limit ?? undefined,
|
|
57
|
+
creates_join_request: ctx.propsValue.creates_join_request ?? false,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
return response.body;
|
|
61
|
+
},
|
|
62
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
2
|
+
import { HttpMethod, httpClient } from '@agnocon/pieces-common';
|
|
3
|
+
import { telegramCommons } from '../common';
|
|
4
|
+
import { telegramBotAuth } from '../..';
|
|
5
|
+
import { telegramDeleteMessageActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const telegramDeleteMessage = createAction({
|
|
8
|
+
auth: telegramBotAuth,
|
|
9
|
+
name: 'telegram_delete_message',
|
|
10
|
+
displayName: 'Delete Message',
|
|
11
|
+
description: 'Delete a message from a Telegram chat.',
|
|
12
|
+
audience: 'ai',
|
|
13
|
+
aiMetadata: {
|
|
14
|
+
description:
|
|
15
|
+
'Permanently removes a message from a chat, targeted by chat_id (a numeric id or @channelusername the bot can reach) and message_id (from a prior send action\'s return or the New Message trigger payload). Use to clean up or retract content; the bot can delete only its own messages, or any message in groups where it is an administrator. Idempotent in effect: the message ends up gone regardless of how many times this runs.',
|
|
16
|
+
idempotent: true,
|
|
17
|
+
},
|
|
18
|
+
outputSchema: telegramDeleteMessageActionOutputSchema,
|
|
19
|
+
props: {
|
|
20
|
+
chat_id: telegramCommons.chatIdProp(),
|
|
21
|
+
message_id: Property.ShortText({
|
|
22
|
+
displayName: 'Message Id',
|
|
23
|
+
description: 'Identifier of the message to delete.',
|
|
24
|
+
required: true,
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
async run(ctx) {
|
|
28
|
+
return await httpClient.sendRequest<never>({
|
|
29
|
+
method: HttpMethod.POST,
|
|
30
|
+
url: telegramCommons.getApiUrl(ctx.auth, 'deleteMessage'),
|
|
31
|
+
body: {
|
|
32
|
+
chat_id: ctx.propsValue.chat_id,
|
|
33
|
+
message_id: ctx.propsValue.message_id,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
2
|
+
import { HttpMethod, httpClient } from '@agnocon/pieces-common';
|
|
3
|
+
import { telegramCommons } from '../common';
|
|
4
|
+
import { telegramBotAuth } from '../..';
|
|
5
|
+
import { telegramEditMessageTextActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const telegramEditMessageText = createAction({
|
|
8
|
+
auth: telegramBotAuth,
|
|
9
|
+
name: 'telegram_edit_message_text',
|
|
10
|
+
displayName: 'Edit Message Text',
|
|
11
|
+
description: 'Edit the text of a message the bot already sent.',
|
|
12
|
+
audience: 'ai',
|
|
13
|
+
aiMetadata: {
|
|
14
|
+
description:
|
|
15
|
+
'Replaces the text of a message the bot already sent, targeted by chat_id + message_id OR by inline_message_id (the two modes are mutually exclusive — resolve message_id from the send action\'s return or the New Message trigger payload). Use to update a status or correct a message in place instead of sending a new one. Text is sent as plain text unless format is set; if you set MarkdownV2 or HTML the text must be correctly escaped or Telegram rejects it. Idempotent in effect (the message ends at the given text), but Telegram rejects an edit whose new text matches the current content.',
|
|
16
|
+
idempotent: true,
|
|
17
|
+
},
|
|
18
|
+
outputSchema: telegramEditMessageTextActionOutputSchema,
|
|
19
|
+
props: {
|
|
20
|
+
chat_id: Property.ShortText({
|
|
21
|
+
displayName: 'Chat Id',
|
|
22
|
+
description:
|
|
23
|
+
'Numeric id or @channelusername of the chat holding the message. Required together with Message Id; leave empty when editing an inline message (use Inline Message Id instead).',
|
|
24
|
+
required: false,
|
|
25
|
+
}),
|
|
26
|
+
message_id: Property.ShortText({
|
|
27
|
+
displayName: 'Message Id',
|
|
28
|
+
description: 'Identifier of the message to edit (used together with Chat Id).',
|
|
29
|
+
required: false,
|
|
30
|
+
}),
|
|
31
|
+
inline_message_id: Property.ShortText({
|
|
32
|
+
displayName: 'Inline Message Id',
|
|
33
|
+
description:
|
|
34
|
+
'Identifier of the inline message (mutually exclusive with Chat Id + Message Id).',
|
|
35
|
+
required: false,
|
|
36
|
+
}),
|
|
37
|
+
text: Property.LongText({
|
|
38
|
+
displayName: 'New Text',
|
|
39
|
+
description: 'New text of the message (1–4096 chars).',
|
|
40
|
+
required: true,
|
|
41
|
+
}),
|
|
42
|
+
format: Property.StaticDropdown({
|
|
43
|
+
displayName: 'Format',
|
|
44
|
+
description:
|
|
45
|
+
'How the message text should be parsed by Telegram. Defaults to plain text; only set MarkdownV2 or HTML when the text is correctly escaped/tagged.',
|
|
46
|
+
required: false,
|
|
47
|
+
options: {
|
|
48
|
+
options: [
|
|
49
|
+
{ label: 'Plain Text', value: 'None' },
|
|
50
|
+
{ label: 'Markdown (V2)', value: 'MarkdownV2' },
|
|
51
|
+
{ label: 'HTML', value: 'HTML' },
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
defaultValue: 'None',
|
|
55
|
+
}),
|
|
56
|
+
disable_web_page_preview: Property.Checkbox({
|
|
57
|
+
displayName: 'Disable Web Page Preview',
|
|
58
|
+
description: 'Disable link previews for links in this message.',
|
|
59
|
+
required: false,
|
|
60
|
+
defaultValue: false,
|
|
61
|
+
}),
|
|
62
|
+
reply_markup: Property.Json({
|
|
63
|
+
displayName: 'Reply Markup',
|
|
64
|
+
description:
|
|
65
|
+
'Advanced/optional. A raw JSON-serialized inline keyboard, e.g. {"inline_keyboard":[[{"text":"Open","url":"https://example.com"}]]}. Malformed markup is rejected by Telegram.',
|
|
66
|
+
required: false,
|
|
67
|
+
}),
|
|
68
|
+
},
|
|
69
|
+
async run(ctx) {
|
|
70
|
+
const hasChatTarget = Boolean(ctx.propsValue.chat_id && ctx.propsValue.message_id);
|
|
71
|
+
const hasInlineTarget = Boolean(ctx.propsValue.inline_message_id);
|
|
72
|
+
if (!hasChatTarget && !hasInlineTarget) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
'Either Chat Id + Message Id, or Inline Message Id, must be provided.'
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return await httpClient.sendRequest<never>({
|
|
79
|
+
method: HttpMethod.POST,
|
|
80
|
+
url: telegramCommons.getApiUrl(ctx.auth, 'editMessageText'),
|
|
81
|
+
body: {
|
|
82
|
+
chat_id: ctx.propsValue.chat_id ?? undefined,
|
|
83
|
+
message_id: ctx.propsValue.message_id ?? undefined,
|
|
84
|
+
inline_message_id: ctx.propsValue.inline_message_id ?? undefined,
|
|
85
|
+
text: ctx.propsValue.text,
|
|
86
|
+
parse_mode: telegramCommons.resolveParseMode(ctx.propsValue.format),
|
|
87
|
+
disable_web_page_preview: ctx.propsValue.disable_web_page_preview ?? false,
|
|
88
|
+
reply_markup: ctx.propsValue.reply_markup ?? undefined,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
2
|
+
import { HttpMethod, httpClient } from '@agnocon/pieces-common';
|
|
3
|
+
import { telegramCommons } from '../common';
|
|
4
|
+
import { telegramBotAuth } from '../..';
|
|
5
|
+
import { telegramForwardMessageActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const telegramForwardMessage = createAction({
|
|
8
|
+
auth: telegramBotAuth,
|
|
9
|
+
name: 'telegram_forward_message',
|
|
10
|
+
displayName: 'Forward Message',
|
|
11
|
+
description: 'Forward a message from one chat to another.',
|
|
12
|
+
audience: 'ai',
|
|
13
|
+
aiMetadata: {
|
|
14
|
+
description:
|
|
15
|
+
'Forwards an existing message from a source chat (from_chat_id) to a target chat (chat_id), preserving original sender attribution. chat_id and from_chat_id are each a numeric id or @channelusername the bot can reach; message_id comes from the New Message trigger or a prior send action. Use to relay content the bot can access between chats; the bot must be able to read the source and post to the target. Not idempotent: each call creates a new forwarded message.',
|
|
16
|
+
idempotent: false,
|
|
17
|
+
},
|
|
18
|
+
outputSchema: telegramForwardMessageActionOutputSchema,
|
|
19
|
+
props: {
|
|
20
|
+
chat_id: Property.ShortText({
|
|
21
|
+
displayName: 'Target Chat Id',
|
|
22
|
+
description:
|
|
23
|
+
'Chat the message will be forwarded to (a numeric id or @channelusername the bot can reach).',
|
|
24
|
+
required: true,
|
|
25
|
+
}),
|
|
26
|
+
from_chat_id: Property.ShortText({
|
|
27
|
+
displayName: 'From Chat Id',
|
|
28
|
+
description: 'Chat the original message came from.',
|
|
29
|
+
required: true,
|
|
30
|
+
}),
|
|
31
|
+
message_id: Property.ShortText({
|
|
32
|
+
displayName: 'Message Id',
|
|
33
|
+
description: 'Identifier of the message to forward.',
|
|
34
|
+
required: true,
|
|
35
|
+
}),
|
|
36
|
+
message_thread_id: telegramCommons.messageThreadIdProp(),
|
|
37
|
+
disable_notification: telegramCommons.disableNotificationProp(),
|
|
38
|
+
protect_content: telegramCommons.protectContentProp(),
|
|
39
|
+
},
|
|
40
|
+
async run(ctx) {
|
|
41
|
+
return await httpClient.sendRequest<never>({
|
|
42
|
+
method: HttpMethod.POST,
|
|
43
|
+
url: telegramCommons.getApiUrl(ctx.auth, 'forwardMessage'),
|
|
44
|
+
body: {
|
|
45
|
+
chat_id: ctx.propsValue.chat_id,
|
|
46
|
+
from_chat_id: ctx.propsValue.from_chat_id,
|
|
47
|
+
message_id: ctx.propsValue.message_id,
|
|
48
|
+
message_thread_id: ctx.propsValue.message_thread_id ?? undefined,
|
|
49
|
+
disable_notification: ctx.propsValue.disable_notification ?? false,
|
|
50
|
+
protect_content: ctx.propsValue.protect_content ?? false,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { HttpError, HttpMethod, httpClient } from '@agnocon/pieces-common';
|
|
2
|
+
import { createAction } from '@agnocon/pieces-framework';
|
|
3
|
+
import { telegramCommons } from '../common';
|
|
4
|
+
import { telegramBotAuth } from '../..';
|
|
5
|
+
import { telegramGetBotInfoActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const telegramGetBotInfo = createAction({
|
|
8
|
+
auth: telegramBotAuth,
|
|
9
|
+
name: 'telegram_get_bot_info',
|
|
10
|
+
displayName: 'Get Bot Info',
|
|
11
|
+
description: "Get the authenticated bot's own identity and capabilities.",
|
|
12
|
+
audience: 'ai',
|
|
13
|
+
aiMetadata: {
|
|
14
|
+
description:
|
|
15
|
+
"Returns the authenticated bot's own identity and capabilities (id, username, name, and which features such as inline mode or group joins are enabled). Use to confirm which bot the connection points at or to read the bot's @username before building an invite or mention. Read-only and takes no input.",
|
|
16
|
+
idempotent: true,
|
|
17
|
+
},
|
|
18
|
+
outputSchema: telegramGetBotInfoActionOutputSchema,
|
|
19
|
+
props: {},
|
|
20
|
+
async run(ctx) {
|
|
21
|
+
try {
|
|
22
|
+
const response = await httpClient.sendRequest<never>({
|
|
23
|
+
method: HttpMethod.POST,
|
|
24
|
+
url: telegramCommons.getApiUrl(ctx.auth, 'getMe'),
|
|
25
|
+
});
|
|
26
|
+
return response.body;
|
|
27
|
+
} catch (error) {
|
|
28
|
+
return (error as HttpError).errorMessage().response.body;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { HttpError, HttpMethod, httpClient } from '@agnocon/pieces-common';
|
|
2
|
+
import { createAction } from '@agnocon/pieces-framework';
|
|
3
|
+
import { telegramCommons } from '../common';
|
|
4
|
+
import { telegramBotAuth } from '../..';
|
|
5
|
+
import { telegramGetChatAdministratorsActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const telegramGetChatAdministrators = createAction({
|
|
8
|
+
auth: telegramBotAuth,
|
|
9
|
+
name: 'telegram_get_chat_administrators',
|
|
10
|
+
displayName: 'Get Chat Administrators',
|
|
11
|
+
description: 'List the administrators of a Telegram chat.',
|
|
12
|
+
audience: 'ai',
|
|
13
|
+
aiMetadata: {
|
|
14
|
+
description:
|
|
15
|
+
"Lists the administrators of a chat by chat_id (a numeric id or @channelusername) — each admin's user, status (creator/administrator), and granted rights. Use to discover who can moderate a chat, or to find a user_id before checking one member with telegram_get_chat_member. Returns an empty list for private chats. Read-only.",
|
|
16
|
+
idempotent: true,
|
|
17
|
+
},
|
|
18
|
+
outputSchema: telegramGetChatAdministratorsActionOutputSchema,
|
|
19
|
+
props: {
|
|
20
|
+
chat_id: telegramCommons.chatIdProp(),
|
|
21
|
+
},
|
|
22
|
+
async run(ctx) {
|
|
23
|
+
try {
|
|
24
|
+
const response = await httpClient.sendRequest<never>({
|
|
25
|
+
method: HttpMethod.POST,
|
|
26
|
+
url: telegramCommons.getApiUrl(ctx.auth, 'getChatAdministrators'),
|
|
27
|
+
body: {
|
|
28
|
+
chat_id: ctx.propsValue.chat_id,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
return response.body;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return (error as HttpError).errorMessage().response.body;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { HttpError, HttpMethod, httpClient } from '@agnocon/pieces-common';
|
|
2
|
+
import { createAction } from '@agnocon/pieces-framework';
|
|
3
|
+
import { telegramCommons } from '../common';
|
|
4
|
+
import { telegramBotAuth } from '../..';
|
|
5
|
+
import { telegramGetChatMemberCountActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const telegramGetChatMemberCount = createAction({
|
|
8
|
+
auth: telegramBotAuth,
|
|
9
|
+
name: 'telegram_get_chat_member_count',
|
|
10
|
+
displayName: 'Get Chat Member Count',
|
|
11
|
+
description: 'Get the number of members in a Telegram chat.',
|
|
12
|
+
audience: 'ai',
|
|
13
|
+
aiMetadata: {
|
|
14
|
+
description:
|
|
15
|
+
'Returns the number of members in a chat by chat_id (a numeric id or @channelusername). Use to size a group or channel before posting or to monitor membership; for per-user details use telegram_get_chat_member. Read-only.',
|
|
16
|
+
idempotent: true,
|
|
17
|
+
},
|
|
18
|
+
outputSchema: telegramGetChatMemberCountActionOutputSchema,
|
|
19
|
+
props: {
|
|
20
|
+
chat_id: telegramCommons.chatIdProp(),
|
|
21
|
+
},
|
|
22
|
+
async run(ctx) {
|
|
23
|
+
try {
|
|
24
|
+
const response = await httpClient.sendRequest<never>({
|
|
25
|
+
method: HttpMethod.POST,
|
|
26
|
+
url: telegramCommons.getApiUrl(ctx.auth, 'getChatMemberCount'),
|
|
27
|
+
body: {
|
|
28
|
+
chat_id: ctx.propsValue.chat_id,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
return response.body;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return (error as HttpError).errorMessage().response.body;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { httpClient, HttpError, HttpMethod } from '@agnocon/pieces-common';
|
|
2
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
3
|
+
import { telegramBotAuth } from '../..';
|
|
4
|
+
import { telegramCommons } from '../common';
|
|
5
|
+
import { telegramGetChatMemberActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const telegramGetChatMember = createAction({
|
|
8
|
+
auth: telegramBotAuth,
|
|
9
|
+
name: 'telegram_get_chat_member',
|
|
10
|
+
displayName: 'Get Chat Member',
|
|
11
|
+
description: 'Get membership info for a user in a Telegram chat.',
|
|
12
|
+
audience: 'ai',
|
|
13
|
+
aiMetadata: {
|
|
14
|
+
description:
|
|
15
|
+
"Looks up one user's membership in a chat by chat_id (a numeric id or @channelusername) and user_id, returning their status (member, administrator, creator, restricted, left, kicked) and permissions. Use to check whether a user belongs to a chat or what rights they hold before acting; to list all admins use telegram_get_chat_administrators. Read-only.",
|
|
16
|
+
idempotent: true,
|
|
17
|
+
},
|
|
18
|
+
outputSchema: telegramGetChatMemberActionOutputSchema,
|
|
19
|
+
props: {
|
|
20
|
+
chat_id: telegramCommons.chatIdProp(),
|
|
21
|
+
user_id: Property.ShortText({
|
|
22
|
+
displayName: 'User Id',
|
|
23
|
+
description: 'Unique identifier for the user (e.g. from the New Message trigger payload).',
|
|
24
|
+
required: true,
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
async run(ctx) {
|
|
28
|
+
try {
|
|
29
|
+
const response = await httpClient.sendRequest<never>({
|
|
30
|
+
method: HttpMethod.POST,
|
|
31
|
+
url: telegramCommons.getApiUrl(ctx.auth, 'getChatMember'),
|
|
32
|
+
headers: {},
|
|
33
|
+
body: {
|
|
34
|
+
chat_id: ctx.propsValue.chat_id,
|
|
35
|
+
user_id: ctx.propsValue.user_id,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
return response.body;
|
|
39
|
+
} catch (error) {
|
|
40
|
+
return (error as HttpError).errorMessage().response.body;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { HttpError, HttpMethod, httpClient } from '@agnocon/pieces-common';
|
|
2
|
+
import { createAction } from '@agnocon/pieces-framework';
|
|
3
|
+
import { telegramCommons } from '../common';
|
|
4
|
+
import { telegramBotAuth } from '../..';
|
|
5
|
+
import { telegramGetChatActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const telegramGetChat = createAction({
|
|
8
|
+
auth: telegramBotAuth,
|
|
9
|
+
name: 'telegram_get_chat',
|
|
10
|
+
displayName: 'Get Chat',
|
|
11
|
+
description: 'Get up-to-date information about a Telegram chat.',
|
|
12
|
+
audience: 'ai',
|
|
13
|
+
aiMetadata: {
|
|
14
|
+
description:
|
|
15
|
+
'Looks up current details about a chat (title, description, type, photo, member count) by chat_id (a numeric id or @channelusername). Use to resolve or inspect a chat before acting on it, or to confirm the bot can reach it; the bot must be a member of or have access to the chat. Read-only and safe to retry.',
|
|
16
|
+
idempotent: true,
|
|
17
|
+
},
|
|
18
|
+
outputSchema: telegramGetChatActionOutputSchema,
|
|
19
|
+
props: {
|
|
20
|
+
chat_id: telegramCommons.chatIdProp(),
|
|
21
|
+
},
|
|
22
|
+
async run(ctx) {
|
|
23
|
+
try {
|
|
24
|
+
const response = await httpClient.sendRequest<never>({
|
|
25
|
+
method: HttpMethod.POST,
|
|
26
|
+
url: telegramCommons.getApiUrl(ctx.auth, 'getChat'),
|
|
27
|
+
body: {
|
|
28
|
+
chat_id: ctx.propsValue.chat_id,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
return response.body;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return (error as HttpError).errorMessage().response.body;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
2
|
+
import { HttpMethod, httpClient } from '@agnocon/pieces-common';
|
|
3
|
+
import { telegramCommons } from '../common';
|
|
4
|
+
import { telegramBotAuth } from '../..';
|
|
5
|
+
import { telegramGetFileActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
type TelegramFileInfo = {
|
|
8
|
+
file_id: string;
|
|
9
|
+
file_unique_id: string;
|
|
10
|
+
file_size?: number;
|
|
11
|
+
file_path?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type TelegramGetFileResponse = {
|
|
15
|
+
ok: boolean;
|
|
16
|
+
result: TelegramFileInfo;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const telegramGetFile = createAction({
|
|
20
|
+
auth: telegramBotAuth,
|
|
21
|
+
name: 'telegram_get_file',
|
|
22
|
+
displayName: 'Get File',
|
|
23
|
+
description: 'Resolve a Telegram file_id to its metadata and download URL.',
|
|
24
|
+
audience: 'ai',
|
|
25
|
+
aiMetadata: {
|
|
26
|
+
description:
|
|
27
|
+
'Resolves a Telegram file_id (from a message the bot received) to its file metadata and download URL, and optionally downloads the content as base64 when download is enabled. Use to retrieve a file attached to an incoming message; the download URL Telegram returns is time-limited. Read-only and safe to retry.',
|
|
28
|
+
idempotent: true,
|
|
29
|
+
},
|
|
30
|
+
outputSchema: telegramGetFileActionOutputSchema,
|
|
31
|
+
props: {
|
|
32
|
+
file_id: Property.ShortText({
|
|
33
|
+
displayName: 'File ID',
|
|
34
|
+
description: 'File identifier to get information about (from a received message).',
|
|
35
|
+
required: true,
|
|
36
|
+
}),
|
|
37
|
+
download: Property.Checkbox({
|
|
38
|
+
displayName: 'Download File',
|
|
39
|
+
description: 'If enabled, the file is downloaded and returned as base64.',
|
|
40
|
+
required: false,
|
|
41
|
+
defaultValue: false,
|
|
42
|
+
}),
|
|
43
|
+
},
|
|
44
|
+
async run(ctx) {
|
|
45
|
+
const fileInfoResponse = await httpClient.sendRequest<TelegramGetFileResponse>({
|
|
46
|
+
method: HttpMethod.POST,
|
|
47
|
+
url: telegramCommons.getApiUrl(ctx.auth, 'getFile'),
|
|
48
|
+
body: {
|
|
49
|
+
file_id: ctx.propsValue.file_id,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
if (!fileInfoResponse.body.ok) {
|
|
54
|
+
throw new Error(`Failed to get file info: ${JSON.stringify(fileInfoResponse.body)}`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const fileInfo = fileInfoResponse.body.result;
|
|
58
|
+
const fileUrl = fileInfo.file_path
|
|
59
|
+
? `https://api.telegram.org/file/bot${ctx.auth.secret_text}/${fileInfo.file_path}`
|
|
60
|
+
: undefined;
|
|
61
|
+
|
|
62
|
+
if (ctx.propsValue.download && fileUrl) {
|
|
63
|
+
const fileResponse = await httpClient.sendRequest<Buffer>({
|
|
64
|
+
method: HttpMethod.GET,
|
|
65
|
+
url: fileUrl,
|
|
66
|
+
responseType: 'arraybuffer',
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const base64Content = Buffer.from(fileResponse.body).toString('base64');
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
file_info: fileInfo,
|
|
73
|
+
file_url: fileUrl,
|
|
74
|
+
file_content_base64: base64Content,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
file_info: fileInfo,
|
|
80
|
+
file_url: fileUrl,
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
2
|
+
import { HttpMethod, httpClient } from '@agnocon/pieces-common';
|
|
3
|
+
import { telegramCommons } from '../common';
|
|
4
|
+
import { telegramBotAuth } from '../..';
|
|
5
|
+
import { telegramPinMessageActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const telegramPinMessage = createAction({
|
|
8
|
+
auth: telegramBotAuth,
|
|
9
|
+
name: 'telegram_pin_message',
|
|
10
|
+
displayName: 'Pin Message',
|
|
11
|
+
description: 'Pin a message in a Telegram chat.',
|
|
12
|
+
audience: 'ai',
|
|
13
|
+
aiMetadata: {
|
|
14
|
+
description:
|
|
15
|
+
'Pins an existing message in a chat, targeted by chat_id (a numeric id or @channelusername the bot can reach) and message_id (from a prior send action or the New Message trigger); the bot must be an administrator with pin rights. Use to highlight an announcement or important message; to remove the pin use telegram_unpin_message. Idempotent: pinning an already-pinned message leaves it pinned.',
|
|
16
|
+
idempotent: true,
|
|
17
|
+
},
|
|
18
|
+
outputSchema: telegramPinMessageActionOutputSchema,
|
|
19
|
+
props: {
|
|
20
|
+
chat_id: telegramCommons.chatIdProp(),
|
|
21
|
+
message_id: Property.ShortText({
|
|
22
|
+
displayName: 'Message Id',
|
|
23
|
+
description: 'Identifier of the message to pin.',
|
|
24
|
+
required: true,
|
|
25
|
+
}),
|
|
26
|
+
disable_notification: Property.Checkbox({
|
|
27
|
+
displayName: 'Disable Notification',
|
|
28
|
+
description:
|
|
29
|
+
'Pass True if it is not necessary to send a notification to all chat members.',
|
|
30
|
+
required: false,
|
|
31
|
+
defaultValue: false,
|
|
32
|
+
}),
|
|
33
|
+
},
|
|
34
|
+
async run(ctx) {
|
|
35
|
+
return await httpClient.sendRequest<never>({
|
|
36
|
+
method: HttpMethod.POST,
|
|
37
|
+
url: telegramCommons.getApiUrl(ctx.auth, 'pinChatMessage'),
|
|
38
|
+
body: {
|
|
39
|
+
chat_id: ctx.propsValue.chat_id,
|
|
40
|
+
message_id: ctx.propsValue.message_id,
|
|
41
|
+
disable_notification: ctx.propsValue.disable_notification ?? false,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
});
|