@aracna/telegram-bot 1.9.13 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apis/telegram-api.d.ts +9 -0
- package/apis/telegram-api.js +55 -0
- package/apis/telegram-file-api.d.ts +7 -0
- package/apis/telegram-file-api.js +14 -0
- package/classes/client.d.ts +46 -0
- package/classes/client.js +409 -0
- package/definitions/constants.d.ts +10 -0
- package/definitions/constants.js +53 -1
- package/definitions/enums.d.ts +1 -20
- package/definitions/enums.js +2 -22
- package/definitions/interfaces.d.ts +91 -75
- package/definitions/interfaces.js +0 -1
- package/definitions/telegram-api-definitions.d.ts +12 -0
- package/definitions/telegram-api-definitions.js +2 -0
- package/definitions/types.d.ts +4 -3
- package/index.d.ts +656 -416
- package/index.js +236 -20
- package/loggers/class-logger.d.ts +2 -0
- package/loggers/{module.logger.js → class-logger.js} +2 -2
- package/package.json +13 -4
- package/requests/add-requests.d.ts +3 -0
- package/requests/add-requests.js +14 -0
- package/requests/answer-requests.d.ts +7 -0
- package/requests/answer-requests.js +23 -0
- package/requests/approve-requests.d.ts +3 -0
- package/requests/approve-requests.js +7 -0
- package/requests/ban-requests.d.ts +4 -0
- package/requests/ban-requests.js +11 -0
- package/requests/close-requests.d.ts +4 -0
- package/requests/close-requests.js +11 -0
- package/requests/copy-requests.d.ts +4 -0
- package/requests/copy-requests.js +11 -0
- package/requests/create-requests.d.ts +7 -0
- package/requests/create-requests.js +30 -0
- package/requests/decline-requests.d.ts +3 -0
- package/requests/decline-requests.js +7 -0
- package/requests/delete-requests.d.ts +10 -0
- package/requests/delete-requests.js +35 -0
- package/requests/download-requests.d.ts +3 -0
- package/requests/download-requests.js +29 -0
- package/requests/edit-requests.d.ts +12 -0
- package/requests/edit-requests.js +46 -0
- package/requests/export-requests.d.ts +3 -0
- package/requests/export-requests.js +7 -0
- package/requests/forward-requests.d.ts +4 -0
- package/requests/forward-requests.js +11 -0
- package/requests/get-requests.d.ts +23 -0
- package/requests/get-requests.js +92 -0
- package/requests/hide-requests.d.ts +3 -0
- package/requests/hide-requests.js +7 -0
- package/requests/leave-requests.d.ts +3 -0
- package/requests/leave-requests.js +7 -0
- package/requests/log-requests.d.ts +2 -0
- package/requests/log-requests.js +7 -0
- package/requests/pin-requests.d.ts +3 -0
- package/requests/pin-requests.js +7 -0
- package/requests/promote-requests.d.ts +3 -0
- package/requests/promote-requests.js +7 -0
- package/requests/refund-requests.d.ts +3 -0
- package/requests/refund-requests.js +7 -0
- package/requests/reopen-requests.d.ts +4 -0
- package/requests/reopen-requests.js +11 -0
- package/requests/replace-requests.d.ts +3 -0
- package/requests/replace-requests.js +14 -0
- package/requests/restrict-requests.d.ts +3 -0
- package/requests/restrict-requests.js +7 -0
- package/requests/revoke-requests.d.ts +3 -0
- package/requests/revoke-requests.js +7 -0
- package/requests/send-requests.d.ts +24 -0
- package/requests/send-requests.js +102 -0
- package/requests/set-requests.d.ts +24 -0
- package/requests/set-requests.js +95 -0
- package/requests/stop-requests.d.ts +4 -0
- package/requests/stop-requests.js +11 -0
- package/requests/unban-requests.d.ts +4 -0
- package/requests/unban-requests.js +11 -0
- package/requests/unhide-requests.d.ts +3 -0
- package/requests/unhide-requests.js +7 -0
- package/requests/unpin-requests.d.ts +6 -0
- package/requests/unpin-requests.js +19 -0
- package/requests/upload-requests.d.ts +3 -0
- package/requests/upload-requests.js +7 -0
- package/requests/webhook-requests.d.ts +6 -0
- package/requests/webhook-requests.js +20 -0
- package/utils/callback-query-utils.d.ts +3 -0
- package/utils/callback-query-utils.js +25 -0
- package/utils/command-utils.d.ts +5 -0
- package/utils/command-utils.js +28 -0
- package/utils/context-utils.d.ts +11 -0
- package/utils/context-utils.js +42 -0
- package/utils/html-utils.d.ts +2 -0
- package/utils/html-utils.js +18 -0
- package/utils/inline-keyboard-utils.d.ts +12 -0
- package/utils/inline-keyboard-utils.js +43 -0
- package/utils/reply-to-message-utils.d.ts +6 -0
- package/utils/reply-to-message-utils.js +36 -0
- package/utils/start-message-utils.d.ts +6 -0
- package/utils/start-message-utils.js +40 -0
- package/builders/button.builder.d.ts +0 -11
- package/builders/button.builder.js +0 -31
- package/childs/add.d.ts +0 -6
- package/childs/add.js +0 -10
- package/childs/answer.d.ts +0 -9
- package/childs/answer.js +0 -19
- package/childs/ban.d.ts +0 -6
- package/childs/ban.js +0 -10
- package/childs/create.d.ts +0 -6
- package/childs/create.js +0 -17
- package/childs/delete.d.ts +0 -8
- package/childs/delete.js +0 -19
- package/childs/download.d.ts +0 -8
- package/childs/download.js +0 -32
- package/childs/edit.d.ts +0 -10
- package/childs/edit.js +0 -22
- package/childs/export.d.ts +0 -5
- package/childs/export.js +0 -10
- package/childs/forward.d.ts +0 -6
- package/childs/forward.js +0 -15
- package/childs/get.d.ts +0 -15
- package/childs/get.js +0 -37
- package/childs/leave.d.ts +0 -5
- package/childs/leave.js +0 -10
- package/childs/pin.d.ts +0 -6
- package/childs/pin.js +0 -10
- package/childs/polling.d.ts +0 -9
- package/childs/polling.js +0 -34
- package/childs/privates/send.private.d.ts +0 -7
- package/childs/privates/send.private.js +0 -19
- package/childs/promote.d.ts +0 -6
- package/childs/promote.js +0 -10
- package/childs/restrict.d.ts +0 -6
- package/childs/restrict.js +0 -15
- package/childs/send.d.ts +0 -31
- package/childs/send.js +0 -130
- package/childs/set.d.ts +0 -17
- package/childs/set.js +0 -44
- package/childs/stop.d.ts +0 -7
- package/childs/stop.js +0 -13
- package/childs/unban.d.ts +0 -5
- package/childs/unban.js +0 -10
- package/childs/unpin.d.ts +0 -5
- package/childs/unpin.js +0 -10
- package/childs/upload.d.ts +0 -7
- package/childs/upload.js +0 -10
- package/childs/webhook.d.ts +0 -8
- package/childs/webhook.js +0 -22
- package/loggers/module.logger.d.ts +0 -2
- package/modules/api.d.ts +0 -5
- package/modules/api.js +0 -24
- package/modules/builder.d.ts +0 -4
- package/modules/builder.js +0 -8
- package/modules/child.d.ts +0 -5
- package/modules/child.js +0 -10
- package/modules/configuration.d.ts +0 -8
- package/modules/configuration.js +0 -10
- package/modules/dummy.d.ts +0 -9
- package/modules/dummy.js +0 -56
- package/modules/telegram.d.ts +0 -87
- package/modules/telegram.js +0 -358
- package/utils/callback.query.utils.d.ts +0 -5
- package/utils/callback.query.utils.js +0 -26
- package/utils/command.utils.d.ts +0 -7
- package/utils/command.utils.js +0 -29
- package/utils/context.utils.d.ts +0 -13
- package/utils/context.utils.js +0 -41
- package/utils/html.utils.d.ts +0 -5
- package/utils/html.utils.js +0 -20
- package/utils/inline.keyboard.utils.d.ts +0 -4
- package/utils/inline.keyboard.utils.js +0 -26
- package/utils/reply.to.message.utils.d.ts +0 -6
- package/utils/reply.to.message.utils.js +0 -27
- package/utils/start.utils.d.ts +0 -7
- package/utils/start.utils.js +0 -32
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.downloadFile = downloadFile;
|
|
4
|
+
exports.downloadUserFirstProfilePhoto = downloadUserFirstProfilePhoto;
|
|
5
|
+
const telegram_file_api_1 = require("../apis/telegram-file-api");
|
|
6
|
+
const get_requests_1 = require("./get-requests");
|
|
7
|
+
async function downloadFile(token, fileID) {
|
|
8
|
+
let file, blob;
|
|
9
|
+
file = await (0, get_requests_1.getFile)(token, { file_id: fileID });
|
|
10
|
+
if (file instanceof Error)
|
|
11
|
+
return file;
|
|
12
|
+
blob = await telegram_file_api_1.TelegramFileAPI.get(file.file_path ?? '', { token });
|
|
13
|
+
if (blob instanceof Error)
|
|
14
|
+
return blob;
|
|
15
|
+
return blob;
|
|
16
|
+
}
|
|
17
|
+
async function downloadUserFirstProfilePhoto(token, userID) {
|
|
18
|
+
let photos, sizes, blob;
|
|
19
|
+
photos = await (0, get_requests_1.getUserProfilePhotos)(token, { limit: 1, user_id: userID });
|
|
20
|
+
if (photos instanceof Error)
|
|
21
|
+
return photos;
|
|
22
|
+
sizes = photos.photos;
|
|
23
|
+
if (sizes.length <= 0)
|
|
24
|
+
return new Error(JSON.stringify(photos));
|
|
25
|
+
blob = await downloadFile(token, sizes[0].reduce((r, v) => (v.height + v.width > r.height + r.width ? v : r), sizes[0][0]).file_id);
|
|
26
|
+
if (blob instanceof Error)
|
|
27
|
+
return blob;
|
|
28
|
+
return blob;
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FetchError } from '@aracna/core';
|
|
2
|
+
import type { ChatInviteLink, EditChatInviteLink, EditChatSubscriptionInviteLink, EditForumTopic, EditGeneralForumTopic, EditMessageCaption, EditMessageLiveLocation, EditMessageReplyMarkup, EditMessageText, Message } from '@aracna/telegram-bot-types';
|
|
3
|
+
import { EditMessageMediaAlternative } from '../definitions/interfaces';
|
|
4
|
+
export declare function editChatInviteLink(token: string, body: EditChatInviteLink): Promise<ChatInviteLink | FetchError>;
|
|
5
|
+
export declare function editChatSubscriptionInviteLink(token: string, body: EditChatSubscriptionInviteLink): Promise<ChatInviteLink | FetchError>;
|
|
6
|
+
export declare function editForumTopic(token: string, body: EditForumTopic): Promise<boolean | FetchError>;
|
|
7
|
+
export declare function editGeneralForumTopic(token: string, body: EditGeneralForumTopic): Promise<boolean | FetchError>;
|
|
8
|
+
export declare function editMessageCaption(token: string, body: EditMessageCaption): Promise<Message | FetchError>;
|
|
9
|
+
export declare function editMessageLiveLocation(token: string, body: EditMessageLiveLocation): Promise<Message | FetchError>;
|
|
10
|
+
export declare function editMessageMedia(token: string, body: EditMessageMediaAlternative): Promise<Message | FetchError>;
|
|
11
|
+
export declare function editMessageReplyMarkup(token: string, body: EditMessageReplyMarkup): Promise<Message | FetchError>;
|
|
12
|
+
export declare function editMessageText(token: string, body: EditMessageText): Promise<Message | FetchError>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.editChatInviteLink = editChatInviteLink;
|
|
4
|
+
exports.editChatSubscriptionInviteLink = editChatSubscriptionInviteLink;
|
|
5
|
+
exports.editForumTopic = editForumTopic;
|
|
6
|
+
exports.editGeneralForumTopic = editGeneralForumTopic;
|
|
7
|
+
exports.editMessageCaption = editMessageCaption;
|
|
8
|
+
exports.editMessageLiveLocation = editMessageLiveLocation;
|
|
9
|
+
exports.editMessageMedia = editMessageMedia;
|
|
10
|
+
exports.editMessageReplyMarkup = editMessageReplyMarkup;
|
|
11
|
+
exports.editMessageText = editMessageText;
|
|
12
|
+
const telegram_api_1 = require("../apis/telegram-api");
|
|
13
|
+
async function editChatInviteLink(token, body) {
|
|
14
|
+
return telegram_api_1.TelegramAPI.post('editChatInviteLink', body, { token });
|
|
15
|
+
}
|
|
16
|
+
async function editChatSubscriptionInviteLink(token, body) {
|
|
17
|
+
return telegram_api_1.TelegramAPI.post('editChatSubscriptionInviteLink', body, { token });
|
|
18
|
+
}
|
|
19
|
+
async function editForumTopic(token, body) {
|
|
20
|
+
return telegram_api_1.TelegramAPI.post('editForumTopic', body, { token });
|
|
21
|
+
}
|
|
22
|
+
async function editGeneralForumTopic(token, body) {
|
|
23
|
+
return telegram_api_1.TelegramAPI.post('editGeneralForumTopic', body, { token });
|
|
24
|
+
}
|
|
25
|
+
async function editMessageCaption(token, body) {
|
|
26
|
+
return telegram_api_1.TelegramAPI.post('editMessageCaption', body, { token });
|
|
27
|
+
}
|
|
28
|
+
async function editMessageLiveLocation(token, body) {
|
|
29
|
+
return telegram_api_1.TelegramAPI.post('editMessageLiveLocation', body, { token });
|
|
30
|
+
}
|
|
31
|
+
async function editMessageMedia(token, body) {
|
|
32
|
+
return telegram_api_1.TelegramAPI.post('editMessageMedia', {
|
|
33
|
+
...body,
|
|
34
|
+
media: {
|
|
35
|
+
...body.media,
|
|
36
|
+
media: body.media.media instanceof Blob ? `attach://media_blob` : body.media.media
|
|
37
|
+
},
|
|
38
|
+
...(body.media.media instanceof Blob ? { media_blob: body.media.media } : {})
|
|
39
|
+
}, { token });
|
|
40
|
+
}
|
|
41
|
+
async function editMessageReplyMarkup(token, body) {
|
|
42
|
+
return telegram_api_1.TelegramAPI.post('editMessageReplyMarkup', body, { token });
|
|
43
|
+
}
|
|
44
|
+
async function editMessageText(token, body) {
|
|
45
|
+
return telegram_api_1.TelegramAPI.post('editMessageText', body, { token });
|
|
46
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exportChatInviteLink = exportChatInviteLink;
|
|
4
|
+
const telegram_api_1 = require("../apis/telegram-api");
|
|
5
|
+
async function exportChatInviteLink(token, body) {
|
|
6
|
+
return telegram_api_1.TelegramAPI.post('exportChatInviteLink', body, { token });
|
|
7
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FetchError } from '@aracna/core';
|
|
2
|
+
import type { ForwardMessage, ForwardMessages, Message, MessageId } from '@aracna/telegram-bot-types';
|
|
3
|
+
export declare function forwardMessage(token: string, body: ForwardMessage): Promise<Message | FetchError>;
|
|
4
|
+
export declare function forwardMessages(token: string, body: ForwardMessages): Promise<MessageId[] | FetchError>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.forwardMessage = forwardMessage;
|
|
4
|
+
exports.forwardMessages = forwardMessages;
|
|
5
|
+
const telegram_api_1 = require("../apis/telegram-api");
|
|
6
|
+
async function forwardMessage(token, body) {
|
|
7
|
+
return telegram_api_1.TelegramAPI.post('forwardMessage', body, { token });
|
|
8
|
+
}
|
|
9
|
+
async function forwardMessages(token, body) {
|
|
10
|
+
return telegram_api_1.TelegramAPI.post('forwardMessages', body, { token });
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { FetchError } from '@aracna/core';
|
|
2
|
+
import type { BotCommand, BotDescription, BotName, BotShortDescription, BusinessConnection, Chat, ChatAdministratorRights, ChatMember, File, GameHighScore, GetBusinessConnection, GetChat, GetChatAdministrators, GetChatMember, GetChatMemberCount, GetChatMenuButton, GetCustomEmojiStickers, GetFile, GetGameHighScores, GetMyCommands, GetMyDefaultAdministratorRights, GetMyDescription, GetMyName, GetMyShortDescription, GetStarTransactions, GetStickerSet, GetUpdates, GetUserChatBoosts, GetUserProfilePhotos, MenuButton, StarTransactions, Sticker, StickerSet, Update, User, UserChatBoosts, UserProfilePhotos } from '@aracna/telegram-bot-types';
|
|
3
|
+
export declare function getBusinessConnection(token: string, body: GetBusinessConnection): Promise<BusinessConnection | FetchError>;
|
|
4
|
+
export declare function getChat(token: string, body: GetChat): Promise<Chat | FetchError>;
|
|
5
|
+
export declare function getChatAdministrators(token: string, body: GetChatAdministrators): Promise<ChatMember[] | FetchError>;
|
|
6
|
+
export declare function getChatMember(token: string, body: GetChatMember): Promise<ChatMember | FetchError>;
|
|
7
|
+
export declare function getChatMemberCount(token: string, body: GetChatMemberCount): Promise<number | FetchError>;
|
|
8
|
+
export declare function getChatMenuButton(token: string, body: GetChatMenuButton): Promise<MenuButton | FetchError>;
|
|
9
|
+
export declare function getCustomEmojiStickers(token: string, body: GetCustomEmojiStickers): Promise<Sticker[] | FetchError>;
|
|
10
|
+
export declare function getFile(token: string, body: GetFile): Promise<File | FetchError>;
|
|
11
|
+
export declare function getForumTopicIconStickers(token: string): Promise<Sticker[] | FetchError>;
|
|
12
|
+
export declare function getGameHighScores(token: string, body: GetGameHighScores): Promise<GameHighScore[] | FetchError>;
|
|
13
|
+
export declare function getMe(token: string): Promise<User | FetchError>;
|
|
14
|
+
export declare function getMyCommands(token: string, body?: GetMyCommands): Promise<BotCommand[] | FetchError>;
|
|
15
|
+
export declare function getMyDefaultAdministratorRights(token: string, body?: GetMyDefaultAdministratorRights): Promise<ChatAdministratorRights | FetchError>;
|
|
16
|
+
export declare function getMyDescription(token: string, body?: GetMyDescription): Promise<BotDescription | FetchError>;
|
|
17
|
+
export declare function getMyName(token: string, body?: GetMyName): Promise<BotName | FetchError>;
|
|
18
|
+
export declare function getMyShortDescription(token: string, body?: GetMyShortDescription): Promise<BotShortDescription | FetchError>;
|
|
19
|
+
export declare function getStarTransactions(token: string, body?: GetStarTransactions): Promise<StarTransactions | FetchError>;
|
|
20
|
+
export declare function getStickerSet(token: string, body: GetStickerSet): Promise<StickerSet | FetchError>;
|
|
21
|
+
export declare function getUpdates(token: string, body?: GetUpdates): Promise<Update[] | FetchError>;
|
|
22
|
+
export declare function getUserChatBoosts(token: string, body: GetUserChatBoosts): Promise<UserChatBoosts | FetchError>;
|
|
23
|
+
export declare function getUserProfilePhotos(token: string, body: GetUserProfilePhotos): Promise<UserProfilePhotos | FetchError>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBusinessConnection = getBusinessConnection;
|
|
4
|
+
exports.getChat = getChat;
|
|
5
|
+
exports.getChatAdministrators = getChatAdministrators;
|
|
6
|
+
exports.getChatMember = getChatMember;
|
|
7
|
+
exports.getChatMemberCount = getChatMemberCount;
|
|
8
|
+
exports.getChatMenuButton = getChatMenuButton;
|
|
9
|
+
exports.getCustomEmojiStickers = getCustomEmojiStickers;
|
|
10
|
+
exports.getFile = getFile;
|
|
11
|
+
exports.getForumTopicIconStickers = getForumTopicIconStickers;
|
|
12
|
+
exports.getGameHighScores = getGameHighScores;
|
|
13
|
+
exports.getMe = getMe;
|
|
14
|
+
exports.getMyCommands = getMyCommands;
|
|
15
|
+
exports.getMyDefaultAdministratorRights = getMyDefaultAdministratorRights;
|
|
16
|
+
exports.getMyDescription = getMyDescription;
|
|
17
|
+
exports.getMyName = getMyName;
|
|
18
|
+
exports.getMyShortDescription = getMyShortDescription;
|
|
19
|
+
exports.getStarTransactions = getStarTransactions;
|
|
20
|
+
exports.getStickerSet = getStickerSet;
|
|
21
|
+
exports.getUpdates = getUpdates;
|
|
22
|
+
exports.getUserChatBoosts = getUserChatBoosts;
|
|
23
|
+
exports.getUserProfilePhotos = getUserProfilePhotos;
|
|
24
|
+
const telegram_api_1 = require("../apis/telegram-api");
|
|
25
|
+
const constants_1 = require("../definitions/constants");
|
|
26
|
+
async function getBusinessConnection(token, body) {
|
|
27
|
+
return telegram_api_1.TelegramAPI.post('getBusinessConnection', body, { token });
|
|
28
|
+
}
|
|
29
|
+
async function getChat(token, body) {
|
|
30
|
+
return telegram_api_1.TelegramAPI.post('getChat', body, { token });
|
|
31
|
+
}
|
|
32
|
+
async function getChatAdministrators(token, body) {
|
|
33
|
+
return telegram_api_1.TelegramAPI.post('getChatAdministrators', body, { token });
|
|
34
|
+
}
|
|
35
|
+
async function getChatMember(token, body) {
|
|
36
|
+
return telegram_api_1.TelegramAPI.post('getChatMember', body, { token });
|
|
37
|
+
}
|
|
38
|
+
async function getChatMemberCount(token, body) {
|
|
39
|
+
return telegram_api_1.TelegramAPI.post('getChatMemberCount', body, { token });
|
|
40
|
+
}
|
|
41
|
+
async function getChatMenuButton(token, body) {
|
|
42
|
+
return telegram_api_1.TelegramAPI.post('getChatMenuButton', body, { token });
|
|
43
|
+
}
|
|
44
|
+
async function getCustomEmojiStickers(token, body) {
|
|
45
|
+
return telegram_api_1.TelegramAPI.post('getCustomEmojiStickers', body, { token });
|
|
46
|
+
}
|
|
47
|
+
async function getFile(token, body) {
|
|
48
|
+
return telegram_api_1.TelegramAPI.post('getFile', body, { token });
|
|
49
|
+
}
|
|
50
|
+
async function getForumTopicIconStickers(token) {
|
|
51
|
+
return telegram_api_1.TelegramAPI.post('getForumTopicIconStickers', undefined, { token });
|
|
52
|
+
}
|
|
53
|
+
async function getGameHighScores(token, body) {
|
|
54
|
+
return telegram_api_1.TelegramAPI.post('getGameHighScores', body, { token });
|
|
55
|
+
}
|
|
56
|
+
async function getMe(token) {
|
|
57
|
+
return telegram_api_1.TelegramAPI.post('getMe', undefined, { token });
|
|
58
|
+
}
|
|
59
|
+
async function getMyCommands(token, body) {
|
|
60
|
+
return telegram_api_1.TelegramAPI.post('getMyCommands', body, { token });
|
|
61
|
+
}
|
|
62
|
+
async function getMyDefaultAdministratorRights(token, body) {
|
|
63
|
+
return telegram_api_1.TelegramAPI.post('getMyDefaultAdministratorRights', body, { token });
|
|
64
|
+
}
|
|
65
|
+
async function getMyDescription(token, body) {
|
|
66
|
+
return telegram_api_1.TelegramAPI.post('getMyDescription', body, { token });
|
|
67
|
+
}
|
|
68
|
+
async function getMyName(token, body) {
|
|
69
|
+
return telegram_api_1.TelegramAPI.post('getMyName', body, { token });
|
|
70
|
+
}
|
|
71
|
+
async function getMyShortDescription(token, body) {
|
|
72
|
+
return telegram_api_1.TelegramAPI.post('getMyShortDescription', body, { token });
|
|
73
|
+
}
|
|
74
|
+
async function getStarTransactions(token, body) {
|
|
75
|
+
return telegram_api_1.TelegramAPI.post('getStarTransactions', body, { token });
|
|
76
|
+
}
|
|
77
|
+
async function getStickerSet(token, body) {
|
|
78
|
+
return telegram_api_1.TelegramAPI.post('getStickerSet', body, { token });
|
|
79
|
+
}
|
|
80
|
+
async function getUpdates(token, body) {
|
|
81
|
+
let updates;
|
|
82
|
+
updates = await telegram_api_1.TelegramAPI.post('getUpdates', { allowed_updates: constants_1.DEFAULT_ALLOWED_UPDATES, ...body }, { token });
|
|
83
|
+
if (updates instanceof Error)
|
|
84
|
+
return updates;
|
|
85
|
+
return Array.isArray(updates) ? updates : [updates];
|
|
86
|
+
}
|
|
87
|
+
async function getUserChatBoosts(token, body) {
|
|
88
|
+
return telegram_api_1.TelegramAPI.post('getUserChatBoosts', body, { token });
|
|
89
|
+
}
|
|
90
|
+
async function getUserProfilePhotos(token, body) {
|
|
91
|
+
return telegram_api_1.TelegramAPI.post('getUserProfilePhotos', body, { token });
|
|
92
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hideGeneralForumTopic = hideGeneralForumTopic;
|
|
4
|
+
const telegram_api_1 = require("../apis/telegram-api");
|
|
5
|
+
async function hideGeneralForumTopic(token, body) {
|
|
6
|
+
return telegram_api_1.TelegramAPI.post('hideGeneralForumTopic', body, { token });
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.leaveChat = leaveChat;
|
|
4
|
+
const telegram_api_1 = require("../apis/telegram-api");
|
|
5
|
+
async function leaveChat(token, body) {
|
|
6
|
+
return telegram_api_1.TelegramAPI.post('leaveChat', body, { token });
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logOut = logOut;
|
|
4
|
+
const telegram_api_1 = require("../apis/telegram-api");
|
|
5
|
+
async function logOut(token) {
|
|
6
|
+
return telegram_api_1.TelegramAPI.post('logOut', undefined, { token });
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pinChatMessage = pinChatMessage;
|
|
4
|
+
const telegram_api_1 = require("../apis/telegram-api");
|
|
5
|
+
async function pinChatMessage(token, body) {
|
|
6
|
+
return telegram_api_1.TelegramAPI.post('pinChatMessage', body, { token });
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.promoteChatMember = promoteChatMember;
|
|
4
|
+
const telegram_api_1 = require("../apis/telegram-api");
|
|
5
|
+
async function promoteChatMember(token, body) {
|
|
6
|
+
return telegram_api_1.TelegramAPI.post('promoteChatMember', body, { token });
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.refundStarPayment = refundStarPayment;
|
|
4
|
+
const telegram_api_1 = require("../apis/telegram-api");
|
|
5
|
+
async function refundStarPayment(token, body) {
|
|
6
|
+
return telegram_api_1.TelegramAPI.post('refundStarPayment', body, { token });
|
|
7
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FetchError } from '@aracna/core';
|
|
2
|
+
import type { ReopenForumTopic, ReopenGeneralForumTopic } from '@aracna/telegram-bot-types';
|
|
3
|
+
export declare function reopenForumTopic(token: string, body: ReopenForumTopic): Promise<boolean | FetchError>;
|
|
4
|
+
export declare function reopenGeneralForumTopic(token: string, body: ReopenGeneralForumTopic): Promise<boolean | FetchError>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reopenForumTopic = reopenForumTopic;
|
|
4
|
+
exports.reopenGeneralForumTopic = reopenGeneralForumTopic;
|
|
5
|
+
const telegram_api_1 = require("../apis/telegram-api");
|
|
6
|
+
async function reopenForumTopic(token, body) {
|
|
7
|
+
return telegram_api_1.TelegramAPI.post('reopenForumTopic', body, { token });
|
|
8
|
+
}
|
|
9
|
+
async function reopenGeneralForumTopic(token, body) {
|
|
10
|
+
return telegram_api_1.TelegramAPI.post('reopenGeneralForumTopic', body, { token });
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.replaceStickerInSet = replaceStickerInSet;
|
|
4
|
+
const telegram_api_1 = require("../apis/telegram-api");
|
|
5
|
+
async function replaceStickerInSet(token, body) {
|
|
6
|
+
return telegram_api_1.TelegramAPI.post('replaceStickerInSet', {
|
|
7
|
+
...body,
|
|
8
|
+
sticker: {
|
|
9
|
+
...body.sticker,
|
|
10
|
+
sticker: body.sticker.sticker instanceof Blob ? `attach://sticker_blob` : body.sticker.sticker
|
|
11
|
+
},
|
|
12
|
+
...(body.sticker.sticker instanceof Blob && { sticker_blob: body.sticker.sticker })
|
|
13
|
+
}, { token });
|
|
14
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.restrictChatMember = restrictChatMember;
|
|
4
|
+
const telegram_api_1 = require("../apis/telegram-api");
|
|
5
|
+
async function restrictChatMember(token, body) {
|
|
6
|
+
return telegram_api_1.TelegramAPI.post('restrictChatMember', body, { token });
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.revokeChatInviteLink = revokeChatInviteLink;
|
|
4
|
+
const telegram_api_1 = require("../apis/telegram-api");
|
|
5
|
+
async function revokeChatInviteLink(token, body) {
|
|
6
|
+
return telegram_api_1.TelegramAPI.post('revokeChatInviteLink', body, { token });
|
|
7
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type FetchError } from '@aracna/core';
|
|
2
|
+
import type { Message, SendAnimation, SendAudio, SendChatAction, SendContact, SendDice, SendDocument, SendGame, SendInvoice, SendLocation, SendMessage, SendPhoto, SendPoll, SendSticker, SendVenue, SendVideo, SendVideoNote, SendVoice } from '@aracna/telegram-bot-types';
|
|
3
|
+
import type { SendMediaGroupAlternative, SendPaidMediaAlternative, SendRepliableMessage } from '../definitions/interfaces';
|
|
4
|
+
export declare function sendAnimation(token: string, body: SendAnimation): Promise<Message | FetchError>;
|
|
5
|
+
export declare function sendAudio(token: string, body: SendAudio): Promise<Message | FetchError>;
|
|
6
|
+
export declare function sendDocument(token: string, body: SendDocument): Promise<Message | FetchError>;
|
|
7
|
+
export declare function sendChatAction(token: string, body: SendChatAction): Promise<boolean | FetchError>;
|
|
8
|
+
export declare function sendContact(token: string, body: SendContact): Promise<Message | FetchError>;
|
|
9
|
+
export declare function sendDice(token: string, body: SendDice): Promise<Message | FetchError>;
|
|
10
|
+
export declare function sendGame(token: string, body: SendGame): Promise<Message | FetchError>;
|
|
11
|
+
export declare function sendInvoice(token: string, body: SendInvoice): Promise<Message | FetchError>;
|
|
12
|
+
export declare function sendLocation(token: string, body: SendLocation): Promise<Message | FetchError>;
|
|
13
|
+
export declare function sendMediaGroup(token: string, body: SendMediaGroupAlternative): Promise<Message[] | FetchError>;
|
|
14
|
+
export declare function sendMessage(token: string, body: SendMessage): Promise<Message | FetchError>;
|
|
15
|
+
export declare function sendMessageHTML(token: string, body: SendMessage): Promise<Message | FetchError>;
|
|
16
|
+
export declare function sendPaidMedia(token: string, body: SendPaidMediaAlternative): Promise<Message | FetchError>;
|
|
17
|
+
export declare function sendPhoto(token: string, body: SendPhoto): Promise<Message | FetchError>;
|
|
18
|
+
export declare function sendPoll(token: string, body: SendPoll): Promise<Message | FetchError>;
|
|
19
|
+
export declare function sendRepliableMessage<T>(token: string, body: SendRepliableMessage<T>): Promise<Message | FetchError>;
|
|
20
|
+
export declare function sendSticker(token: string, body: SendSticker): Promise<Message | FetchError>;
|
|
21
|
+
export declare function sendVenue(token: string, body: SendVenue): Promise<Message | FetchError>;
|
|
22
|
+
export declare function sendVideo(token: string, body: SendVideo): Promise<Message | FetchError>;
|
|
23
|
+
export declare function sendVideoNote(token: string, body: SendVideoNote): Promise<Message | FetchError>;
|
|
24
|
+
export declare function sendVoice(token: string, body: SendVoice): Promise<Message | FetchError>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendAnimation = sendAnimation;
|
|
4
|
+
exports.sendAudio = sendAudio;
|
|
5
|
+
exports.sendDocument = sendDocument;
|
|
6
|
+
exports.sendChatAction = sendChatAction;
|
|
7
|
+
exports.sendContact = sendContact;
|
|
8
|
+
exports.sendDice = sendDice;
|
|
9
|
+
exports.sendGame = sendGame;
|
|
10
|
+
exports.sendInvoice = sendInvoice;
|
|
11
|
+
exports.sendLocation = sendLocation;
|
|
12
|
+
exports.sendMediaGroup = sendMediaGroup;
|
|
13
|
+
exports.sendMessage = sendMessage;
|
|
14
|
+
exports.sendMessageHTML = sendMessageHTML;
|
|
15
|
+
exports.sendPaidMedia = sendPaidMedia;
|
|
16
|
+
exports.sendPhoto = sendPhoto;
|
|
17
|
+
exports.sendPoll = sendPoll;
|
|
18
|
+
exports.sendRepliableMessage = sendRepliableMessage;
|
|
19
|
+
exports.sendSticker = sendSticker;
|
|
20
|
+
exports.sendVenue = sendVenue;
|
|
21
|
+
exports.sendVideo = sendVideo;
|
|
22
|
+
exports.sendVideoNote = sendVideoNote;
|
|
23
|
+
exports.sendVoice = sendVoice;
|
|
24
|
+
const telegram_api_1 = require("../apis/telegram-api");
|
|
25
|
+
const html_utils_1 = require("../utils/html-utils");
|
|
26
|
+
const reply_to_message_utils_1 = require("../utils/reply-to-message-utils");
|
|
27
|
+
async function sendAnimation(token, body) {
|
|
28
|
+
return telegram_api_1.TelegramAPI.post('sendAnimation', body, { token });
|
|
29
|
+
}
|
|
30
|
+
async function sendAudio(token, body) {
|
|
31
|
+
return telegram_api_1.TelegramAPI.post('sendAudio', body, { token });
|
|
32
|
+
}
|
|
33
|
+
async function sendDocument(token, body) {
|
|
34
|
+
return telegram_api_1.TelegramAPI.post('sendDocument', body, { token });
|
|
35
|
+
}
|
|
36
|
+
async function sendChatAction(token, body) {
|
|
37
|
+
return telegram_api_1.TelegramAPI.post('sendChatAction', body, { token });
|
|
38
|
+
}
|
|
39
|
+
async function sendContact(token, body) {
|
|
40
|
+
return telegram_api_1.TelegramAPI.post('sendContact', body, { token });
|
|
41
|
+
}
|
|
42
|
+
async function sendDice(token, body) {
|
|
43
|
+
return telegram_api_1.TelegramAPI.post('sendDice', body, { token });
|
|
44
|
+
}
|
|
45
|
+
async function sendGame(token, body) {
|
|
46
|
+
return telegram_api_1.TelegramAPI.post('sendGame', body, { token });
|
|
47
|
+
}
|
|
48
|
+
async function sendInvoice(token, body) {
|
|
49
|
+
return telegram_api_1.TelegramAPI.post('sendInvoice', body, { token });
|
|
50
|
+
}
|
|
51
|
+
async function sendLocation(token, body) {
|
|
52
|
+
return telegram_api_1.TelegramAPI.post('sendLocation', body, { token });
|
|
53
|
+
}
|
|
54
|
+
async function sendMediaGroup(token, body) {
|
|
55
|
+
return telegram_api_1.TelegramAPI.post('sendMediaGroup', {
|
|
56
|
+
...body,
|
|
57
|
+
media: body.media.map((media, index) => ({ ...media, media: `attach://media_${index}` })),
|
|
58
|
+
...body.media.reduce((result, media, index) => ({ ...result, [`media_${index}`]: media.media }), {})
|
|
59
|
+
}, { token });
|
|
60
|
+
}
|
|
61
|
+
async function sendMessage(token, body) {
|
|
62
|
+
return telegram_api_1.TelegramAPI.post('sendMessage', body, { token });
|
|
63
|
+
}
|
|
64
|
+
async function sendMessageHTML(token, body) {
|
|
65
|
+
return sendMessage(token, { parse_mode: 'HTML', ...body, text: (0, html_utils_1.sanitizeHTML)(body.text) });
|
|
66
|
+
}
|
|
67
|
+
async function sendPaidMedia(token, body) {
|
|
68
|
+
return telegram_api_1.TelegramAPI.post('sendPaidMedia', {
|
|
69
|
+
...body,
|
|
70
|
+
media: body.media.map((v, k) => ({ ...v, media: `attach://media_${k}` })),
|
|
71
|
+
...body.media.reduce((r, v, k) => ({ ...r, [`media_${k}`]: v.media }), {})
|
|
72
|
+
}, { token });
|
|
73
|
+
}
|
|
74
|
+
async function sendPhoto(token, body) {
|
|
75
|
+
return telegram_api_1.TelegramAPI.post('sendPhoto', body, { token });
|
|
76
|
+
}
|
|
77
|
+
async function sendPoll(token, body) {
|
|
78
|
+
return telegram_api_1.TelegramAPI.post('sendPoll', body, { token });
|
|
79
|
+
}
|
|
80
|
+
async function sendRepliableMessage(token, body) {
|
|
81
|
+
return sendMessage(token, {
|
|
82
|
+
parse_mode: 'HTML',
|
|
83
|
+
reply_markup: { force_reply: true, selective: true },
|
|
84
|
+
...body,
|
|
85
|
+
text: body.text + (0, reply_to_message_utils_1.encodeReplyToMessageBody)(body.data, { chatID: body.from_chat_id, command: body.command })
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async function sendSticker(token, body) {
|
|
89
|
+
return telegram_api_1.TelegramAPI.post('sendSticker', body, { token });
|
|
90
|
+
}
|
|
91
|
+
async function sendVenue(token, body) {
|
|
92
|
+
return telegram_api_1.TelegramAPI.post('sendVenue', body, { token });
|
|
93
|
+
}
|
|
94
|
+
async function sendVideo(token, body) {
|
|
95
|
+
return telegram_api_1.TelegramAPI.post('sendVideo', body, { token });
|
|
96
|
+
}
|
|
97
|
+
async function sendVideoNote(token, body) {
|
|
98
|
+
return telegram_api_1.TelegramAPI.post('sendVideoNote', body, { token });
|
|
99
|
+
}
|
|
100
|
+
async function sendVoice(token, body) {
|
|
101
|
+
return telegram_api_1.TelegramAPI.post('sendVoice', body, { token });
|
|
102
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FetchError } from '@aracna/core';
|
|
2
|
+
import type { SetChatAdministratorCustomTitle, SetChatDescription, SetChatMenuButton, SetChatPermissions, SetChatPhoto, SetChatStickerSet, SetChatTitle, SetCustomEmojiStickerSetThumbnail, SetGameScore, SetMessageReaction, SetMyCommands, SetMyDefaultAdministratorRights, SetMyDescription, SetMyName, SetMyShortDescription, SetPassportDataErrors, SetStickerEmojiList, SetStickerKeywords, SetStickerMaskPosition, SetStickerPositionInSet, SetStickerSetThumbnail, SetStickerSetTitle } from '@aracna/telegram-bot-types';
|
|
3
|
+
export declare function setChatAdministratorCustomTitle(token: string, body: SetChatAdministratorCustomTitle): Promise<boolean | FetchError>;
|
|
4
|
+
export declare function setChatDescription(token: string, body: SetChatDescription): Promise<boolean | FetchError>;
|
|
5
|
+
export declare function setChatMenuButton(token: string, body: SetChatMenuButton): Promise<boolean | FetchError>;
|
|
6
|
+
export declare function setChatPermissions(token: string, body: SetChatPermissions): Promise<boolean | FetchError>;
|
|
7
|
+
export declare function setChatPhoto(token: string, body: SetChatPhoto): Promise<boolean | FetchError>;
|
|
8
|
+
export declare function setChatStickerSet(token: string, body: SetChatStickerSet): Promise<boolean | FetchError>;
|
|
9
|
+
export declare function setChatTitle(token: string, body: SetChatTitle): Promise<boolean | FetchError>;
|
|
10
|
+
export declare function setCustomEmojiStickerSetThumbnail(token: string, body: SetCustomEmojiStickerSetThumbnail): Promise<boolean | FetchError>;
|
|
11
|
+
export declare function setGameScore(token: string, body: SetGameScore): Promise<boolean | FetchError>;
|
|
12
|
+
export declare function setMessageReaction(token: string, body: SetMessageReaction): Promise<boolean | FetchError>;
|
|
13
|
+
export declare function setMyCommands(token: string, body: SetMyCommands): Promise<boolean | FetchError>;
|
|
14
|
+
export declare function setMyDefaultAdministratorRights(token: string, body: SetMyDefaultAdministratorRights): Promise<boolean | FetchError>;
|
|
15
|
+
export declare function setMyDescription(token: string, body: SetMyDescription): Promise<boolean | FetchError>;
|
|
16
|
+
export declare function setMyName(token: string, body: SetMyName): Promise<boolean | FetchError>;
|
|
17
|
+
export declare function setMyShortDescription(token: string, body: SetMyShortDescription): Promise<boolean | FetchError>;
|
|
18
|
+
export declare function setPassportDataErrors(token: string, body: SetPassportDataErrors): Promise<boolean | FetchError>;
|
|
19
|
+
export declare function setStickerEmojiList(token: string, body: SetStickerEmojiList): Promise<boolean | FetchError>;
|
|
20
|
+
export declare function setStickerKeywords(token: string, body: SetStickerKeywords): Promise<boolean | FetchError>;
|
|
21
|
+
export declare function setStickerMaskPosition(token: string, body: SetStickerMaskPosition): Promise<boolean | FetchError>;
|
|
22
|
+
export declare function setStickerPositionInSet(token: string, body: SetStickerPositionInSet): Promise<boolean | FetchError>;
|
|
23
|
+
export declare function setStickerSetThumbnail(token: string, body: SetStickerSetThumbnail): Promise<boolean | FetchError>;
|
|
24
|
+
export declare function setStickerSetTitle(token: string, body: SetStickerSetTitle): Promise<boolean | FetchError>;
|