catto.js 1.3.4 → 1.3.6
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.js +0 -1
- package/Oracle.js +40 -0
- package/TelegramChannel.js +42 -22
- package/index.js +2 -1
- package/package.json +5 -3
package/Bot.js
CHANGED
|
@@ -50,7 +50,6 @@ module.exports = class extends EventEmitter {
|
|
|
50
50
|
this.client = new Discord.Client(opts);
|
|
51
51
|
if (this.options.sharded) {
|
|
52
52
|
this.client.cluster = new ClusterClient(this.client);
|
|
53
|
-
this.client.removeAllListeners("ready");
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
this.currentStatus = void 0;
|
package/Oracle.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var common = null;
|
|
2
|
+
|
|
3
|
+
module.exports = class {
|
|
4
|
+
constructor(options, client) {
|
|
5
|
+
this.options = Object.assign({
|
|
6
|
+
"config": "config",
|
|
7
|
+
"profile": "default"
|
|
8
|
+
}, options || {});
|
|
9
|
+
if (client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
} else {
|
|
12
|
+
common = require("oci-common");
|
|
13
|
+
this.client = {};
|
|
14
|
+
this.client.provider = new common.ConfigFileAuthenticationDetailsProvider(this.options.config, this.options.profile);
|
|
15
|
+
this.client.signer = new common.DefaultRequestSigner(this.client.provider);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async fetch(uri, options) {
|
|
19
|
+
if (!options.headers) {
|
|
20
|
+
options.headers = {};
|
|
21
|
+
}
|
|
22
|
+
options.uri = uri;
|
|
23
|
+
if (options.body) {
|
|
24
|
+
if (typeof options.body === "object" && !options.headers["Content-Type"]) {
|
|
25
|
+
options.headers["Content-Type"] = "application/json";
|
|
26
|
+
options.body = JSON.stringify(options.body);
|
|
27
|
+
}
|
|
28
|
+
if (!options.headers["Content-Length"]) {
|
|
29
|
+
options.headers["Content-Length"] = options.body.length;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
var headers = options.headers;
|
|
33
|
+
options.headers = new Headers;
|
|
34
|
+
for (var key in headers) {
|
|
35
|
+
options.headers.set(key, headers[key]);
|
|
36
|
+
}
|
|
37
|
+
await this.client.signer.signHttpRequest(options);
|
|
38
|
+
return fetch(options.uri, options);
|
|
39
|
+
}
|
|
40
|
+
};
|
package/TelegramChannel.js
CHANGED
|
@@ -31,32 +31,48 @@ module.exports = class {
|
|
|
31
31
|
data = data.data;
|
|
32
32
|
}
|
|
33
33
|
if (data.media && data.media.length) {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
if (data.media[0].type == "animation") {
|
|
35
|
+
await this.bot.client.telegram.sendAnimation(this.id, data.media[0].url, Object.assign({
|
|
36
|
+
"reply_parameters": data.replyParameters ? {
|
|
37
|
+
"message_id": data.replyParameters.message.id,
|
|
38
|
+
"chat_id": (data.replyParameters.channel ? data.replyParameters.channel.id : this.id),
|
|
39
|
+
"allow_sending_without_reply": !1
|
|
40
|
+
} : void 0,
|
|
41
|
+
"reply_markup": data.replyMarkup ? data.replyMarkup : {
|
|
42
|
+
"remove_keyboard": !0
|
|
43
|
+
},
|
|
44
|
+
"caption": data.content,
|
|
45
|
+
"parse_mode": data.parseMode,
|
|
46
|
+
"show_caption_above_media": data.textAbove
|
|
47
|
+
}, data.extra));
|
|
48
|
+
} else {
|
|
49
|
+
await this.bot.client.telegram.sendMediaGroup(this.id, data.media.map((media, index) => {
|
|
50
|
+
if (index < 1) {
|
|
51
|
+
return {
|
|
52
|
+
"type": (media.type == "image") ? "photo" : media.type,
|
|
53
|
+
"media": media.url,
|
|
54
|
+
"caption": data.content,
|
|
55
|
+
"parse_mode": data.parseMode,
|
|
56
|
+
"show_caption_above_media": data.textAbove
|
|
57
|
+
};
|
|
58
|
+
}
|
|
36
59
|
return {
|
|
37
60
|
"type": (media.type == "image") ? "photo" : media.type,
|
|
38
61
|
"media": media.url,
|
|
39
|
-
"caption": data.content,
|
|
40
|
-
"parse_mode": data.parseMode,
|
|
41
62
|
"show_caption_above_media": data.textAbove
|
|
42
63
|
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"reply_markup": data.replyMarkup ? data.replyMarkup : {
|
|
56
|
-
"remove_keyboard": !0
|
|
57
|
-
},
|
|
58
|
-
"parse_mode": data.parseMode
|
|
59
|
-
}, data.extra));
|
|
64
|
+
}), Object.assign({
|
|
65
|
+
"reply_parameters": data.replyParameters ? {
|
|
66
|
+
"message_id": data.replyParameters.message.id,
|
|
67
|
+
"chat_id": (data.replyParameters.channel ? data.replyParameters.channel.id : this.id),
|
|
68
|
+
"allow_sending_without_reply": !1
|
|
69
|
+
} : void 0,
|
|
70
|
+
"reply_markup": data.replyMarkup ? data.replyMarkup : {
|
|
71
|
+
"remove_keyboard": !0
|
|
72
|
+
},
|
|
73
|
+
"parse_mode": data.parseMode
|
|
74
|
+
}, data.extra));
|
|
75
|
+
}
|
|
60
76
|
} else {
|
|
61
77
|
await this.bot.client.telegram.sendMessage(this.id, data.content, Object.assign({
|
|
62
78
|
"reply_parameters": data.replyParameters ? {
|
|
@@ -66,7 +82,8 @@ module.exports = class {
|
|
|
66
82
|
} : void 0,
|
|
67
83
|
"reply_markup": data.replyMarkup ? data.replyMarkup : {
|
|
68
84
|
"remove_keyboard": !0
|
|
69
|
-
}
|
|
85
|
+
},
|
|
86
|
+
"parse_mode": data.parseMode
|
|
70
87
|
}, data.extra));
|
|
71
88
|
}
|
|
72
89
|
if (this.typingLoop !== null) {
|
|
@@ -104,3 +121,6 @@ module.exports = class {
|
|
|
104
121
|
|
|
105
122
|
|
|
106
123
|
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var mod = {};
|
|
2
2
|
var version = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
|
|
3
|
-
var parts = ["random", "Server", "HTML", "request", "utils", "GitHub", "Base64", "Bitfield", "Application", "TelegramBot", "TelegramMessage", "TelegramChannel", "TelegramMessageBuilder", "TelegramInteraction", "TelegramPaymentInProgress", "TelegramPayment", "TelegramUser", "TelegramFile"];
|
|
3
|
+
var parts = ["random", "Server", "HTML", "request", "utils", "GitHub", "Base64", "Bitfield", "Application", "TelegramBot", "TelegramMessage", "TelegramChannel", "TelegramMessageBuilder", "TelegramInteraction", "TelegramPaymentInProgress", "TelegramPayment", "TelegramUser", "TelegramFile", "Oracle"];
|
|
4
4
|
if (version >= 18.20) {
|
|
5
5
|
parts.push("Bot", "MessageBuilder");
|
|
6
6
|
}
|
|
@@ -11,3 +11,4 @@ parts.forEach(part => {
|
|
|
11
11
|
mod[part] = require(`./${part}`);
|
|
12
12
|
});
|
|
13
13
|
module.exports = mod;
|
|
14
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "catto.js",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"description": "Universal module for everything.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"random",
|
|
31
31
|
"telegram",
|
|
32
32
|
"api",
|
|
33
|
-
"telegraf"
|
|
33
|
+
"telegraf",
|
|
34
|
+
"oracle"
|
|
34
35
|
],
|
|
35
36
|
"author": "topcatto",
|
|
36
37
|
"license": "ISC",
|
|
@@ -40,13 +41,14 @@
|
|
|
40
41
|
"homepage": "https://github.com/BoryaGames/catto.js#readme",
|
|
41
42
|
"dependencies": {
|
|
42
43
|
"body-parser": "^1.20.2",
|
|
43
|
-
"discord-hybrid-sharding": "^
|
|
44
|
+
"discord-hybrid-sharding": "^3.0.0",
|
|
44
45
|
"discord.js": "^14.22.1",
|
|
45
46
|
"ejs": "^3.1.10",
|
|
46
47
|
"express": "^4.19.2",
|
|
47
48
|
"express-session": "^1.18.0",
|
|
48
49
|
"express-ws": "^5.0.2",
|
|
49
50
|
"node-fetch": "^3.3.2",
|
|
51
|
+
"oci-common": "^2.118.0",
|
|
50
52
|
"session-file-store": "^1.5.0",
|
|
51
53
|
"telegraf": "^4.16.3",
|
|
52
54
|
"tweetnacl": "^1.0.3"
|