@maxhub/max-bot-api 0.2.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/LICENSE +20 -0
- package/dist/api.d.ts +42 -0
- package/dist/api.js +144 -0
- package/dist/bot.d.ts +26 -0
- package/dist/bot.js +70 -0
- package/dist/composer.d.ts +22 -0
- package/dist/composer.js +130 -0
- package/dist/context.d.ts +85 -0
- package/dist/context.js +252 -0
- package/dist/core/helpers/attachments.d.ts +70 -0
- package/dist/core/helpers/attachments.js +127 -0
- package/dist/core/helpers/buttons.d.ts +8 -0
- package/dist/core/helpers/buttons.js +33 -0
- package/dist/core/helpers/keyboard.d.ts +3 -0
- package/dist/core/helpers/keyboard.js +34 -0
- package/dist/core/helpers/types.d.ts +7 -0
- package/dist/core/helpers/types.js +2 -0
- package/dist/core/helpers/upload.d.ts +47 -0
- package/dist/core/helpers/upload.js +166 -0
- package/dist/core/network/api/base-api.d.ts +14 -0
- package/dist/core/network/api/base-api.js +35 -0
- package/dist/core/network/api/client.d.ts +23 -0
- package/dist/core/network/api/client.js +72 -0
- package/dist/core/network/api/error.d.ts +11 -0
- package/dist/core/network/api/error.js +17 -0
- package/dist/core/network/api/index.d.ts +5 -0
- package/dist/core/network/api/index.js +25 -0
- package/dist/core/network/api/modules/bots/api.d.ts +7 -0
- package/dist/core/network/api/modules/bots/api.js +16 -0
- package/dist/core/network/api/modules/bots/types.d.ts +11 -0
- package/dist/core/network/api/modules/bots/types.js +2 -0
- package/dist/core/network/api/modules/chats/api.d.ts +19 -0
- package/dist/core/network/api/modules/chats/api.js +83 -0
- package/dist/core/network/api/modules/chats/types.d.ts +109 -0
- package/dist/core/network/api/modules/chats/types.js +2 -0
- package/dist/core/network/api/modules/index.d.ts +12 -0
- package/dist/core/network/api/modules/index.js +34 -0
- package/dist/core/network/api/modules/messages/api.d.ts +17 -0
- package/dist/core/network/api/modules/messages/api.js +59 -0
- package/dist/core/network/api/modules/messages/types.d.ts +70 -0
- package/dist/core/network/api/modules/messages/types.js +2 -0
- package/dist/core/network/api/modules/subscriptions/api.d.ts +6 -0
- package/dist/core/network/api/modules/subscriptions/api.js +13 -0
- package/dist/core/network/api/modules/subscriptions/types.d.ts +13 -0
- package/dist/core/network/api/modules/subscriptions/types.js +2 -0
- package/dist/core/network/api/modules/types.d.ts +118 -0
- package/dist/core/network/api/modules/types.js +19 -0
- package/dist/core/network/api/modules/uploads/api.d.ts +6 -0
- package/dist/core/network/api/modules/uploads/api.js +13 -0
- package/dist/core/network/api/modules/uploads/types.d.ts +9 -0
- package/dist/core/network/api/modules/uploads/types.js +2 -0
- package/dist/core/network/api/raw-api.d.ts +169 -0
- package/dist/core/network/api/raw-api.js +29 -0
- package/dist/core/network/api/types/attachment-request.d.ts +68 -0
- package/dist/core/network/api/types/attachment-request.js +2 -0
- package/dist/core/network/api/types/attachment.d.ts +67 -0
- package/dist/core/network/api/types/attachment.js +2 -0
- package/dist/core/network/api/types/bot.d.ts +8 -0
- package/dist/core/network/api/types/bot.js +2 -0
- package/dist/core/network/api/types/chat.d.ts +41 -0
- package/dist/core/network/api/types/chat.js +2 -0
- package/dist/core/network/api/types/common.d.ts +9 -0
- package/dist/core/network/api/types/common.js +2 -0
- package/dist/core/network/api/types/index.d.ts +11 -0
- package/dist/core/network/api/types/index.js +27 -0
- package/dist/core/network/api/types/keyboard.d.ts +30 -0
- package/dist/core/network/api/types/keyboard.js +2 -0
- package/dist/core/network/api/types/markup.d.ts +13 -0
- package/dist/core/network/api/types/markup.js +2 -0
- package/dist/core/network/api/types/message.d.ts +38 -0
- package/dist/core/network/api/types/message.js +2 -0
- package/dist/core/network/api/types/subcription.d.ts +85 -0
- package/dist/core/network/api/types/subcription.js +2 -0
- package/dist/core/network/api/types/uploads.d.ts +1 -0
- package/dist/core/network/api/types/uploads.js +2 -0
- package/dist/core/network/api/types/user.d.ts +14 -0
- package/dist/core/network/api/types/user.js +2 -0
- package/dist/core/network/polling.d.ts +11 -0
- package/dist/core/network/polling.js +51 -0
- package/dist/filters.d.ts +2 -0
- package/dist/filters.js +17 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +45 -0
- package/dist/middleware.d.ts +9 -0
- package/dist/middleware.js +2 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +17 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +24 -0
- package/package.json +55 -0
- package/readme.md +62 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ChatsApi = exports.UploadsApi = exports.SubscriptionsApi = exports.MessagesApi = exports.BotsApi = exports.BaseApi = void 0;
|
|
18
|
+
var base_api_1 = require("../base-api");
|
|
19
|
+
Object.defineProperty(exports, "BaseApi", { enumerable: true, get: function () { return base_api_1.BaseApi; } });
|
|
20
|
+
var api_1 = require("./bots/api");
|
|
21
|
+
Object.defineProperty(exports, "BotsApi", { enumerable: true, get: function () { return api_1.BotsApi; } });
|
|
22
|
+
__exportStar(require("./bots/types"), exports);
|
|
23
|
+
var api_2 = require("./messages/api");
|
|
24
|
+
Object.defineProperty(exports, "MessagesApi", { enumerable: true, get: function () { return api_2.MessagesApi; } });
|
|
25
|
+
__exportStar(require("./messages/types"), exports);
|
|
26
|
+
var api_3 = require("./subscriptions/api");
|
|
27
|
+
Object.defineProperty(exports, "SubscriptionsApi", { enumerable: true, get: function () { return api_3.SubscriptionsApi; } });
|
|
28
|
+
__exportStar(require("./subscriptions/types"), exports);
|
|
29
|
+
var api_4 = require("./uploads/api");
|
|
30
|
+
Object.defineProperty(exports, "UploadsApi", { enumerable: true, get: function () { return api_4.UploadsApi; } });
|
|
31
|
+
__exportStar(require("./uploads/types"), exports);
|
|
32
|
+
var api_5 = require("./chats/api");
|
|
33
|
+
Object.defineProperty(exports, "ChatsApi", { enumerable: true, get: function () { return api_5.ChatsApi; } });
|
|
34
|
+
__exportStar(require("./chats/types"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseApi } from '../../base-api';
|
|
2
|
+
import type { FlattenReq, GetMessageDTO, GetMessageResponse, GetMessagesDTO, GetMessagesResponse, SendMessageResponse } from '../types';
|
|
3
|
+
import type { SendMessageDTO, DeleteMessageDTO } from './types';
|
|
4
|
+
export declare class MessagesApi extends BaseApi {
|
|
5
|
+
get: ({ ...query }: FlattenReq<GetMessagesDTO>) => Promise<GetMessagesResponse>;
|
|
6
|
+
getById: ({ message_id }: FlattenReq<GetMessageDTO>) => Promise<GetMessageResponse>;
|
|
7
|
+
send: ({ chat_id, user_id, disable_link_preview, ...body }: FlattenReq<SendMessageDTO>) => Promise<SendMessageResponse>;
|
|
8
|
+
edit: ({ message_id, ...body }: {
|
|
9
|
+
[x: string]: any;
|
|
10
|
+
message_id: any;
|
|
11
|
+
}) => Promise<import("../..").ActionResponse>;
|
|
12
|
+
delete: ({ ...query }: FlattenReq<DeleteMessageDTO>) => Promise<import("../..").ActionResponse>;
|
|
13
|
+
answerOnCallback: ({ callback_id, ...body }: {
|
|
14
|
+
[x: string]: any;
|
|
15
|
+
callback_id: any;
|
|
16
|
+
}) => Promise<import("../..").ActionResponse>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessagesApi = void 0;
|
|
4
|
+
const utils_1 = require("../../../../../utils");
|
|
5
|
+
const error_1 = require("../../error");
|
|
6
|
+
const base_api_1 = require("../../base-api");
|
|
7
|
+
class MessagesApi extends base_api_1.BaseApi {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.get = async ({ ...query }) => {
|
|
11
|
+
return this._get('messages', {
|
|
12
|
+
query,
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
this.getById = async ({ message_id }) => {
|
|
16
|
+
return this._get('messages/{message_id}', {
|
|
17
|
+
path: { message_id },
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
this.send = async ({ chat_id, user_id, disable_link_preview, ...body }) => {
|
|
21
|
+
try {
|
|
22
|
+
return await this._post('messages', {
|
|
23
|
+
body,
|
|
24
|
+
query: { chat_id, user_id, disable_link_preview },
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
if (err instanceof error_1.MaxError) {
|
|
29
|
+
if (err.code === 'attachment.not.ready') {
|
|
30
|
+
console.log('Attachment not ready');
|
|
31
|
+
await (0, utils_1.sleep)(1000);
|
|
32
|
+
return this.send({
|
|
33
|
+
chat_id, user_id, disable_link_preview, ...body,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
this.edit = async ({ message_id, ...body }) => {
|
|
41
|
+
return this._put('messages', {
|
|
42
|
+
query: { message_id },
|
|
43
|
+
body,
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
this.delete = async ({ ...query }) => {
|
|
47
|
+
return this._delete('messages', {
|
|
48
|
+
query,
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
this.answerOnCallback = async ({ callback_id, ...body }) => {
|
|
52
|
+
return this._post('answers', {
|
|
53
|
+
query: { callback_id },
|
|
54
|
+
body,
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.MessagesApi = MessagesApi;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ActionResponse, AttachmentRequest, Message, MessageLinkType } from '../../types';
|
|
2
|
+
import type { FlattenReq } from '../types';
|
|
3
|
+
export type GetMessageDTO = {
|
|
4
|
+
path: {
|
|
5
|
+
message_id: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export type GetMessageResponse = Message;
|
|
9
|
+
export type GetMessagesDTO = {
|
|
10
|
+
query: {
|
|
11
|
+
chat_id?: number;
|
|
12
|
+
message_ids?: string | null;
|
|
13
|
+
from?: number;
|
|
14
|
+
to?: number;
|
|
15
|
+
count?: number;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type GetMessagesExtra = Omit<FlattenReq<GetMessagesDTO>, 'chat_id' | 'message_ids'> & {
|
|
19
|
+
message_ids?: string[];
|
|
20
|
+
};
|
|
21
|
+
export type GetMessagesResponse = {
|
|
22
|
+
messages: Message[];
|
|
23
|
+
};
|
|
24
|
+
export type SendMessageDTO = {
|
|
25
|
+
query: {
|
|
26
|
+
user_id?: number;
|
|
27
|
+
chat_id?: number;
|
|
28
|
+
disable_link_preview?: boolean;
|
|
29
|
+
};
|
|
30
|
+
body: {
|
|
31
|
+
text?: string | null;
|
|
32
|
+
attachments?: AttachmentRequest[] | null;
|
|
33
|
+
link?: {
|
|
34
|
+
type: MessageLinkType;
|
|
35
|
+
mid: string;
|
|
36
|
+
} | null;
|
|
37
|
+
notify?: boolean;
|
|
38
|
+
format?: 'markdown' | 'html' | null;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export type SendMessageExtra = Omit<FlattenReq<SendMessageDTO>, 'chat_id' | 'user_id' | 'text'>;
|
|
42
|
+
export type SendMessageResponse = {
|
|
43
|
+
message: Message;
|
|
44
|
+
};
|
|
45
|
+
export type DeleteMessageDTO = {
|
|
46
|
+
query: {
|
|
47
|
+
message_id: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export type DeleteMessageExtra = Omit<FlattenReq<DeleteMessageDTO>, 'message_id'>;
|
|
51
|
+
export type DeleteMessageResponse = ActionResponse;
|
|
52
|
+
export type EditMessageDTO = {
|
|
53
|
+
query: {
|
|
54
|
+
message_id: string;
|
|
55
|
+
};
|
|
56
|
+
body: SendMessageDTO['body'];
|
|
57
|
+
};
|
|
58
|
+
export type EditMessageExtra = Omit<FlattenReq<EditMessageDTO>, 'message_id'>;
|
|
59
|
+
export type EditMessageResponse = ActionResponse;
|
|
60
|
+
export type AnswerOnCallbackDTO = {
|
|
61
|
+
query: {
|
|
62
|
+
callback_id: string;
|
|
63
|
+
};
|
|
64
|
+
body: {
|
|
65
|
+
message?: SendMessageDTO['body'] | null;
|
|
66
|
+
notification?: string | null;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export type AnswerOnCallbackExtra = Omit<FlattenReq<AnswerOnCallbackDTO>, 'callback_id'>;
|
|
70
|
+
export type AnswerOnCallbackResponse = ActionResponse;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BaseApi } from '../../base-api';
|
|
2
|
+
import { FlattenReq } from '../types';
|
|
3
|
+
import { GetUpdatesDTO } from './types';
|
|
4
|
+
export declare class SubscriptionsApi extends BaseApi {
|
|
5
|
+
getUpdates: ({ ...query }: FlattenReq<GetUpdatesDTO>) => Promise<import("./types").GetUpdatesResponse>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubscriptionsApi = void 0;
|
|
4
|
+
const base_api_1 = require("../../base-api");
|
|
5
|
+
class SubscriptionsApi extends base_api_1.BaseApi {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.getUpdates = async ({ ...query }) => {
|
|
9
|
+
return this._get('updates', { query });
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.SubscriptionsApi = SubscriptionsApi;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { ReqOptions } from '../client';
|
|
2
|
+
import type { EditMyInfoDTO, EditMyInfoResponse, GetMyInfoResponse } from './bots/types';
|
|
3
|
+
import type { AddChatMembersDTO, AddChatMembersResponse, EditChatInfoDTO, EditChatInfoResponse, GetAllChatsDTO, GetAllChatsResponse, GetChatAdminsDTO, GetChatAdminsResponse, GetChatByIdDTO, GetChatByIdResponse, GetChatByLinkDTO, GetChatByLinkResponse, GetChatMembersDTO, GetChatMembershipDTO, GetChatMembershipResponse, GetChatMembersResponse, GetPinnedMessageDTO, GetPinnedMessageResponse, LeaveChatDTO, LeaveChatResponse, PinMessageDTO, PinMessageResponse, RemoveChatMemberDTO, RemoveChatMemberResponse, SendActionDTO, SendActionResponse, UnpinMessageDTO, UnpinMessageResponse } from './chats/types';
|
|
4
|
+
import type { AnswerOnCallbackDTO, AnswerOnCallbackResponse, DeleteMessageDTO, DeleteMessageResponse, EditMessageDTO, EditMessageResponse, GetMessageDTO, GetMessageResponse, GetMessagesDTO, GetMessagesResponse, SendMessageDTO, SendMessageResponse } from './messages/types';
|
|
5
|
+
import type { GetUpdatesDTO, GetUpdatesResponse } from './subscriptions/types';
|
|
6
|
+
import { GetUploadUrlResponse, GetUploadUrlDTO } from './uploads/types';
|
|
7
|
+
export * from './bots/types';
|
|
8
|
+
export * from './messages/types';
|
|
9
|
+
export * from './subscriptions/types';
|
|
10
|
+
export type FlattenReq<T extends Omit<ReqOptions, 'method'>> = T['body'] & T['query'] & T['path'];
|
|
11
|
+
export type ApiMethods = {
|
|
12
|
+
GET: {
|
|
13
|
+
chats: {
|
|
14
|
+
req: GetAllChatsDTO;
|
|
15
|
+
res: GetAllChatsResponse;
|
|
16
|
+
};
|
|
17
|
+
'chats/{chat_id}': {
|
|
18
|
+
req: GetChatByIdDTO;
|
|
19
|
+
res: GetChatByIdResponse;
|
|
20
|
+
};
|
|
21
|
+
'chats/{chat_id}/members/admins': {
|
|
22
|
+
req: GetChatAdminsDTO;
|
|
23
|
+
res: GetChatAdminsResponse;
|
|
24
|
+
};
|
|
25
|
+
'chats/{chat_id}/members': {
|
|
26
|
+
req: GetChatMembersDTO;
|
|
27
|
+
res: GetChatMembersResponse;
|
|
28
|
+
};
|
|
29
|
+
'chats/{chat_id}/members/me': {
|
|
30
|
+
req: GetChatMembershipDTO;
|
|
31
|
+
res: GetChatMembershipResponse;
|
|
32
|
+
};
|
|
33
|
+
'chats/{chat_id}/pin': {
|
|
34
|
+
req: GetPinnedMessageDTO;
|
|
35
|
+
res: GetPinnedMessageResponse;
|
|
36
|
+
};
|
|
37
|
+
'chats/{chat_link}': {
|
|
38
|
+
req: GetChatByLinkDTO;
|
|
39
|
+
res: GetChatByLinkResponse;
|
|
40
|
+
};
|
|
41
|
+
me: {
|
|
42
|
+
req: {};
|
|
43
|
+
res: GetMyInfoResponse;
|
|
44
|
+
};
|
|
45
|
+
updates: {
|
|
46
|
+
req: GetUpdatesDTO;
|
|
47
|
+
res: GetUpdatesResponse;
|
|
48
|
+
};
|
|
49
|
+
messages: {
|
|
50
|
+
req: GetMessagesDTO;
|
|
51
|
+
res: GetMessagesResponse;
|
|
52
|
+
};
|
|
53
|
+
'messages/{message_id}': {
|
|
54
|
+
req: GetMessageDTO;
|
|
55
|
+
res: GetMessageResponse;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
POST: {
|
|
59
|
+
'chats/{chat_id}/actions': {
|
|
60
|
+
req: SendActionDTO;
|
|
61
|
+
res: SendActionResponse;
|
|
62
|
+
};
|
|
63
|
+
'chats/{chat_id}/members': {
|
|
64
|
+
req: AddChatMembersDTO;
|
|
65
|
+
res: AddChatMembersResponse;
|
|
66
|
+
};
|
|
67
|
+
messages: {
|
|
68
|
+
req: SendMessageDTO;
|
|
69
|
+
res: SendMessageResponse;
|
|
70
|
+
};
|
|
71
|
+
uploads: {
|
|
72
|
+
req: GetUploadUrlDTO;
|
|
73
|
+
res: GetUploadUrlResponse;
|
|
74
|
+
};
|
|
75
|
+
answers: {
|
|
76
|
+
req: AnswerOnCallbackDTO;
|
|
77
|
+
res: AnswerOnCallbackResponse;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
PATCH: {
|
|
81
|
+
me: {
|
|
82
|
+
req: EditMyInfoDTO;
|
|
83
|
+
res: EditMyInfoResponse;
|
|
84
|
+
};
|
|
85
|
+
'chats/{chat_id}': {
|
|
86
|
+
req: EditChatInfoDTO;
|
|
87
|
+
res: EditChatInfoResponse;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
PUT: {
|
|
91
|
+
messages: {
|
|
92
|
+
req: EditMessageDTO;
|
|
93
|
+
res: EditMessageResponse;
|
|
94
|
+
};
|
|
95
|
+
'chats/{chat_id}/pin': {
|
|
96
|
+
req: PinMessageDTO;
|
|
97
|
+
res: PinMessageResponse;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
DELETE: {
|
|
101
|
+
messages: {
|
|
102
|
+
req: DeleteMessageDTO;
|
|
103
|
+
res: DeleteMessageResponse;
|
|
104
|
+
};
|
|
105
|
+
'chats/{chat_id}/pin': {
|
|
106
|
+
req: UnpinMessageDTO;
|
|
107
|
+
res: UnpinMessageResponse;
|
|
108
|
+
};
|
|
109
|
+
'chats/{chat_id}/members': {
|
|
110
|
+
req: RemoveChatMemberDTO;
|
|
111
|
+
res: RemoveChatMemberResponse;
|
|
112
|
+
};
|
|
113
|
+
'chats/{chat_id}/members/me': {
|
|
114
|
+
req: LeaveChatDTO;
|
|
115
|
+
res: LeaveChatResponse;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./bots/types"), exports);
|
|
18
|
+
__exportStar(require("./messages/types"), exports);
|
|
19
|
+
__exportStar(require("./subscriptions/types"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BaseApi } from '../../base-api';
|
|
2
|
+
import { FlattenReq } from '../types';
|
|
3
|
+
import { GetUploadUrlDTO } from './types';
|
|
4
|
+
export declare class UploadsApi extends BaseApi {
|
|
5
|
+
getUploadUrl: ({ ...query }: FlattenReq<GetUploadUrlDTO>) => Promise<import("./types").GetUploadUrlResponse>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UploadsApi = void 0;
|
|
4
|
+
const base_api_1 = require("../../base-api");
|
|
5
|
+
class UploadsApi extends base_api_1.BaseApi {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.getUploadUrl = async ({ ...query }) => {
|
|
9
|
+
return this._post('uploads', { query });
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.UploadsApi = UploadsApi;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { Client } from './client';
|
|
2
|
+
import { BaseApi, BotsApi, ChatsApi, MessagesApi, SubscriptionsApi, UploadsApi } from './modules';
|
|
3
|
+
export declare class RawApi extends BaseApi {
|
|
4
|
+
private readonly client;
|
|
5
|
+
constructor(client: Client);
|
|
6
|
+
get: <Method extends "chats" | "chats/{chat_id}" | "chats/{chat_id}/members/admins" | "chats/{chat_id}/members" | "chats/{chat_id}/members/me" | "chats/{chat_id}/pin" | "chats/{chat_link}" | "me" | "updates" | "messages" | "messages/{message_id}">(method: Method, options: {
|
|
7
|
+
chats: {
|
|
8
|
+
req: import("./modules").GetAllChatsDTO;
|
|
9
|
+
res: import("./modules").GetAllChatsResponse;
|
|
10
|
+
};
|
|
11
|
+
'chats/{chat_id}': {
|
|
12
|
+
req: import("./modules").GetChatByIdDTO;
|
|
13
|
+
res: import("./modules").GetChatByIdResponse;
|
|
14
|
+
};
|
|
15
|
+
'chats/{chat_id}/members/admins': {
|
|
16
|
+
req: import("./modules").GetChatAdminsDTO;
|
|
17
|
+
res: import("./modules").GetChatAdminsResponse;
|
|
18
|
+
};
|
|
19
|
+
'chats/{chat_id}/members': {
|
|
20
|
+
req: import("./modules").GetChatMembersDTO;
|
|
21
|
+
res: import("./modules").GetChatMembersResponse;
|
|
22
|
+
};
|
|
23
|
+
'chats/{chat_id}/members/me': {
|
|
24
|
+
req: import("./modules").GetChatMembershipDTO;
|
|
25
|
+
res: import("./modules").GetChatMembershipResponse;
|
|
26
|
+
};
|
|
27
|
+
'chats/{chat_id}/pin': {
|
|
28
|
+
req: import("./modules").GetPinnedMessageDTO;
|
|
29
|
+
res: import("./modules").GetPinnedMessageResponse;
|
|
30
|
+
};
|
|
31
|
+
'chats/{chat_link}': {
|
|
32
|
+
req: import("./modules").GetChatByLinkDTO;
|
|
33
|
+
res: import("./modules").GetChatByLinkResponse;
|
|
34
|
+
};
|
|
35
|
+
me: {
|
|
36
|
+
req: {};
|
|
37
|
+
res: import("./modules").GetMyInfoResponse;
|
|
38
|
+
};
|
|
39
|
+
updates: {
|
|
40
|
+
req: import("./modules").GetUpdatesDTO;
|
|
41
|
+
res: import("./modules").GetUpdatesResponse;
|
|
42
|
+
};
|
|
43
|
+
messages: {
|
|
44
|
+
req: import("./modules").GetMessagesDTO;
|
|
45
|
+
res: import("./modules").GetMessagesResponse;
|
|
46
|
+
};
|
|
47
|
+
'messages/{message_id}': {
|
|
48
|
+
req: import("./modules").GetMessageDTO;
|
|
49
|
+
res: import("./modules").GetMessageResponse;
|
|
50
|
+
};
|
|
51
|
+
}[Method]["req"]) => Promise<{
|
|
52
|
+
chats: {
|
|
53
|
+
req: import("./modules").GetAllChatsDTO;
|
|
54
|
+
res: import("./modules").GetAllChatsResponse;
|
|
55
|
+
};
|
|
56
|
+
'chats/{chat_id}': {
|
|
57
|
+
req: import("./modules").GetChatByIdDTO;
|
|
58
|
+
res: import("./modules").GetChatByIdResponse;
|
|
59
|
+
};
|
|
60
|
+
'chats/{chat_id}/members/admins': {
|
|
61
|
+
req: import("./modules").GetChatAdminsDTO;
|
|
62
|
+
res: import("./modules").GetChatAdminsResponse;
|
|
63
|
+
};
|
|
64
|
+
'chats/{chat_id}/members': {
|
|
65
|
+
req: import("./modules").GetChatMembersDTO;
|
|
66
|
+
res: import("./modules").GetChatMembersResponse;
|
|
67
|
+
};
|
|
68
|
+
'chats/{chat_id}/members/me': {
|
|
69
|
+
req: import("./modules").GetChatMembershipDTO;
|
|
70
|
+
res: import("./modules").GetChatMembershipResponse;
|
|
71
|
+
};
|
|
72
|
+
'chats/{chat_id}/pin': {
|
|
73
|
+
req: import("./modules").GetPinnedMessageDTO;
|
|
74
|
+
res: import("./modules").GetPinnedMessageResponse;
|
|
75
|
+
};
|
|
76
|
+
'chats/{chat_link}': {
|
|
77
|
+
req: import("./modules").GetChatByLinkDTO;
|
|
78
|
+
res: import("./modules").GetChatByLinkResponse;
|
|
79
|
+
};
|
|
80
|
+
me: {
|
|
81
|
+
req: {};
|
|
82
|
+
res: import("./modules").GetMyInfoResponse;
|
|
83
|
+
};
|
|
84
|
+
updates: {
|
|
85
|
+
req: import("./modules").GetUpdatesDTO;
|
|
86
|
+
res: import("./modules").GetUpdatesResponse;
|
|
87
|
+
};
|
|
88
|
+
messages: {
|
|
89
|
+
req: import("./modules").GetMessagesDTO;
|
|
90
|
+
res: import("./modules").GetMessagesResponse;
|
|
91
|
+
};
|
|
92
|
+
'messages/{message_id}': {
|
|
93
|
+
req: import("./modules").GetMessageDTO;
|
|
94
|
+
res: import("./modules").GetMessageResponse;
|
|
95
|
+
};
|
|
96
|
+
}[Method]["res"]>;
|
|
97
|
+
post: <Method extends "chats/{chat_id}/members" | "messages" | "chats/{chat_id}/actions" | "uploads" | "answers">(method: Method, options: {
|
|
98
|
+
'chats/{chat_id}/actions': {
|
|
99
|
+
req: import("./modules").SendActionDTO;
|
|
100
|
+
res: import("./modules").SendActionResponse;
|
|
101
|
+
};
|
|
102
|
+
'chats/{chat_id}/members': {
|
|
103
|
+
req: import("./modules").AddChatMembersDTO;
|
|
104
|
+
res: import("./modules").AddChatMembersResponse;
|
|
105
|
+
};
|
|
106
|
+
messages: {
|
|
107
|
+
req: import("./modules").SendMessageDTO;
|
|
108
|
+
res: import("./modules").SendMessageResponse;
|
|
109
|
+
};
|
|
110
|
+
uploads: {
|
|
111
|
+
req: import("./modules").GetUploadUrlDTO;
|
|
112
|
+
res: import("./modules").GetUploadUrlResponse;
|
|
113
|
+
};
|
|
114
|
+
answers: {
|
|
115
|
+
req: import("./modules").AnswerOnCallbackDTO;
|
|
116
|
+
res: import("./modules").AnswerOnCallbackResponse;
|
|
117
|
+
};
|
|
118
|
+
}[Method]["req"]) => Promise<{
|
|
119
|
+
'chats/{chat_id}/actions': {
|
|
120
|
+
req: import("./modules").SendActionDTO;
|
|
121
|
+
res: import("./modules").SendActionResponse;
|
|
122
|
+
};
|
|
123
|
+
'chats/{chat_id}/members': {
|
|
124
|
+
req: import("./modules").AddChatMembersDTO;
|
|
125
|
+
res: import("./modules").AddChatMembersResponse;
|
|
126
|
+
};
|
|
127
|
+
messages: {
|
|
128
|
+
req: import("./modules").SendMessageDTO;
|
|
129
|
+
res: import("./modules").SendMessageResponse;
|
|
130
|
+
};
|
|
131
|
+
uploads: {
|
|
132
|
+
req: import("./modules").GetUploadUrlDTO;
|
|
133
|
+
res: import("./modules").GetUploadUrlResponse;
|
|
134
|
+
};
|
|
135
|
+
answers: {
|
|
136
|
+
req: import("./modules").AnswerOnCallbackDTO;
|
|
137
|
+
res: import("./modules").AnswerOnCallbackResponse;
|
|
138
|
+
};
|
|
139
|
+
}[Method]["res"]>;
|
|
140
|
+
patch: <Method extends "chats/{chat_id}" | "me">(method: Method, options: {
|
|
141
|
+
me: {
|
|
142
|
+
req: import("./modules").EditMyInfoDTO;
|
|
143
|
+
res: import("./modules").EditMyInfoResponse;
|
|
144
|
+
};
|
|
145
|
+
'chats/{chat_id}': {
|
|
146
|
+
req: import("./modules").EditChatInfoDTO;
|
|
147
|
+
res: import("./modules").EditChatInfoResponse;
|
|
148
|
+
};
|
|
149
|
+
}[Method]["req"]) => Promise<{
|
|
150
|
+
me: {
|
|
151
|
+
req: import("./modules").EditMyInfoDTO;
|
|
152
|
+
res: import("./modules").EditMyInfoResponse;
|
|
153
|
+
};
|
|
154
|
+
'chats/{chat_id}': {
|
|
155
|
+
req: import("./modules").EditChatInfoDTO;
|
|
156
|
+
res: import("./modules").EditChatInfoResponse;
|
|
157
|
+
};
|
|
158
|
+
}[Method]["res"]>;
|
|
159
|
+
private _chats?;
|
|
160
|
+
get chats(): ChatsApi;
|
|
161
|
+
private _bots?;
|
|
162
|
+
get bots(): BotsApi;
|
|
163
|
+
private _messages?;
|
|
164
|
+
get messages(): MessagesApi;
|
|
165
|
+
private _subscriptions?;
|
|
166
|
+
get subscriptions(): SubscriptionsApi;
|
|
167
|
+
private _uploads?;
|
|
168
|
+
get uploads(): UploadsApi;
|
|
169
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RawApi = void 0;
|
|
4
|
+
const modules_1 = require("./modules");
|
|
5
|
+
class RawApi extends modules_1.BaseApi {
|
|
6
|
+
constructor(client) {
|
|
7
|
+
super(client);
|
|
8
|
+
this.client = client;
|
|
9
|
+
this.get = this._get;
|
|
10
|
+
this.post = this._post;
|
|
11
|
+
this.patch = this._patch;
|
|
12
|
+
}
|
|
13
|
+
get chats() {
|
|
14
|
+
return (this._chats ?? (this._chats = new modules_1.ChatsApi(this.client)));
|
|
15
|
+
}
|
|
16
|
+
get bots() {
|
|
17
|
+
return (this._bots ?? (this._bots = new modules_1.BotsApi(this.client)));
|
|
18
|
+
}
|
|
19
|
+
get messages() {
|
|
20
|
+
return (this._messages ?? (this._messages = new modules_1.MessagesApi(this.client)));
|
|
21
|
+
}
|
|
22
|
+
get subscriptions() {
|
|
23
|
+
return (this._subscriptions ?? (this._subscriptions = new modules_1.SubscriptionsApi(this.client)));
|
|
24
|
+
}
|
|
25
|
+
get uploads() {
|
|
26
|
+
return (this._uploads ?? (this._uploads = new modules_1.UploadsApi(this.client)));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.RawApi = RawApi;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { NullableObject } from '../../../helpers/types';
|
|
2
|
+
import { Button } from './keyboard';
|
|
3
|
+
type MediaAttachmentRequestPayload = {
|
|
4
|
+
token?: string;
|
|
5
|
+
};
|
|
6
|
+
export type ImageAttachmentRequest = {
|
|
7
|
+
type: 'image';
|
|
8
|
+
payload: MediaAttachmentRequestPayload & {
|
|
9
|
+
url?: string | null;
|
|
10
|
+
photos?: {
|
|
11
|
+
[key: string]: {
|
|
12
|
+
token: string;
|
|
13
|
+
};
|
|
14
|
+
} | null;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export type VideoAttachmentRequest = {
|
|
18
|
+
type: 'video';
|
|
19
|
+
payload: MediaAttachmentRequestPayload;
|
|
20
|
+
};
|
|
21
|
+
export type AudioAttachmentRequest = {
|
|
22
|
+
type: 'audio';
|
|
23
|
+
payload: MediaAttachmentRequestPayload;
|
|
24
|
+
};
|
|
25
|
+
export type FileAttachmentRequest = {
|
|
26
|
+
type: 'file';
|
|
27
|
+
payload: MediaAttachmentRequestPayload;
|
|
28
|
+
};
|
|
29
|
+
export type ContactAttachmentRequest = {
|
|
30
|
+
type: 'contact';
|
|
31
|
+
payload: {
|
|
32
|
+
name: string | null;
|
|
33
|
+
contact_id?: number | null;
|
|
34
|
+
vcf_info?: string | null;
|
|
35
|
+
vcf_phone?: string | null;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export type StickerAttachmentRequest = {
|
|
39
|
+
type: 'sticker';
|
|
40
|
+
payload: {
|
|
41
|
+
code: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export type InlineKeyboardAttachmentRequest = {
|
|
45
|
+
type: 'inline_keyboard';
|
|
46
|
+
payload: {
|
|
47
|
+
buttons: Button[][];
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export type LocationAttachmentRequest = {
|
|
51
|
+
type: 'location';
|
|
52
|
+
latitude: number;
|
|
53
|
+
longitude: number;
|
|
54
|
+
};
|
|
55
|
+
export type ShareAttachmentRequest = {
|
|
56
|
+
type: 'share';
|
|
57
|
+
payload: Partial<NullableObject<MediaAttachmentRequestPayload> & {
|
|
58
|
+
url?: string | null;
|
|
59
|
+
}>;
|
|
60
|
+
};
|
|
61
|
+
export type PhotoAttachmentRequestPayload = {
|
|
62
|
+
url?: string | null;
|
|
63
|
+
token?: string | null;
|
|
64
|
+
photos?: Record<string, string> | null;
|
|
65
|
+
};
|
|
66
|
+
export type AttachmentRequest = ImageAttachmentRequest | VideoAttachmentRequest | AudioAttachmentRequest | FileAttachmentRequest | StickerAttachmentRequest | ContactAttachmentRequest | InlineKeyboardAttachmentRequest | ShareAttachmentRequest | LocationAttachmentRequest;
|
|
67
|
+
export type AttachmentType = AttachmentRequest['type'];
|
|
68
|
+
export {};
|