gj-boomlings-api 2.0.0 → 2.0.2
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 +1 -1
- package/README.md +2 -9
- package/functions/blockUser.js +8 -2
- package/functions/deleteAccountPost.js +11 -5
- package/functions/deleteComment.js +14 -7
- package/functions/deleteLevel.js +13 -7
- package/functions/dlLevel.js +219 -1
- package/functions/dlMessage.js +23 -5
- package/functions/getAccountPosts.js +23 -4
- package/functions/getBlockedList.js +20 -6
- package/functions/getCommentHistory.js +35 -6
- package/functions/getComments.js +31 -3
- package/functions/getCreatorScores.js +18 -0
- package/functions/getDailyLevel.js +5 -1
- package/functions/getFriendsList.js +21 -6
- package/functions/getGauntlets.js +11 -0
- package/functions/getLevelByID.js +43 -0
- package/functions/getLevelScores.js +32 -9
- package/functions/getMapPacks.js +16 -0
- package/functions/getMessages.js +22 -5
- package/functions/getOfficialSongInfo.js +15 -4
- package/functions/getProfile.js +198 -1
- package/functions/getSongInfo.js +21 -6
- package/functions/getSongsLibrary.js +107 -1
- package/functions/getTab.js +8 -0
- package/functions/getTop100.js +4 -0
- package/functions/getTopLists.js +5 -0
- package/functions/getUserLevels.js +11 -5
- package/functions/getWeeklyDemon.js +4 -0
- package/functions/reportLevel.js +5 -0
- package/functions/searchLevels.js +6 -0
- package/functions/searchLists.js +24 -0
- package/functions/unblockUser.js +7 -1
- package/functions/updateLevelDesc.js +11 -4
- package/functions/uploadAccountPost.js +10 -3
- package/functions/uploadComment.js +15 -6
- package/functions/uploadMessage.js +18 -9
- package/gjReq.js +18 -1
- package/index.js +36 -2
- package/misc/GJDecode.js +221 -1
- package/misc/colors.json +109 -1
- package/misc/gauntlets.json +36 -1
- package/misc/officialsongs.json +248 -1
- package/misc/rgbToHEX.js +17 -1
- package/package.json +1 -1
- package/xor.js +11 -1
|
@@ -1,4 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} ScoresUser
|
|
3
|
+
* @property {string} name - The player's username.
|
|
4
|
+
* @property {number} playerID - The player's player ID.
|
|
5
|
+
* @property {number} accountID - The player's account ID.
|
|
6
|
+
* @property {number} rank - The player's ranking on the leaderboard.
|
|
7
|
+
* @property {number} stars - The amount of stars the player has.
|
|
8
|
+
* @property {number} diamonds - The amount of diamonds the player has.
|
|
9
|
+
* @property {number} secretCoins - The amount of secret coins the player has.
|
|
10
|
+
* @property {number} userCoins - The amount of user coins the player has.
|
|
11
|
+
* @property {number} demons - The amount of demons the player has completed.
|
|
12
|
+
* @property {number} moons - The amount of moons the player has.
|
|
13
|
+
* @property {number} creatorPoints - The amount of creator points the player has.
|
|
14
|
+
*/
|
|
1
15
|
module.exports = {
|
|
16
|
+
/**
|
|
17
|
+
* Fetches the player leaderboard based on the amount of creator points.
|
|
18
|
+
* @returns {ScoresUser[]}
|
|
19
|
+
*/
|
|
2
20
|
getCreatorScores: async function () {
|
|
3
21
|
let GJDecode = require("../misc/GJDecode");
|
|
4
22
|
const { decodeScoresUser } = new GJDecode;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
+
/**
|
|
3
|
+
* Gets the current daily level.
|
|
4
|
+
* @returns {import("./dlLevel").Level}
|
|
5
|
+
*/
|
|
2
6
|
getDailyLevel: async function () {
|
|
3
|
-
const { dlLevel } = require("./dlLevel")
|
|
7
|
+
const { dlLevel } = require("./dlLevel");
|
|
4
8
|
let res = await dlLevel(-1);
|
|
5
9
|
return res;
|
|
6
10
|
}
|
|
@@ -1,14 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} Friend
|
|
3
|
+
* @property {string} username - The friend's username.
|
|
4
|
+
* @property {number} playerID - The friend's player ID.
|
|
5
|
+
* @property {number} accountID - The friend's account ID.
|
|
6
|
+
* @property {string} color1 - The HEX code of the friend's primary color.
|
|
7
|
+
* @property {string} color2 - The HEX code of the friend's secondary color.
|
|
8
|
+
* @property {string} messages - The current state of messaging the friend. Returns "all" if anyone can message the person, "friends" if it's limited to friends, and "none" if no one can.
|
|
9
|
+
*/
|
|
1
10
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Gets the list of a user's friends.
|
|
13
|
+
* @param {string} username - The user's username or player ID.
|
|
14
|
+
* @param {string} password - The user's password.
|
|
15
|
+
* @returns {Friend[]}
|
|
16
|
+
*/
|
|
17
|
+
getFriendsList: async function (username, password) {
|
|
18
|
+
if (!username) throw new Error("Please provide a player ID or username!");
|
|
19
|
+
if (!password) throw new Error("Please provide a password!");
|
|
5
20
|
|
|
6
21
|
const { gjReq } = require("../gjReq");
|
|
7
22
|
const XOR = require("../xor");
|
|
8
23
|
const xor = new XOR;
|
|
9
24
|
|
|
10
25
|
let search = await gjReq("getGJUsers20", {
|
|
11
|
-
str:
|
|
26
|
+
str: username,
|
|
12
27
|
secret: "Wmfd2893gb7"
|
|
13
28
|
});
|
|
14
29
|
if (search.data == -1) return [];
|
|
@@ -16,7 +31,7 @@ module.exports = {
|
|
|
16
31
|
|
|
17
32
|
const data = {
|
|
18
33
|
accountID: accID,
|
|
19
|
-
gjp: xor.encrypt(
|
|
34
|
+
gjp: xor.encrypt(password, 37526),
|
|
20
35
|
secret: "Wmfd2893gb7"
|
|
21
36
|
}
|
|
22
37
|
|
|
@@ -30,7 +45,7 @@ module.exports = {
|
|
|
30
45
|
const { rgbToHEX } = require("../misc/rgbToHEX");
|
|
31
46
|
|
|
32
47
|
players.forEach(p => {
|
|
33
|
-
let s=p.split(":");
|
|
48
|
+
let s = p.split(":");
|
|
34
49
|
let username = s[1];
|
|
35
50
|
let playerID = s[3];
|
|
36
51
|
let p1 = s[7];
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} Gauntlet
|
|
3
|
+
* @property {string} name - The gauntlet's name.
|
|
4
|
+
* @property {number} id - The gauntlet's ID.
|
|
5
|
+
* @property {Array<Number>} levels - The list of level IDs in the gauntlet.
|
|
6
|
+
*/
|
|
1
7
|
module.exports = {
|
|
8
|
+
/**
|
|
9
|
+
* Gets the list of gauntlets.
|
|
10
|
+
* @returns {Gauntlet[]}
|
|
11
|
+
*/
|
|
2
12
|
getGauntlets: async function () {
|
|
3
13
|
const glIDs = require("../misc/gauntlets.json");
|
|
4
14
|
const { gjReq } = require("../gjReq");
|
|
@@ -15,6 +25,7 @@ module.exports = {
|
|
|
15
25
|
}
|
|
16
26
|
result.push({
|
|
17
27
|
name: `${glIDs[g.split(":")[1]]} Gauntlet`,
|
|
28
|
+
id: Number(g.split(":")[1]),
|
|
18
29
|
levels: list
|
|
19
30
|
});
|
|
20
31
|
})
|
|
@@ -1,4 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} Song
|
|
3
|
+
* @property {string} name - The song's name.
|
|
4
|
+
* @property {number} id - The song's ID.
|
|
5
|
+
* @property {string} artist - The song artist.
|
|
6
|
+
* @property {number} artistId - The song artist's ID on Newgrounds.
|
|
7
|
+
* @property {number} fileSize - The song's file size in megabytes.
|
|
8
|
+
* @property {string} link - The direct link to download the song file.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {Object} Level
|
|
13
|
+
* @property {number} id - The level's ID.
|
|
14
|
+
* @property {string} name - The level's name.
|
|
15
|
+
* @property {string} description - The level's description.
|
|
16
|
+
* @property {string} levelVersion - The level's current version number.
|
|
17
|
+
* @property {number} playerID - The level uploader's player ID.
|
|
18
|
+
* @property {string} difficulty - The level's difficulty.
|
|
19
|
+
* @property {number} stars - The amount of given stars when completing the level.
|
|
20
|
+
* @property {number} downloads - The amount of times the level has been downloaded.
|
|
21
|
+
* @property {number} likes - The amount of likes the level has.
|
|
22
|
+
* @property {boolean} disliked - Whether the level is disliked (i.e. if the likes count is less than 0).
|
|
23
|
+
* @property {string} length - The level's length.
|
|
24
|
+
* @property {boolean} demon - Whether the level is a demon.
|
|
25
|
+
* @property {boolean} featured - Whether the level is featured.
|
|
26
|
+
* @property {boolean} epic - Whether the level is epic-rated.
|
|
27
|
+
* @property {string|boolean} rating - Primarily used for new 2.2 ratings. Returns either "epic", "legendary", "mythic", or `false` if the level's rating is lower than epic.
|
|
28
|
+
* @property {number} objects - The amount of objects the level has (inaccurate because it could be circumvented, and caps at 65,535).
|
|
29
|
+
* @property {number} starsRequested - The amount of stars the uploader requested for this level.
|
|
30
|
+
* @property {string} gameVersion - The version of the game used to upload the current version of the level. Returns "Pre-1.7" if the level was last updated in 1.6 or earlier.
|
|
31
|
+
* @property {number} copiedID - The original level's ID if this level was copied. Returns 0 if the level is original on itself.
|
|
32
|
+
* @property {boolean} large - Whether the level is considered "large" (i.e. has more than 40k objects).
|
|
33
|
+
* @property {boolean} twoPlayer - Whether the level can be played by two people.
|
|
34
|
+
* @property {number} coins - The amount of coins the level has.
|
|
35
|
+
* @property {boolean} verifiedCoins - Whether the coins are verified.
|
|
36
|
+
* @property {string} creator - The level uploader's username.
|
|
37
|
+
* @property {Song} song - The main song used in the level.
|
|
38
|
+
*/
|
|
1
39
|
module.exports = {
|
|
40
|
+
/**
|
|
41
|
+
* Gets a level by its ID. Works considerably faster than dlLevel(), yet lacks the last update/upload date, password, LDM, accurate object count, SFX and additional songs (if any).
|
|
42
|
+
* @param {number} id - The level's ID.
|
|
43
|
+
* @returns {Level}
|
|
44
|
+
*/
|
|
2
45
|
getLevelByID: async function (id) {
|
|
3
46
|
if (isNaN(id)) throw new Error("Please provide a valid level ID!");
|
|
4
47
|
const { gjReq } = require("../gjReq");
|
|
@@ -1,16 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} LevelScore
|
|
3
|
+
* @property {string} username - The player's username.
|
|
4
|
+
* @property {number} playerID - The player's player ID.
|
|
5
|
+
* @property {number} accountID - The player's account ID.
|
|
6
|
+
* @property {number} rank - The player's ranking on the leaderboard.
|
|
7
|
+
* @property {string} color1 - The player's primary color.
|
|
8
|
+
* @property {string} color2 - The player's secondary color.
|
|
9
|
+
* @property {string} iconID - The player's icon ID.
|
|
10
|
+
* @property {string} iconType - The player's selected game mode to be displayed as an icon.
|
|
11
|
+
* @property {string} glow - Whether the player's icon has the "glow" feature enabled.
|
|
12
|
+
* @property {string} percent - The record's percentage.
|
|
13
|
+
* @property {string} coins - The amount of coins collected.
|
|
14
|
+
* @property {string} age - How long ago the record was published.
|
|
15
|
+
*/
|
|
1
16
|
module.exports = {
|
|
2
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Fetches leaderboards from a specified level.
|
|
19
|
+
* @param {number} level - The level to fetch leaderboards from.
|
|
20
|
+
* @param {("week"|"top"|"player")} type - The leaderboard type. Possible types: \"week\", \"top\", \"friends\".
|
|
21
|
+
* @param {string} username - The user's username or player ID. For whatever reason, RobTop made this required, even for simple fetching.
|
|
22
|
+
* @param {string} password - The user's password. For whatever reason, RobTop made this required, even for simple fetching.
|
|
23
|
+
* @returns {LevelScore[]}
|
|
24
|
+
*/
|
|
25
|
+
getLevelScores: async function (level, type, username, password) {
|
|
3
26
|
let types = { week: "2", top: "1", friends: "0" }
|
|
4
|
-
if (!
|
|
27
|
+
if (!level) throw new Error("Please provide a level ID!");
|
|
5
28
|
if (!types[type.toLowerCase()]) throw new Error("Please provide a valid leaderboard type! Possible types: \"week\", \"top\", \"friends\".")
|
|
6
|
-
if (!
|
|
7
|
-
if (!
|
|
29
|
+
if (!username) throw new Error("Please provide a username or a Player ID!");
|
|
30
|
+
if (!password) throw new Error("Please provide a password!");
|
|
8
31
|
|
|
9
32
|
const { gjReq } = require("../gjReq.js");
|
|
10
33
|
const { rgbToHEX } = require("../misc/rgbToHEX");
|
|
11
34
|
const colors = require("../misc/colors.json");
|
|
12
35
|
let search = await gjReq("getGJUsers20", {
|
|
13
|
-
str:
|
|
36
|
+
str: username,
|
|
14
37
|
secret: "Wmfd2893gb7"
|
|
15
38
|
});
|
|
16
39
|
if (search.data == -1) return [];
|
|
@@ -21,8 +44,8 @@ module.exports = {
|
|
|
21
44
|
|
|
22
45
|
const data = {
|
|
23
46
|
accountID: accID,
|
|
24
|
-
gjp: xor.encrypt(
|
|
25
|
-
levelID:
|
|
47
|
+
gjp: xor.encrypt(password, 37526),
|
|
48
|
+
levelID: level,
|
|
26
49
|
secret: "Wmfd2893gb7",
|
|
27
50
|
type: types[type.toLowerCase()]
|
|
28
51
|
}
|
|
@@ -51,8 +74,8 @@ module.exports = {
|
|
|
51
74
|
playerID: Number(s[3]),
|
|
52
75
|
accountID: Number(s[15]),
|
|
53
76
|
rank: Number(s[19]),
|
|
54
|
-
|
|
55
|
-
|
|
77
|
+
color1: rgbToHEX(colors[username[7]]),
|
|
78
|
+
color2: rgbToHEX(colors[username[9]]),
|
|
56
79
|
iconID: Number(s[5]),
|
|
57
80
|
iconType: iconObj[s[11]],
|
|
58
81
|
glow: s[13] == "2" ? true : false,
|
package/functions/getMapPacks.js
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} MapPack
|
|
3
|
+
* @property {string} name - The map pack's name.
|
|
4
|
+
* @property {number} id - The map pack's ID.
|
|
5
|
+
* @property {Array<Number>} levels - The list of level IDs in the map pack.
|
|
6
|
+
* @property {Number} stars - The amount of stars received from completing the map pack.
|
|
7
|
+
* @property {number} coins - The amount of secret coins received from completing the map pack.
|
|
8
|
+
* @property {string} difficulty - The map pack's difficulty.
|
|
9
|
+
* @property {string} textColor - The map pack's title color.
|
|
10
|
+
* @property {string} barColor - The map pack's progress bar color.
|
|
11
|
+
*/
|
|
1
12
|
module.exports = {
|
|
13
|
+
/**
|
|
14
|
+
* Gets the map packs from a specified page.
|
|
15
|
+
* @param {number} page - The page to search through. Defaults to 1.
|
|
16
|
+
* @returns {MapPack[]}
|
|
17
|
+
*/
|
|
2
18
|
getMapPacks: async function (page = 1) {
|
|
3
19
|
const { gjReq } = require("../gjReq");
|
|
4
20
|
const data = {
|
package/functions/getMessages.js
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} Message
|
|
3
|
+
* @property {string} username - The message sender's username.
|
|
4
|
+
* @property {string} title - The message's title.
|
|
5
|
+
* @property {number} playerID - The message sender's player ID.
|
|
6
|
+
* @property {number} accountID - The message sender's account ID.
|
|
7
|
+
* @property {number} messageID - The message ID.
|
|
8
|
+
* @property {string} age - How long ago the message was sent.
|
|
9
|
+
* @property {boolean} read - Whether the message was already read.
|
|
10
|
+
*/
|
|
1
11
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Gets the list of messages received by a user.
|
|
14
|
+
* @param {string} username - The user's username or player ID.
|
|
15
|
+
* @param {string} password - The user's password.
|
|
16
|
+
* @param {number} page - The page to search through. Defaults to 1.
|
|
17
|
+
* @returns {Message[]}
|
|
18
|
+
*/
|
|
19
|
+
getMessages: async function (username, password, page = 1) {
|
|
20
|
+
if (!username) throw new Error("Please provide a player ID or username!");
|
|
21
|
+
if (!password) throw new Error("Please provide a password!");
|
|
5
22
|
if (isNaN(page)) throw new Error("The page should be a number!");
|
|
6
23
|
|
|
7
24
|
const { gjReq } = require("../gjReq");
|
|
@@ -9,7 +26,7 @@ module.exports = {
|
|
|
9
26
|
const xor = new XOR;
|
|
10
27
|
|
|
11
28
|
let search = await gjReq("getGJUsers20", {
|
|
12
|
-
str:
|
|
29
|
+
str: username,
|
|
13
30
|
secret: "Wmfd2893gb7"
|
|
14
31
|
});
|
|
15
32
|
if (search.data == -1) return [];
|
|
@@ -17,7 +34,7 @@ module.exports = {
|
|
|
17
34
|
|
|
18
35
|
let res = await gjReq("getGJMessages20", {
|
|
19
36
|
accountID: accID,
|
|
20
|
-
gjp: xor.encrypt(
|
|
37
|
+
gjp: xor.encrypt(password, 37526),
|
|
21
38
|
secret: "Wmfd2893gb7",
|
|
22
39
|
page: page - 1
|
|
23
40
|
});
|
|
@@ -1,11 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} Song
|
|
3
|
+
* @property {string} name - The song's name.
|
|
4
|
+
* @property {string} id - The ID of the level the song is used in (e.g. "Level 1").
|
|
5
|
+
* @property {string} artist - The song artist.
|
|
6
|
+
* @property {string} link - The link to listen to the song.
|
|
7
|
+
*/
|
|
1
8
|
module.exports = {
|
|
9
|
+
/**
|
|
10
|
+
* Gets song info about an official song.
|
|
11
|
+
* @param {number} song - The song ID.
|
|
12
|
+
* @returns {Song}
|
|
13
|
+
*/
|
|
2
14
|
getOfficialSongInfo: function (song) {
|
|
3
15
|
if (isNaN(song)) throw new Error("Please provide a valid official song ID.");
|
|
4
|
-
const
|
|
5
|
-
const jsons = { 1: sm, 2: bot, 3: pg, 4: dout, 5: bab, 6: clg, 7: j, 8: tm, 9: c, 10: xs, 11: cf, 12: toe, 13: ea, 14: cs, 15: ed, 16: hf, 17: bp, 18: toeii, 19: gd, 20: d, 21: fd, 22: dash, 23: exp, 24: tss, 25: va, 26: ar, 27: tc, 28: p, 29: bm, 30: m, 31: y, 32: f, 33: sp, 34: s, 35: e, 36: round, 37: mdo, 38: ps, 39: ne, 40: pt };
|
|
16
|
+
const officialSongs = require("../misc/officialsongs.json");
|
|
6
17
|
|
|
7
|
-
let result =
|
|
8
|
-
if (!result) result =
|
|
18
|
+
let result = officialSongs[Number(song)];
|
|
19
|
+
if (!result) result = officialSongs["-1"];
|
|
9
20
|
return result;
|
|
10
21
|
}
|
|
11
22
|
}
|
package/functions/getProfile.js
CHANGED
|
@@ -1 +1,198 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} Player
|
|
3
|
+
* @property {string} username - The player's username.
|
|
4
|
+
* @property {number} playerID - The player's player ID.
|
|
5
|
+
* @property {number} accountID - The player's account ID.
|
|
6
|
+
* @property {number} rank - The player's position on the global leaderboard.
|
|
7
|
+
* @property {number} stars - The amount of stars the player has.
|
|
8
|
+
* @property {number} diamonds - The amount of diamonds the player has.
|
|
9
|
+
* @property {number} secretCoins - The amount of secret coins the player has.
|
|
10
|
+
* @property {number} userCoins - The amount of user coins the player has.
|
|
11
|
+
* @property {number} demons - The amount of demons the player has completed.
|
|
12
|
+
* @property {number} moons - The amount of moons the player has.
|
|
13
|
+
* @property {number} creatorPoints - The amount of creator points the player has.
|
|
14
|
+
* @property {string} color1 - The HEX code of the player's primary color.
|
|
15
|
+
* @property {string} color2 - The HEX code of the player's secondary color.
|
|
16
|
+
* @property {number} cubeID - The ID of the currently selected cube icon.
|
|
17
|
+
* @property {number} shipID - The ID of the currently selected ship icon.
|
|
18
|
+
* @property {number} ballID - The ID of the currently selected ball icon.
|
|
19
|
+
* @property {number} ufoID - The ID of the currently selected UFO icon.
|
|
20
|
+
* @property {number} waveID - The ID of the currently selected wave icon.
|
|
21
|
+
* @property {number} robotID - The ID of the currently selected robot icon.
|
|
22
|
+
* @property {number} spiderID - The ID of the currently selected spider icon.
|
|
23
|
+
* @property {number} swingID - The ID of the currently selected swing icon.
|
|
24
|
+
* @property {number} jetpackID - The ID of the currently selected jetpack icon.
|
|
25
|
+
* @property {number} explosionID - The ID of the currently selected explosion animation.
|
|
26
|
+
* @property {boolean} glow - Whether the player's icon has the "glow" feature enabled.
|
|
27
|
+
* @property {string} messages - The current state of messaging the player. Returns "all" if anyone can message the person, "friends" if it's limited to friends, and "none" if no one can.
|
|
28
|
+
* @property {boolean} friendRequests - Whether the player has allowed to receive friend requests.
|
|
29
|
+
* @property {string} commentHistory - The current state of viewing the player's comment history. Returns "all" if anyone can do it, "friends" if it's limited to friends, and "none" if only the player can.
|
|
30
|
+
* @property {string|null} mod - Whether the player is a moderator. Returns `null` if not, "mod" if the user is a regular moderator and "elder" if the user is an elder moderator.
|
|
31
|
+
* @property {string} youtube - The player's YouTube channel ID, used in this template: `https://youtube.com/channel/((youtube))`.
|
|
32
|
+
* @property {string} twitter - The player's X (formerly Twitter) username, used in this template: `https://x.com/((twitter))`.
|
|
33
|
+
* @property {string} twitch - The player's Twitch username, used in this template: `https://twitch.tv/((twitch))`.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
module.exports = {
|
|
37
|
+
/**
|
|
38
|
+
* Fetches the profile of a specified user.
|
|
39
|
+
* @param {string} name - The search query (user, account ID or player ID).
|
|
40
|
+
* @param {("name"|"accountid"|"playerid")} mode - The search mode, defaults to "auto". If "auto" is selected, the search is first attempted by matching the matching the username, then account ID and then player ID.
|
|
41
|
+
* @returns {Player}
|
|
42
|
+
*/
|
|
43
|
+
getProfile: async function (name, mode = "auto") {
|
|
44
|
+
const { gjReq } = require("../gjReq");
|
|
45
|
+
const { rgbToHEX } = require("../misc/rgbToHEX");
|
|
46
|
+
const colors = require("../misc/colors.json");
|
|
47
|
+
if (!name) throw new Error("Please provide an account name, player ID or account ID!")
|
|
48
|
+
if (!["name", "accountid", "playerid", "auto"].includes(mode)) throw new Error("Please provide a valid search mode! It's either \"name\", \"accountid\", \"playerid\", or \"auto\"")
|
|
49
|
+
|
|
50
|
+
function decodeUser(array) {
|
|
51
|
+
let accName = array[1];
|
|
52
|
+
let playerID = Number(array[3]);
|
|
53
|
+
let secretCoins = Number(array[5]);
|
|
54
|
+
let userCoins = Number(array[7]);
|
|
55
|
+
let c1 = array[9];
|
|
56
|
+
let c2 = array[11];
|
|
57
|
+
let stars = Number(array[15]);
|
|
58
|
+
let moons = Number(array[17]);
|
|
59
|
+
let diamonds = Number(array[19]);
|
|
60
|
+
let demons = Number(array[21]);
|
|
61
|
+
let cp = Number(array[23]);
|
|
62
|
+
let msg = array[25];
|
|
63
|
+
let friendReqs = array[27];
|
|
64
|
+
let commentHistory = array[29];
|
|
65
|
+
let yt = array[31];
|
|
66
|
+
let cube = Number(array[33]);
|
|
67
|
+
let ship = Number(array[35]);
|
|
68
|
+
let ball = Number(array[37]);
|
|
69
|
+
let ufo = Number(array[39]);
|
|
70
|
+
let wave = Number(array[41]);
|
|
71
|
+
let robot = Number(array[43]);
|
|
72
|
+
let spider = Number(array[47]);
|
|
73
|
+
let swing = Number(array[51]);
|
|
74
|
+
let jetpack = Number(array[53]);
|
|
75
|
+
let glow = Boolean(Number(array[45]));
|
|
76
|
+
let explosion = Number(array[49]);
|
|
77
|
+
let rank = Number(array[55]);
|
|
78
|
+
let accID = Number(array[57]);
|
|
79
|
+
let twitter = array[61];
|
|
80
|
+
let twitch = array[63];
|
|
81
|
+
let mod = array[65];
|
|
82
|
+
|
|
83
|
+
let msgObj = {
|
|
84
|
+
0: "all",
|
|
85
|
+
1: "friends",
|
|
86
|
+
2: "none"
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
let friendReqsObj = {
|
|
90
|
+
0: true,
|
|
91
|
+
1: false
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
let modObj = {
|
|
95
|
+
0: null,
|
|
96
|
+
1: "mod",
|
|
97
|
+
2: "elder"
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
username: accName,
|
|
102
|
+
playerID: playerID,
|
|
103
|
+
accountID: accID,
|
|
104
|
+
rank: rank,
|
|
105
|
+
stars: stars,
|
|
106
|
+
diamonds: diamonds,
|
|
107
|
+
secretCoins: secretCoins,
|
|
108
|
+
userCoins: userCoins,
|
|
109
|
+
demons: demons,
|
|
110
|
+
moons: moons,
|
|
111
|
+
creatorPoints: cp,
|
|
112
|
+
color1: rgbToHEX(colors[c1]),
|
|
113
|
+
color2: rgbToHEX(colors[c2]),
|
|
114
|
+
cubeID: cube,
|
|
115
|
+
shipID: ship,
|
|
116
|
+
ballID: ball,
|
|
117
|
+
ufoID: ufo,
|
|
118
|
+
waveID: wave,
|
|
119
|
+
robotID: robot,
|
|
120
|
+
spiderID: spider,
|
|
121
|
+
swingID: swing,
|
|
122
|
+
jetpackID: jetpack,
|
|
123
|
+
explosionID: explosion,
|
|
124
|
+
glow: glow,
|
|
125
|
+
messages: msgObj[msg],
|
|
126
|
+
friendRequests: friendReqsObj[friendReqs],
|
|
127
|
+
commentHistory: msgObj[commentHistory],
|
|
128
|
+
mod: modObj[mod],
|
|
129
|
+
youtube: yt,
|
|
130
|
+
twitter: twitter,
|
|
131
|
+
twitch: twitch
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function accIDSearch() {
|
|
136
|
+
let res = await gjReq("getGJUserInfo20", {
|
|
137
|
+
targetAccountID: name,
|
|
138
|
+
secret: "Wmfd2893gb7"
|
|
139
|
+
});
|
|
140
|
+
if (res.data == -1) return {};
|
|
141
|
+
let accArray = res.data.split(":");
|
|
142
|
+
|
|
143
|
+
return decodeUser(accArray);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async function nonAccIDSearch() {
|
|
147
|
+
let search = await gjReq("getGJUsers20", {
|
|
148
|
+
str: name,
|
|
149
|
+
secret: "Wmfd2893gb7"
|
|
150
|
+
});
|
|
151
|
+
if (search.data == -1) return {};
|
|
152
|
+
let targetAccID = search.data.split(":")[21];
|
|
153
|
+
|
|
154
|
+
let res = await gjReq("getGJUserInfo20", {
|
|
155
|
+
targetAccountID: targetAccID,
|
|
156
|
+
secret: "Wmfd2893gb7"
|
|
157
|
+
});
|
|
158
|
+
let accArray = res.data.split(":");
|
|
159
|
+
|
|
160
|
+
return decodeUser(accArray);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (mode == "accountid") {
|
|
164
|
+
const user = await new Promise((resolve) => {
|
|
165
|
+
accIDSearch().then(u => resolve(u));
|
|
166
|
+
})
|
|
167
|
+
return user;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (mode == "name" || mode == "playerid") {
|
|
171
|
+
const user = await new Promise((resolve) => {
|
|
172
|
+
nonAccIDSearch().then(u => resolve(u));
|
|
173
|
+
})
|
|
174
|
+
return user;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (isNaN(name)) {
|
|
178
|
+
const user = await new Promise((resolve) => {
|
|
179
|
+
nonAccIDSearch().then(u => resolve(u));
|
|
180
|
+
})
|
|
181
|
+
return user;
|
|
182
|
+
} else {
|
|
183
|
+
let user;
|
|
184
|
+
const accIDUser = await new Promise((resolve) => {
|
|
185
|
+
accIDSearch().then(u => resolve(u));
|
|
186
|
+
})
|
|
187
|
+
if (!Object.keys(user).length) {
|
|
188
|
+
const nonAccIDUser = await new Promise((resolve) => {
|
|
189
|
+
nonAccIDSearch().then(u => resolve(u));
|
|
190
|
+
})
|
|
191
|
+
user = nonAccIDUser;
|
|
192
|
+
} else {
|
|
193
|
+
user = accIDUser;
|
|
194
|
+
}
|
|
195
|
+
return user;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
package/functions/getSongInfo.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} Song
|
|
3
|
+
* @property {string} name - The song's name.
|
|
4
|
+
* @property {number} id - The song's ID.
|
|
5
|
+
* @property {string} artist - The song artist.
|
|
6
|
+
* @property {number} artistId - The song artist's ID on Newgrounds.
|
|
7
|
+
* @property {number} fileSize - The song's file size in megabytes.
|
|
8
|
+
* @property {string} link - The direct link to download the song file.
|
|
9
|
+
*/
|
|
10
|
+
|
|
1
11
|
module.exports = {
|
|
12
|
+
/**
|
|
13
|
+
* Searches for a song on Newgrounds or in the internal Geometry Dash song library.
|
|
14
|
+
* @param {number} song - The song ID.
|
|
15
|
+
* @returns {Song}
|
|
16
|
+
*/
|
|
2
17
|
getSongInfo: async function (song) {
|
|
3
18
|
if (isNaN(song)) throw new Error("Please provide a valid song ID.");
|
|
4
19
|
const { gjReq } = require("../gjReq");
|
|
@@ -16,12 +31,12 @@ module.exports = {
|
|
|
16
31
|
if (link == "CUSTOMURL") link = `https://geometrydashfiles.b-cdn.net/music/${song.toString().trim()}.ogg`;
|
|
17
32
|
|
|
18
33
|
const result = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
name: rawSong[3],
|
|
35
|
+
id: Number(rawSong[1]),
|
|
36
|
+
artist: rawSong[7],
|
|
37
|
+
artistId: Number(rawSong[5]),
|
|
38
|
+
fileSize: Number(rawSong[9]),
|
|
39
|
+
link: link
|
|
25
40
|
}
|
|
26
41
|
|
|
27
42
|
return result;
|