rubika 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bot/bot.ts +1 -1
- package/bot/methods/advanced/builder.ts +6 -6
- package/bot/methods/files/uploadFile.ts +1 -1
- package/bot/methods/utilities/webhook.ts +3 -1
- package/bot/network.ts +1 -1
- package/client/client.ts +2 -2
- package/client/methods/auth/registerDevice.ts +1 -1
- package/client/methods/messages/sendMessage.ts +2 -2
- package/client/methods/utilities/start.ts +1 -1
- package/client/methods/utilities/thumbnail.ts +5 -5
- package/client/network/api.ts +1 -1
- package/client/network/file.ts +2 -2
- package/package.json +1 -1
package/bot/bot.ts
CHANGED
|
@@ -14,14 +14,14 @@ async function builder(
|
|
|
14
14
|
|
|
15
15
|
const response: any = await this.network.request(method, input);
|
|
16
16
|
|
|
17
|
-
if (response?.status
|
|
18
|
-
|
|
19
|
-
`[builder] error in request ${method}:\n ${JSON.stringify(response, null, 2)}`,
|
|
20
|
-
"error",
|
|
21
|
-
);
|
|
17
|
+
if (response?.status === "OK") {
|
|
18
|
+
return response.data;
|
|
22
19
|
}
|
|
23
20
|
|
|
24
|
-
|
|
21
|
+
this.logger.error(
|
|
22
|
+
`[builder] error in request ${method}:\n ${JSON.stringify(response, null, 2)}`,
|
|
23
|
+
"error",
|
|
24
|
+
);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export default builder;
|
|
@@ -38,12 +38,14 @@ async function setupWebhook(
|
|
|
38
38
|
},
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
+
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
42
|
+
|
|
41
43
|
// set-endpoints
|
|
42
44
|
for (const update of updates) {
|
|
43
45
|
const res = await this.updateBotEndpoints(url, update);
|
|
44
46
|
|
|
45
47
|
if (res.status !== "Done") {
|
|
46
|
-
|
|
48
|
+
this.logger.error(
|
|
47
49
|
`[setupWebhook] status updateBotEndpoints is ${res.status} for update: ${update}`,
|
|
48
50
|
"warn",
|
|
49
51
|
);
|
package/bot/network.ts
CHANGED
package/client/client.ts
CHANGED
|
@@ -73,7 +73,7 @@ export default class Client extends Methods {
|
|
|
73
73
|
handler: maybeHandler,
|
|
74
74
|
});
|
|
75
75
|
} else {
|
|
76
|
-
|
|
76
|
+
return new Error("Invalid arguments for on()");
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -108,7 +108,7 @@ export default class Client extends Methods {
|
|
|
108
108
|
prefix,
|
|
109
109
|
});
|
|
110
110
|
} else {
|
|
111
|
-
|
|
111
|
+
return new Error("Invalid arguments for command()");
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
}
|
|
@@ -35,7 +35,7 @@ async function getBrowser(
|
|
|
35
35
|
let deviceModel = "Unknown";
|
|
36
36
|
|
|
37
37
|
if (!deviceModelMatch) {
|
|
38
|
-
|
|
38
|
+
return new Error(`Cannot parse user-agent (${userAgent})`);
|
|
39
39
|
} else {
|
|
40
40
|
deviceModel = `${deviceModelMatch[1]} ${deviceModelMatch[2]}`;
|
|
41
41
|
}
|
|
@@ -48,7 +48,7 @@ async function sendMessage(
|
|
|
48
48
|
}
|
|
49
49
|
file_inline = await fs.promises.readFile(fileName);
|
|
50
50
|
} else if (!Buffer.isBuffer(file_inline)) {
|
|
51
|
-
|
|
51
|
+
return this.logger.error(
|
|
52
52
|
"File argument must be a file path or bytes",
|
|
53
53
|
"warn",
|
|
54
54
|
);
|
|
@@ -70,7 +70,7 @@ async function sendMessage(
|
|
|
70
70
|
thumb = false;
|
|
71
71
|
if (audio_info) {
|
|
72
72
|
if (!optionalMusicMetadata) {
|
|
73
|
-
|
|
73
|
+
return new Error(
|
|
74
74
|
"music-metadata module is not installed. Some features may be disabled.",
|
|
75
75
|
);
|
|
76
76
|
}
|
|
@@ -16,7 +16,7 @@ async function start(this: Client): Promise<void> {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
try {
|
|
19
|
-
if (!this.auth)
|
|
19
|
+
if (!this.auth) return Error("[start] Error auth is not set");
|
|
20
20
|
this.key = Buffer.from(Crypto.passphrase(this.auth), "utf8");
|
|
21
21
|
this.decode_auth = Crypto.decode_auth(this.auth);
|
|
22
22
|
const result = await this.getUserInfo();
|
|
@@ -8,7 +8,7 @@ const ffmpeg = optionalImport<typeof import("fluent-ffmpeg")>("fluent-ffmpeg");
|
|
|
8
8
|
class ThumbnailGenerator {
|
|
9
9
|
static async getTime(videoPath: string): Promise<number> {
|
|
10
10
|
if (!ffmpeg) {
|
|
11
|
-
|
|
11
|
+
return new Error(
|
|
12
12
|
"fluent-ffmpeg module is not installed. Some features may be disabled.",
|
|
13
13
|
);
|
|
14
14
|
}
|
|
@@ -28,7 +28,7 @@ class ThumbnailGenerator {
|
|
|
28
28
|
|
|
29
29
|
static async fromVideo(videoPath: string): Promise<string> {
|
|
30
30
|
if (!ffmpeg) {
|
|
31
|
-
|
|
31
|
+
return new Error(
|
|
32
32
|
"fluent-ffmpeg module is not installed. Some features may be disabled.",
|
|
33
33
|
);
|
|
34
34
|
}
|
|
@@ -57,7 +57,7 @@ class ThumbnailGenerator {
|
|
|
57
57
|
return base64Thumbnail;
|
|
58
58
|
} catch (error) {
|
|
59
59
|
console.error("Error generating video thumbnail:", error);
|
|
60
|
-
|
|
60
|
+
return error;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -66,7 +66,7 @@ class ThumbnailGenerator {
|
|
|
66
66
|
width: number = 320,
|
|
67
67
|
): Promise<string> {
|
|
68
68
|
if (!sharp) {
|
|
69
|
-
|
|
69
|
+
return new Error(
|
|
70
70
|
"sharp module is not installed. Some features may be disabled.",
|
|
71
71
|
);
|
|
72
72
|
}
|
|
@@ -76,7 +76,7 @@ class ThumbnailGenerator {
|
|
|
76
76
|
return buffer.toString("base64");
|
|
77
77
|
} catch (error) {
|
|
78
78
|
console.error("Error generating image thumbnail:", error);
|
|
79
|
-
|
|
79
|
+
return error;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
}
|
package/client/network/api.ts
CHANGED
|
@@ -86,7 +86,7 @@ export async function sendRequest(network: Network, url: string, data: any) {
|
|
|
86
86
|
|
|
87
87
|
await network.delay(1000);
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
return network.client.logger.error(
|
|
90
90
|
`[request] Failed after ${MAX_ATTEMPTS} attempts: ${url}`,
|
|
91
91
|
"warn",
|
|
92
92
|
);
|
package/client/network/file.ts
CHANGED
|
@@ -8,7 +8,7 @@ export async function uploadFile(
|
|
|
8
8
|
chunkSize: number = 1048576,
|
|
9
9
|
): Promise<any> {
|
|
10
10
|
if (!fs.existsSync(filePath))
|
|
11
|
-
|
|
11
|
+
return new Error("File not found in the given path");
|
|
12
12
|
|
|
13
13
|
const stat = await fs.promises.stat(filePath);
|
|
14
14
|
const fileSize = stat.size;
|
|
@@ -81,7 +81,7 @@ export async function uploadFile(
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
return new Error("Upload failed completely.");
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
export async function download(
|