rubika 1.2.3 → 1.2.4
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/bot/bot.ts +34 -28
- package/bot/contexts/inline.ts +15 -14
- package/bot/contexts/update.ts +20 -21
- package/bot/filters.ts +32 -30
- package/bot/index.ts +4 -2
- package/bot/methods/advanced/builder.ts +7 -12
- package/bot/methods/files/_sendFile.ts +5 -2
- package/bot/methods/files/uploadFile.ts +4 -1
- package/bot/methods/index.ts +10 -10
- package/bot/methods/messages/deleteMessage.ts +6 -10
- package/bot/methods/messages/sendContact.ts +5 -3
- package/bot/methods/messages/sendFile.ts +1 -1
- package/bot/methods/messages/sendGif.ts +23 -23
- package/bot/methods/messages/sendImage.ts +23 -23
- package/bot/methods/messages/sendLocation.ts +6 -3
- package/bot/methods/messages/sendMessage.ts +6 -2
- package/bot/methods/messages/sendMusic.ts +23 -23
- package/bot/methods/messages/sendPoll.ts +6 -3
- package/bot/methods/messages/sendSticker.ts +8 -4
- package/bot/methods/messages/sendVideo.ts +23 -23
- package/bot/methods/messages/sendVoice.ts +23 -23
- package/bot/methods/utilities/getUpdates.ts +1 -1
- package/bot/methods/utilities/handleUpdates.ts +14 -14
- package/bot/methods/utilities/polling.ts +57 -32
- package/bot/methods/utilities/run.ts +2 -2
- package/bot/methods/utilities/start.ts +5 -2
- package/bot/methods/utilities/webhook.ts +1 -2
- package/bot/network.ts +43 -15
- package/bot/types/handlers.ts +3 -3
- package/bot/types/interfaces.ts +44 -4
- package/bot/types/utils.ts +6 -1
- package/bot/utils/antiSpam.ts +1 -1
- package/client/client.ts +35 -33
- package/client/contexts/activities.type.ts +2 -2
- package/client/contexts/chat.type.ts +2 -2
- package/client/contexts/message.type.ts +10 -3
- package/client/contexts/notifications.type.ts +2 -2
- package/client/crypto.ts +2 -2
- package/client/filters.ts +31 -31
- package/client/index.ts +5 -1
- package/client/methods/advanced/builder.ts +3 -1
- package/client/methods/auth/registerDevice.ts +8 -6
- package/client/methods/channels/addChannel.ts +1 -1
- package/client/methods/channels/editChannelInfo.ts +3 -3
- package/client/methods/channels/setChannelVoiceChatSetting.ts +1 -1
- package/client/methods/chats/editJoinLink.ts +1 -1
- package/client/methods/chats/seenChats.ts +1 -1
- package/client/methods/extras/deleteMessagebyCount.ts +40 -38
- package/client/methods/extras/onEditMessages.ts +1 -1
- package/client/methods/extras/userIsAdmin.ts +2 -2
- package/client/methods/groups/editGroupInfo.ts +13 -1
- package/client/methods/groups/setGroupVoiceChatSetting.ts +1 -1
- package/client/methods/messages/sendDocument.ts +3 -2
- package/client/methods/messages/sendFileInline.ts +1 -1
- package/client/methods/messages/sendGif.ts +4 -3
- package/client/methods/messages/sendMessage.ts +7 -5
- package/client/methods/messages/sendMessageAPICall.ts +18 -0
- package/client/methods/messages/sendMusic.ts +3 -2
- package/client/methods/messages/sendPhoto.ts +3 -2
- package/client/methods/messages/sendText.ts +4 -2
- package/client/methods/messages/sendVideo.ts +3 -2
- package/client/methods/messages/sendVideoMessage.ts +3 -2
- package/client/methods/messages/sendVoice.ts +3 -2
- package/client/methods/settings/updateProfile.ts +1 -1
- package/client/methods/utilities/start.ts +7 -4
- package/client/methods/utilities/thumbnail.ts +5 -5
- package/client/network/file.ts +13 -7
- package/client/network/websocket.ts +32 -15
- package/client/types/client.type.ts +10 -10
- package/client/utils/session.ts +1 -1
- package/index.ts +1 -0
- package/package.json +1 -7
- package/utils/formater.ts +1 -1
- package/utils/index.ts +2 -1
- package/utils/logger.ts +28 -0
- package/utils/parser.ts +120 -156
- package/utils/errors.ts +0 -26
package/client/filters.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FileInline } from "./types/decorators.type";
|
|
2
2
|
import { Filters as BotFilters } from "../bot";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { Contexts } from ".";
|
|
5
4
|
|
|
5
|
+
class Filters {
|
|
6
6
|
static findKey(message: any, key: string): any {
|
|
7
7
|
if (!message || typeof message !== "object") {
|
|
8
8
|
return undefined;
|
|
@@ -34,113 +34,113 @@ class Filters {
|
|
|
34
34
|
return undefined;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
static guidType(message:
|
|
37
|
+
static guidType(message: Contexts.Message<any>, startWith: string): boolean {
|
|
38
38
|
const result = Filters.findKey(message, "object_guid");
|
|
39
39
|
return result?.startsWith(startWith) ?? false;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
static isMention(message:
|
|
42
|
+
static isMention(message: Contexts.Message<any>): boolean {
|
|
43
43
|
return !!Filters.findKey(
|
|
44
44
|
message.message?.metadata?.meta_data_parts,
|
|
45
45
|
"link",
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
static isMarkdown(message:
|
|
49
|
+
static isMarkdown(message: Contexts.Message<any>): boolean {
|
|
50
50
|
return !!Filters.findKey(message.message, "metadata");
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
static isReply(message:
|
|
53
|
+
static isReply(message: Contexts.Message<any>): boolean {
|
|
54
54
|
return !!Filters.findKey(message, "reply_to_message_id");
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
static isEdited(message:
|
|
57
|
+
static isEdited(message: Contexts.Message<any>): boolean {
|
|
58
58
|
return !!Filters.findKey(message, "is_edited");
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
static isLink(message:
|
|
61
|
+
static isLink(message: Contexts.Message<any>): boolean {
|
|
62
62
|
const text = Filters.findKey(message, "text");
|
|
63
63
|
return text ? BotFilters.linkify.test(text) : false;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
static isText(message:
|
|
66
|
+
static isText(message: Contexts.Message<any>): boolean {
|
|
67
67
|
return !!Filters.findKey(message, "text");
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
static isGroup(message:
|
|
70
|
+
static isGroup(message: Contexts.Message<any>): boolean {
|
|
71
71
|
return Filters.guidType(message, "g0");
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
static isChannel(message:
|
|
74
|
+
static isChannel(message: Contexts.Message<any>): boolean {
|
|
75
75
|
return Filters.guidType(message, "c0");
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
static isPrivate(message:
|
|
78
|
+
static isPrivate(message: Contexts.Message<any>): boolean {
|
|
79
79
|
return Filters.guidType(message, "u0");
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
static isForward(message:
|
|
82
|
+
static isForward(message: Contexts.Message<any>): boolean {
|
|
83
83
|
return !!Filters.findKey(message, "forwarded_from");
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
static fileInline(message:
|
|
86
|
+
static fileInline(message: Contexts.Message<any>): FileInline | undefined {
|
|
87
87
|
return message.message?.file_inline;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
static isFileInline(message:
|
|
90
|
+
static isFileInline(message: Contexts.Message<any>): boolean {
|
|
91
91
|
return ["FileInline", "FileInlineCaption"].includes(message.message?.type);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
static isFile(message:
|
|
94
|
+
static isFile(message: Contexts.Message<any>): boolean {
|
|
95
95
|
return Filters.fileInline(message)?.type === "File";
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
static isPhoto(message:
|
|
98
|
+
static isPhoto(message: Contexts.Message<any>): boolean {
|
|
99
99
|
return Filters.fileInline(message)?.type === "Image";
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
static isSticker(message:
|
|
102
|
+
static isSticker(message: Contexts.Message<any>): boolean {
|
|
103
103
|
return Filters.fileInline(message)?.type === "Sticker";
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
static isVideo(message:
|
|
106
|
+
static isVideo(message: Contexts.Message<any>): boolean {
|
|
107
107
|
return Filters.fileInline(message)?.type === "Video";
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
static isVoice(message:
|
|
110
|
+
static isVoice(message: Contexts.Message<any>): boolean {
|
|
111
111
|
return Filters.fileInline(message)?.type === "Voice";
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
static isGif(message:
|
|
114
|
+
static isGif(message: Contexts.Message<any>): boolean {
|
|
115
115
|
return Filters.fileInline(message)?.type === "Gif";
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
static isMusic(message:
|
|
118
|
+
static isMusic(message: Contexts.Message<any>): boolean {
|
|
119
119
|
return Filters.fileInline(message)?.type === "Music";
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
static isLocation(message:
|
|
122
|
+
static isLocation(message: Contexts.Message<any>): boolean {
|
|
123
123
|
return !!Filters.findKey(message.message, "location");
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
static isContact(message:
|
|
126
|
+
static isContact(message: Contexts.Message<any>): boolean {
|
|
127
127
|
return !!Filters.findKey(message.message, "contact_message");
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
static isPoll(message:
|
|
130
|
+
static isPoll(message: Contexts.Message<any>): boolean {
|
|
131
131
|
return !!Filters.findKey(message, "poll");
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
static isLive(message:
|
|
134
|
+
static isLive(message: Contexts.Message<any>): boolean {
|
|
135
135
|
return !!Filters.findKey(message, "live_data");
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
static isEvent(message:
|
|
138
|
+
static isEvent(message: Contexts.Message<any>): boolean {
|
|
139
139
|
return !!Filters.findKey(message, "event_data");
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
static isLength(length: number, object_guid?: string) {
|
|
143
|
-
return (message:
|
|
143
|
+
return (message: Contexts.Message<any>) => {
|
|
144
144
|
if (object_guid) {
|
|
145
145
|
if (object_guid !== message.object_guid) return false;
|
|
146
146
|
}
|
|
@@ -156,7 +156,7 @@ class Filters {
|
|
|
156
156
|
object_guid?: string,
|
|
157
157
|
length?: number,
|
|
158
158
|
) {
|
|
159
|
-
return (message:
|
|
159
|
+
return (message: Contexts.Message<any>) => {
|
|
160
160
|
if (object_guid) {
|
|
161
161
|
if (object_guid !== message.object_guid) return false;
|
|
162
162
|
}
|
|
@@ -170,7 +170,7 @@ class Filters {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
static equalCommand(text: string, object_guid?: string) {
|
|
173
|
-
return (message:
|
|
173
|
+
return (message: Contexts.Message<any>) => {
|
|
174
174
|
if (object_guid) {
|
|
175
175
|
if (object_guid !== message.object_guid) return false;
|
|
176
176
|
}
|
package/client/index.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import Client from "./client";
|
|
2
|
+
import Crypto from "./crypto";
|
|
2
3
|
import Filters from "./filters";
|
|
4
|
+
import Utils from "../utils/formater";
|
|
5
|
+
export * as Contexts from "./contexts";
|
|
6
|
+
export * from "../utils";
|
|
3
7
|
|
|
4
8
|
export default Client;
|
|
5
|
-
export { Filters };
|
|
9
|
+
export { Filters, Crypto, Utils };
|
|
@@ -27,8 +27,10 @@ async function builder(
|
|
|
27
27
|
const status_det = result.status_det;
|
|
28
28
|
|
|
29
29
|
if (status == "OK" && status_det == "OK") {
|
|
30
|
-
return result.data;
|
|
30
|
+
return { ...result.data, status_message: "OK" };
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
return { status_message: status_det };
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Logger } from "../../../utils";
|
|
1
2
|
import Client from "../../client";
|
|
2
3
|
|
|
3
4
|
type SystemVersions = { [key: string]: string };
|
|
@@ -25,6 +26,7 @@ interface BrowserInfo {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
async function getBrowser(
|
|
29
|
+
logger: Logger<Client>,
|
|
28
30
|
userAgent: string,
|
|
29
31
|
langCode: string,
|
|
30
32
|
appVersion: string,
|
|
@@ -32,13 +34,12 @@ async function getBrowser(
|
|
|
32
34
|
const deviceModelMatch = userAgent
|
|
33
35
|
.toLowerCase()
|
|
34
36
|
.match(/(opera|chrome|safari|firefox|msie|trident)\/(\d+)/);
|
|
35
|
-
let deviceModel = "Unknown";
|
|
36
37
|
|
|
37
38
|
if (!deviceModelMatch) {
|
|
38
|
-
|
|
39
|
-
} else {
|
|
40
|
-
deviceModel = `${deviceModelMatch[1]} ${deviceModelMatch[2]}`;
|
|
39
|
+
throw logger.error(`Cannot parse user-agent (${userAgent})`, "error");
|
|
41
40
|
}
|
|
41
|
+
|
|
42
|
+
const deviceModel = `${deviceModelMatch[1]} ${deviceModelMatch[2]}`;
|
|
42
43
|
|
|
43
44
|
let systemVersion = "Unknown";
|
|
44
45
|
for (const [key, value] of Object.entries(systemVersions)) {
|
|
@@ -65,10 +66,11 @@ async function registerDevice(this: Client): Promise<void> {
|
|
|
65
66
|
const result = await this.builder(
|
|
66
67
|
"registerDevice",
|
|
67
68
|
await getBrowser(
|
|
69
|
+
this.logger,
|
|
68
70
|
this.network.userAgent,
|
|
69
71
|
this.network.defaultPlatform.lang_code,
|
|
70
|
-
this.network.defaultPlatform.app_version
|
|
71
|
-
)
|
|
72
|
+
this.network.defaultPlatform.app_version,
|
|
73
|
+
),
|
|
72
74
|
);
|
|
73
75
|
|
|
74
76
|
return result;
|
|
@@ -10,7 +10,7 @@ interface InputType {
|
|
|
10
10
|
channel_type?: string;
|
|
11
11
|
sign_messages?: boolean;
|
|
12
12
|
is_restricted_content?: boolean;
|
|
13
|
-
chat_reaction_setting?:
|
|
13
|
+
chat_reaction_setting?: object;
|
|
14
14
|
chat_history_for_new_members?: ChatHistory;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -22,10 +22,10 @@ async function editChannelInfo(
|
|
|
22
22
|
channel_type?: string,
|
|
23
23
|
sign_messages?: boolean,
|
|
24
24
|
is_restricted_content?: boolean,
|
|
25
|
-
chat_reaction_setting?:
|
|
25
|
+
chat_reaction_setting?: object,
|
|
26
26
|
chat_history_for_new_members?: ChatHistory,
|
|
27
27
|
) {
|
|
28
|
-
|
|
28
|
+
const input: InputType = { channel_guid, updated_parameters: [] };
|
|
29
29
|
|
|
30
30
|
if (title) {
|
|
31
31
|
input.title = title;
|
|
@@ -19,7 +19,7 @@ async function editJoinLink(
|
|
|
19
19
|
expire_time?: number,
|
|
20
20
|
usage_limit?: number
|
|
21
21
|
) {
|
|
22
|
-
|
|
22
|
+
const input: InputType = { object_guid, join_link, update_parameters: [] };
|
|
23
23
|
|
|
24
24
|
if (typeof title === "string") {
|
|
25
25
|
input.update_parameters.push("title");
|
|
@@ -1,49 +1,51 @@
|
|
|
1
|
-
import Client from
|
|
1
|
+
import Client from "../../client";
|
|
2
2
|
|
|
3
3
|
async function deleteMessagebyCount(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
this: Client,
|
|
5
|
+
object_guid: string,
|
|
6
|
+
message_id: string,
|
|
7
|
+
count: number,
|
|
8
|
+
sort: "FromMin" | "FromMax" = "FromMax",
|
|
9
|
+
filter_type?:
|
|
10
|
+
| "Music"
|
|
11
|
+
| "File"
|
|
12
|
+
| "Media"
|
|
13
|
+
| "Voice"
|
|
14
|
+
| "Gif"
|
|
15
|
+
| "Groups"
|
|
16
|
+
| "Channels",
|
|
17
17
|
) {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const countLoop = Math.ceil(count / 25);
|
|
19
|
+
const tasks: Promise<unknown>[] = [];
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
for (let index = 1; index <= countLoop; index++) {
|
|
22
|
+
const res = await this.getMessages(
|
|
23
|
+
object_guid,
|
|
24
|
+
message_id,
|
|
25
|
+
"25",
|
|
26
|
+
sort,
|
|
27
|
+
filter_type,
|
|
28
|
+
);
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
if (!res.has_continue) break;
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
message_id = res.new_max_id;
|
|
33
|
+
const messagesID = res.messages.map(
|
|
34
|
+
(message: Record<string, unknown>) => message.message_id,
|
|
35
|
+
);
|
|
36
|
+
tasks.push(
|
|
37
|
+
this.deleteMessages(
|
|
38
|
+
object_guid,
|
|
39
|
+
index !== countLoop
|
|
40
|
+
? messagesID
|
|
41
|
+
: messagesID.slice(0, count - (countLoop - 1) * 25),
|
|
42
|
+
),
|
|
43
|
+
);
|
|
44
|
+
}
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
await Promise.allSettled(tasks);
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
return true;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
export default deleteMessagebyCount;
|
|
@@ -4,7 +4,7 @@ import Client from "../../client";
|
|
|
4
4
|
function onEditMessages(
|
|
5
5
|
this: Client,
|
|
6
6
|
object_guid: string,
|
|
7
|
-
callback: (message: Message) =>
|
|
7
|
+
callback: (message: Message<unknown>) => unknown,
|
|
8
8
|
) {
|
|
9
9
|
let state = Math.round(Date.now() / 1000) - 150;
|
|
10
10
|
const messagesIDs = new Set<string>();
|
|
@@ -9,14 +9,14 @@ async function userIsAdmin(
|
|
|
9
9
|
let nextStartID = null;
|
|
10
10
|
|
|
11
11
|
while (hasContinue) {
|
|
12
|
-
|
|
12
|
+
const result = object_guid.startsWith('g0')
|
|
13
13
|
? await this.getGroupAdminMembers(object_guid, nextStartID)
|
|
14
14
|
: await this.getChannelAdminMembers(object_guid, nextStartID);
|
|
15
15
|
|
|
16
16
|
hasContinue = result.has_continue;
|
|
17
17
|
nextStartID = result.next_start_id;
|
|
18
18
|
|
|
19
|
-
for (
|
|
19
|
+
for (const user of result.in_chat_members)
|
|
20
20
|
if (user_guid === user.member_guid) return true;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -2,6 +2,18 @@ import Client from "../../client";
|
|
|
2
2
|
|
|
3
3
|
type ChatHistoryOption = "Hidden" | "Visible";
|
|
4
4
|
|
|
5
|
+
type InputType = {
|
|
6
|
+
group_guid: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
slow_mode?: string;
|
|
10
|
+
event_messages?: boolean;
|
|
11
|
+
is_restricted_content?: boolean;
|
|
12
|
+
chat_reaction_setting?: { [key: string]: string | number } | null | undefined;
|
|
13
|
+
chat_history_for_new_members?: ChatHistoryOption;
|
|
14
|
+
updated_parameters: string[];
|
|
15
|
+
};
|
|
16
|
+
|
|
5
17
|
async function editGroupInfo(
|
|
6
18
|
this: Client,
|
|
7
19
|
group_guid: string,
|
|
@@ -14,7 +26,7 @@ async function editGroupInfo(
|
|
|
14
26
|
chat_history_for_new_members?: ChatHistoryOption,
|
|
15
27
|
) {
|
|
16
28
|
const updated_parameters: string[] = [];
|
|
17
|
-
const input_data:
|
|
29
|
+
const input_data: InputType = { group_guid, updated_parameters: [] };
|
|
18
30
|
|
|
19
31
|
if (title !== undefined) {
|
|
20
32
|
input_data.title = title;
|
|
@@ -6,18 +6,19 @@ async function sendDocument(
|
|
|
6
6
|
document: string | Buffer<ArrayBufferLike>,
|
|
7
7
|
caption?: string,
|
|
8
8
|
reply_to_message_id?: string,
|
|
9
|
-
auto_delete?: number
|
|
9
|
+
auto_delete?: number,
|
|
10
10
|
) {
|
|
11
11
|
return await this.sendMessage(
|
|
12
12
|
object_guid,
|
|
13
13
|
caption,
|
|
14
14
|
reply_to_message_id,
|
|
15
15
|
document,
|
|
16
|
+
undefined,
|
|
16
17
|
"File",
|
|
17
18
|
undefined,
|
|
18
19
|
undefined,
|
|
19
20
|
undefined,
|
|
20
|
-
auto_delete
|
|
21
|
+
auto_delete,
|
|
21
22
|
);
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -25,7 +25,7 @@ async function sendFileInline(
|
|
|
25
25
|
reply_to_message_id?: string,
|
|
26
26
|
auto_delete?: number,
|
|
27
27
|
) {
|
|
28
|
-
let input: Record<string,
|
|
28
|
+
let input: Record<string, unknown> = {
|
|
29
29
|
object_guid,
|
|
30
30
|
rnd: Math.floor(Math.random() * 1e6 + 1),
|
|
31
31
|
reply_to_message_id,
|
|
@@ -6,19 +6,20 @@ async function sendGif(
|
|
|
6
6
|
gif: string | Buffer<ArrayBufferLike>,
|
|
7
7
|
caption?: string,
|
|
8
8
|
reply_to_message_id?: string,
|
|
9
|
-
auto_delete?: number
|
|
9
|
+
auto_delete?: number,
|
|
10
10
|
) {
|
|
11
11
|
return await this.sendMessage(
|
|
12
12
|
object_guid,
|
|
13
13
|
caption,
|
|
14
14
|
reply_to_message_id,
|
|
15
15
|
gif,
|
|
16
|
+
undefined,
|
|
16
17
|
"Gif",
|
|
17
18
|
undefined,
|
|
18
19
|
true,
|
|
19
20
|
undefined,
|
|
20
|
-
auto_delete
|
|
21
|
+
auto_delete,
|
|
21
22
|
);
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export default sendGif;
|
|
25
|
+
export default sendGif;
|
|
@@ -13,6 +13,7 @@ async function sendMessage(
|
|
|
13
13
|
text: string | null = null,
|
|
14
14
|
reply_to_message_id: string | null = null,
|
|
15
15
|
file_inline: Buffer | string | null = null,
|
|
16
|
+
aux_data?: { button_id: string },
|
|
16
17
|
type: string = "File",
|
|
17
18
|
is_spoil: boolean = false,
|
|
18
19
|
thumb: boolean | string = true,
|
|
@@ -31,7 +32,7 @@ async function sendMessage(
|
|
|
31
32
|
let fileName: string | null = null;
|
|
32
33
|
let audio_data: any;
|
|
33
34
|
|
|
34
|
-
let input: Record<string,
|
|
35
|
+
let input: Record<string, unknown> = {
|
|
35
36
|
object_guid,
|
|
36
37
|
rnd: Math.floor(Math.random() * 1e6 + 1),
|
|
37
38
|
reply_to_message_id,
|
|
@@ -39,6 +40,8 @@ async function sendMessage(
|
|
|
39
40
|
|
|
40
41
|
if (text) input = { ...input, ...Markdown.toMetadata(text) };
|
|
41
42
|
|
|
43
|
+
if (aux_data) input["aux_data"] = aux_data;
|
|
44
|
+
|
|
42
45
|
if (file_inline) {
|
|
43
46
|
if (typeof file_inline === "string") {
|
|
44
47
|
fileName = file_inline;
|
|
@@ -70,8 +73,9 @@ async function sendMessage(
|
|
|
70
73
|
thumb = false;
|
|
71
74
|
if (audio_info) {
|
|
72
75
|
if (!optionalMusicMetadata) {
|
|
73
|
-
return
|
|
76
|
+
return this.logger.error(
|
|
74
77
|
"music-metadata module is not installed. Some features may be disabled.",
|
|
78
|
+
"error",
|
|
75
79
|
);
|
|
76
80
|
}
|
|
77
81
|
|
|
@@ -121,13 +125,11 @@ async function sendMessage(
|
|
|
121
125
|
const result = await this.builder("sendMessage", input);
|
|
122
126
|
|
|
123
127
|
if (auto_delete) {
|
|
124
|
-
|
|
128
|
+
setTimeout(async () => {
|
|
125
129
|
await this.deleteMessages(
|
|
126
130
|
result.message_update.object_guid,
|
|
127
131
|
result.message_update.message_id,
|
|
128
132
|
);
|
|
129
|
-
|
|
130
|
-
clearTimeout(res);
|
|
131
133
|
}, auto_delete * 1000);
|
|
132
134
|
}
|
|
133
135
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Client from "../../client";
|
|
2
|
+
|
|
3
|
+
async function sendMessageAPICall(
|
|
4
|
+
this: Client,
|
|
5
|
+
text: string,
|
|
6
|
+
object_guid: string,
|
|
7
|
+
message_id: string,
|
|
8
|
+
aux_data: { button_id: string },
|
|
9
|
+
) {
|
|
10
|
+
return await this.builder("sendMessageAPICall", {
|
|
11
|
+
text,
|
|
12
|
+
object_guid,
|
|
13
|
+
message_id,
|
|
14
|
+
aux_data,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default sendMessageAPICall;
|
|
@@ -8,18 +8,19 @@ async function sendMusic(
|
|
|
8
8
|
reply_to_message_id?: string,
|
|
9
9
|
is_spoil?: boolean,
|
|
10
10
|
audio_info?: boolean,
|
|
11
|
-
auto_delete?: number
|
|
11
|
+
auto_delete?: number,
|
|
12
12
|
) {
|
|
13
13
|
return await this.sendMessage(
|
|
14
14
|
object_guid,
|
|
15
15
|
caption,
|
|
16
16
|
reply_to_message_id,
|
|
17
17
|
music,
|
|
18
|
+
undefined,
|
|
18
19
|
"Music",
|
|
19
20
|
is_spoil,
|
|
20
21
|
undefined,
|
|
21
22
|
audio_info,
|
|
22
|
-
auto_delete
|
|
23
|
+
auto_delete,
|
|
23
24
|
);
|
|
24
25
|
}
|
|
25
26
|
|
|
@@ -7,18 +7,19 @@ async function sendPhoto(
|
|
|
7
7
|
text?: string,
|
|
8
8
|
reply_id?: string,
|
|
9
9
|
is_spoil?: boolean,
|
|
10
|
-
auto_delete?: number
|
|
10
|
+
auto_delete?: number,
|
|
11
11
|
) {
|
|
12
12
|
return this.sendMessage(
|
|
13
13
|
object_guid,
|
|
14
14
|
text,
|
|
15
15
|
reply_id,
|
|
16
16
|
photo,
|
|
17
|
+
undefined,
|
|
17
18
|
"Image",
|
|
18
19
|
is_spoil,
|
|
19
20
|
true,
|
|
20
21
|
false,
|
|
21
|
-
auto_delete
|
|
22
|
+
auto_delete,
|
|
22
23
|
);
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -5,18 +5,20 @@ async function sendText(
|
|
|
5
5
|
object_guid: string,
|
|
6
6
|
text: string,
|
|
7
7
|
reply_id?: string,
|
|
8
|
-
|
|
8
|
+
aux_data?: { button_id: string },
|
|
9
|
+
auto_delete?: number,
|
|
9
10
|
) {
|
|
10
11
|
return await this.sendMessage(
|
|
11
12
|
object_guid,
|
|
12
13
|
text,
|
|
13
14
|
reply_id,
|
|
14
15
|
null,
|
|
16
|
+
aux_data,
|
|
15
17
|
undefined,
|
|
16
18
|
false,
|
|
17
19
|
false,
|
|
18
20
|
false,
|
|
19
|
-
auto_delete
|
|
21
|
+
auto_delete,
|
|
20
22
|
);
|
|
21
23
|
}
|
|
22
24
|
|