noblox-asset.js 7.4.0
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/.github/ISSUE_TEMPLATE/bug_report.md +29 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +22 -0
- package/.github/workflows/doc-publish.yml +33 -0
- package/.github/workflows/npmpublish.yml +72 -0
- package/.github/workflows/run-tests.yml +49 -0
- package/CODE_OF_CONDUCT.md +76 -0
- package/LICENSE +21 -0
- package/README.md +182 -0
- package/eslint.config.mjs +34 -0
- package/examples/cleanPlayers.js +130 -0
- package/examples/cleanWall.js +110 -0
- package/examples/revertRanks.js +100 -0
- package/examples/savePlayers.js +119 -0
- package/examples/saveWall.js +96 -0
- package/img/moderatedThumbnails/moderatedThumbnail_100x100.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_110x110.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_140x140.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_150x150.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_150x200.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_180x180.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_250x250.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_30x30.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_352x352.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_420x420.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_48x48.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_50x50.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_60x60.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_720x720.png +0 -0
- package/img/moderatedThumbnails/moderatedThumbnail_75x75.png +0 -0
- package/img/noblox-js-small.png +0 -0
- package/img/noblox-js.png +0 -0
- package/img/thumbnailSizes.png +0 -0
- package/jsDocsConfig.json +55 -0
- package/lib/accountinformation/getUserSocialLinks.js +40 -0
- package/lib/accountsettings/block.js +53 -0
- package/lib/accountsettings/unblock.js +53 -0
- package/lib/asset/deleteFromInventory.js +56 -0
- package/lib/asset/getGamePassProductInfo.js +50 -0
- package/lib/asset/getProductInfo.js +46 -0
- package/lib/asset/uploadAnimation.js +103 -0
- package/lib/asset/uploadItem.js +83 -0
- package/lib/asset/uploadModel.js +90 -0
- package/lib/avatar/avatarRules.js +39 -0
- package/lib/avatar/currentlyWearing.js +33 -0
- package/lib/avatar/getAvatar.js +36 -0
- package/lib/avatar/getCurrentAvatar.js +38 -0
- package/lib/avatar/getRecentItems.js +36 -0
- package/lib/avatar/outfitDetails.js +33 -0
- package/lib/avatar/outfits.js +38 -0
- package/lib/avatar/redrawAvatar.js +47 -0
- package/lib/avatar/removeAssetId.js +51 -0
- package/lib/avatar/setAvatarBodyColors.js +61 -0
- package/lib/avatar/setAvatarScales.js +61 -0
- package/lib/avatar/setPlayerAvatarType.js +51 -0
- package/lib/avatar/setWearingAssets.js +51 -0
- package/lib/avatar/wearAssetId.js +51 -0
- package/lib/badges/getAwardedTimestamps.js +49 -0
- package/lib/badges/getBadgeInfo.js +44 -0
- package/lib/badges/getGameBadges.js +63 -0
- package/lib/badges/getPlayerBadges.js +28 -0
- package/lib/badges/updateBadgeInfo.js +75 -0
- package/lib/cache/add.js +14 -0
- package/lib/cache/addIf.js +26 -0
- package/lib/cache/clear.js +8 -0
- package/lib/cache/get.js +28 -0
- package/lib/cache/index.js +17 -0
- package/lib/cache/new.js +12 -0
- package/lib/cache/wrap.js +25 -0
- package/lib/chat/addUsersToConversation.js +58 -0
- package/lib/chat/chatSettings.js +34 -0
- package/lib/chat/getChatMessages.js +41 -0
- package/lib/chat/getConversations.js +44 -0
- package/lib/chat/getRolloutSettings.js +36 -0
- package/lib/chat/getUnreadConversationCount.js +34 -0
- package/lib/chat/getUnreadMessages.js +39 -0
- package/lib/chat/getUserConversations.js +38 -0
- package/lib/chat/markChatAsRead.js +53 -0
- package/lib/chat/markChatAsSeen.js +51 -0
- package/lib/chat/multiGetLatestMessages.js +38 -0
- package/lib/chat/onNewConversation.js +50 -0
- package/lib/chat/onNewMessage.js +53 -0
- package/lib/chat/onNewMessageBySelf.js +50 -0
- package/lib/chat/onUserOnline.js +50 -0
- package/lib/chat/onUserTyping.js +54 -0
- package/lib/chat/removeFromGroupConversation.js +59 -0
- package/lib/chat/renameGroupConversation.js +58 -0
- package/lib/chat/sendChatMessage.js +58 -0
- package/lib/chat/setChatUserTyping.js +58 -0
- package/lib/chat/start121Conversation.js +51 -0
- package/lib/chat/startCloudEditConversation.js +51 -0
- package/lib/chat/startGroupConversation.js +59 -0
- package/lib/client/onNotification.js +86 -0
- package/lib/client/setAPIKey.js +18 -0
- package/lib/client/setCookie.js +38 -0
- package/lib/datastores/deleteDatastoreEntry.js +56 -0
- package/lib/datastores/getDatastoreEntry.js +88 -0
- package/lib/datastores/getDatastoreEntryVersions.js +73 -0
- package/lib/datastores/getDatastoreKeys.js +63 -0
- package/lib/datastores/getDatastores.js +62 -0
- package/lib/datastores/incrementDatastoreEntry.js +83 -0
- package/lib/datastores/setDatastoreEntry.js +80 -0
- package/lib/develop/canManage.js +42 -0
- package/lib/develop/configureItem.js +210 -0
- package/lib/develop/updateUniverse.js +52 -0
- package/lib/develop/updateUniverseAccess.js +54 -0
- package/lib/economy/getGroupFunds.js +42 -0
- package/lib/economy/getGroupPayoutEligibility.js +55 -0
- package/lib/economy/getGroupRevenueSummary.js +42 -0
- package/lib/economy/getGroupTransactions.js +32 -0
- package/lib/economy/getResaleData.js +48 -0
- package/lib/economy/getResellers.js +35 -0
- package/lib/economy/getUserFunds.js +43 -0
- package/lib/economy/getUserTransactions.js +34 -0
- package/lib/economy/onGroupTransaction.js +74 -0
- package/lib/friends/acceptFriendRequest.js +54 -0
- package/lib/friends/declineAllFriendRequests.js +52 -0
- package/lib/friends/declineFriendRequest.js +54 -0
- package/lib/friends/getFollowerCount.js +35 -0
- package/lib/friends/getFollowers.js +56 -0
- package/lib/friends/getFollowingCount.js +35 -0
- package/lib/friends/getFollowings.js +56 -0
- package/lib/friends/getFriendCount.js +35 -0
- package/lib/friends/getFriendRequests.js +51 -0
- package/lib/friends/getFriends.js +48 -0
- package/lib/friends/onFriendRequest.js +58 -0
- package/lib/friends/removeFriend.js +53 -0
- package/lib/friends/sendFriendRequest.js +54 -0
- package/lib/friends/unfollow.js +53 -0
- package/lib/games/addDeveloperProduct.js +53 -0
- package/lib/games/configureGamePass.js +126 -0
- package/lib/games/getDeveloperProducts.js +44 -0
- package/lib/games/getGameInstances.js +31 -0
- package/lib/games/getGamePasses.js +39 -0
- package/lib/games/getGameRevenue.js +48 -0
- package/lib/games/getGameSocialLinks.js +42 -0
- package/lib/games/getGroupGames.js +30 -0
- package/lib/games/getPlaceInfo.js +47 -0
- package/lib/games/getUniverseInfo.js +50 -0
- package/lib/games/publishToTopic.js +52 -0
- package/lib/games/sendUserNotification.js +65 -0
- package/lib/games/updateDeveloperProduct.js +56 -0
- package/lib/groups/banFromGroup.js +47 -0
- package/lib/groups/changeRank.js +59 -0
- package/lib/groups/deleteWallPost.js +59 -0
- package/lib/groups/deleteWallPostsByUser.js +55 -0
- package/lib/groups/demote.js +25 -0
- package/lib/groups/exile.js +55 -0
- package/lib/groups/getAuditLog.js +64 -0
- package/lib/groups/getGroup.js +50 -0
- package/lib/groups/getGroupBans.js +37 -0
- package/lib/groups/getGroupSocialLinks.js +41 -0
- package/lib/groups/getGroups.js +82 -0
- package/lib/groups/getJoinRequest.js +47 -0
- package/lib/groups/getJoinRequests.js +53 -0
- package/lib/groups/getPlayers.js +103 -0
- package/lib/groups/getRankInGroup.js +45 -0
- package/lib/groups/getRankNameInGroup.js +44 -0
- package/lib/groups/getRole.js +64 -0
- package/lib/groups/getRolePermissions.js +48 -0
- package/lib/groups/getRoles.js +53 -0
- package/lib/groups/getShout.js +47 -0
- package/lib/groups/getWall.js +56 -0
- package/lib/groups/groupPayout.js +103 -0
- package/lib/groups/handleJoinRequest.js +57 -0
- package/lib/groups/handleJoinRequests.js +61 -0
- package/lib/groups/leaveGroup.js +56 -0
- package/lib/groups/onAuditLog.js +62 -0
- package/lib/groups/onJoinRequest.js +63 -0
- package/lib/groups/onJoinRequestHandle.js +105 -0
- package/lib/groups/onShout.js +57 -0
- package/lib/groups/onWallPost.js +58 -0
- package/lib/groups/promote.js +25 -0
- package/lib/groups/searchGroups.js +32 -0
- package/lib/groups/setGroupDescription.js +58 -0
- package/lib/groups/setGroupName.js +59 -0
- package/lib/groups/setRank.js +74 -0
- package/lib/groups/setRoleInfo.js +84 -0
- package/lib/groups/shout.js +58 -0
- package/lib/groups/unbanFromGroup.js +41 -0
- package/lib/index.js +212 -0
- package/lib/internal/levelOneCopy.js +16 -0
- package/lib/internal/queue.js +61 -0
- package/lib/internal/timeout.js +30 -0
- package/lib/internal/wrap.js +78 -0
- package/lib/inventory/getCollectibles.js +31 -0
- package/lib/inventory/getInventory.js +32 -0
- package/lib/inventory/getInventoryById.js +31 -0
- package/lib/inventory/getOwnership.js +47 -0
- package/lib/inventory/getUAIDs.js +47 -0
- package/lib/itemconfiguration/getGroupAssets.js +32 -0
- package/lib/options.js +26 -0
- package/lib/party/onPartyDeleted.js +53 -0
- package/lib/party/onPartyInvite.js +53 -0
- package/lib/party/onPartyJoinedGame.js +53 -0
- package/lib/party/onPartyLeftGame.js +53 -0
- package/lib/party/onPartySelfJoined.js +53 -0
- package/lib/party/onPartySelfLeft.js +53 -0
- package/lib/party/onPartyUserJoined.js +53 -0
- package/lib/party/onPartyUserLeft.js +53 -0
- package/lib/premiumfeatures/getPremium.js +46 -0
- package/lib/presence/getPresences.js +60 -0
- package/lib/privatemessages/getMessages.js +55 -0
- package/lib/privatemessages/message.js +75 -0
- package/lib/privatemessages/onMessage.js +89 -0
- package/lib/thumbnails/getLogo.js +56 -0
- package/lib/thumbnails/getPlayerThumbnail.js +120 -0
- package/lib/thumbnails/getThumbnails.js +92 -0
- package/lib/trades/acceptTrade.js +52 -0
- package/lib/trades/canTradeWith.js +43 -0
- package/lib/trades/counterTrade.js +78 -0
- package/lib/trades/declineTrade.js +52 -0
- package/lib/trades/getTradeInfo.js +47 -0
- package/lib/trades/getTrades.js +37 -0
- package/lib/trades/sendTrade.js +76 -0
- package/lib/users/getBlurb.js +37 -0
- package/lib/users/getIdFromUsername.js +56 -0
- package/lib/users/getPlayerInfo.js +128 -0
- package/lib/users/getUserInfo.js +35 -0
- package/lib/users/getUsernameFromId.js +45 -0
- package/lib/users/getUsernameHistory.js +42 -0
- package/lib/users/onBlurbChange.js +46 -0
- package/lib/users/searchUsers.js +41 -0
- package/lib/util/apiError.js +50 -0
- package/lib/util/clearSession.js +32 -0
- package/lib/util/generalRequest.js +61 -0
- package/lib/util/getAction.js +45 -0
- package/lib/util/getAuthenticatedUser.js +41 -0
- package/lib/util/getCurrentUser.js +58 -0
- package/lib/util/getGeneralToken.js +52 -0
- package/lib/util/getHash.js +29 -0
- package/lib/util/getInputs.js +37 -0
- package/lib/util/getPageResults.js +86 -0
- package/lib/util/getSenderUserId.js +30 -0
- package/lib/util/getSession.js +38 -0
- package/lib/util/getVerification.js +60 -0
- package/lib/util/getVerificationInputs.js +31 -0
- package/lib/util/http.js +138 -0
- package/lib/util/jar.js +25 -0
- package/lib/util/refreshCookie.js +52 -0
- package/lib/util/relog.js +81 -0
- package/lib/util/setOptions.js +54 -0
- package/lib/util/shortPoll.js +102 -0
- package/package.json +76 -0
- package/postinstall.mjs +1 -0
- package/settings.json +115 -0
- package/test/accountinformation.test.js +27 -0
- package/test/accountsettings.test.js +27 -0
- package/test/asset.test.js +81 -0
- package/test/assets/Great-White-Shark-Fin.rbxm +0 -0
- package/test/assets/KeyframeSequence.rbxm +0 -0
- package/test/avatar.test.js +164 -0
- package/test/badges.test.js +96 -0
- package/test/chat.test.js +104 -0
- package/test/datastore.test.js +105 -0
- package/test/develop.test.js +53 -0
- package/test/economy.test.js +143 -0
- package/test/friends.test.js +146 -0
- package/test/games.test.js +229 -0
- package/test/groups.test.js +405 -0
- package/test/inventory.test.js +98 -0
- package/test/itemconfiguration.test.js +24 -0
- package/test/premiumfeatures.test.js +17 -0
- package/test/presence.test.js +25 -0
- package/test/privatemessages.test.js +33 -0
- package/test/thumbnails.test.js +53 -0
- package/test/users.test.js +110 -0
- package/tutorials/Authentication.md +75 -0
- package/tutorials/Event Emitters.md +26 -0
- package/tutorials/Promises.md +86 -0
- package/tutorials/VPS Authentication.md +72 -0
- package/typings/index.d.ts +2639 -0
- package/typings/jsDocs.ts +1987 -0
package/lib/cache/get.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Includes
|
|
2
|
+
const levelOneCopy = require('../internal/levelOneCopy.js')
|
|
3
|
+
|
|
4
|
+
// Define
|
|
5
|
+
module.exports = function (cache, type, index) {
|
|
6
|
+
if (cache[type]) {
|
|
7
|
+
const group = cache[type]
|
|
8
|
+
const cached = group.items[index]
|
|
9
|
+
if (cached && cached.time) {
|
|
10
|
+
let passed
|
|
11
|
+
if (!group.permanent) {
|
|
12
|
+
passed = Date.now() / 1000 - cached.time
|
|
13
|
+
if (passed > group.expire) {
|
|
14
|
+
return false
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
let item = cached.item
|
|
18
|
+
if (item instanceof Object) {
|
|
19
|
+
item = levelOneCopy(item)
|
|
20
|
+
}
|
|
21
|
+
return [item, (group.refresh && ((group.refresh === true && true) || passed > group.refresh))]
|
|
22
|
+
} else {
|
|
23
|
+
return false
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
return 'Invalid type'
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Includes
|
|
2
|
+
const newCache = require('./new.js')
|
|
3
|
+
const add = require('./add.js')
|
|
4
|
+
const addIf = require('./addIf.js')
|
|
5
|
+
const get = require('./get.js')
|
|
6
|
+
const clear = require('./clear.js')
|
|
7
|
+
const wrap = require('./wrap.js')
|
|
8
|
+
|
|
9
|
+
// Define
|
|
10
|
+
module.exports = {
|
|
11
|
+
new: newCache,
|
|
12
|
+
add,
|
|
13
|
+
clear,
|
|
14
|
+
addIf,
|
|
15
|
+
get,
|
|
16
|
+
wrap
|
|
17
|
+
}
|
package/lib/cache/new.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Define
|
|
2
|
+
module.exports = function (types) {
|
|
3
|
+
const cache = {}
|
|
4
|
+
for (let i = 0; i < types.length; i++) {
|
|
5
|
+
const type = types[i]
|
|
6
|
+
const expireValue = type.expire
|
|
7
|
+
const permanent = expireValue === true
|
|
8
|
+
const expire = (permanent || expireValue === false ? 0 : expireValue)
|
|
9
|
+
cache[type.name] = { items: {}, expire, refresh: type.refresh, permanent }
|
|
10
|
+
}
|
|
11
|
+
return cache
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Includes
|
|
2
|
+
const addIf = require('./addIf.js')
|
|
3
|
+
const options = require('../options.js')
|
|
4
|
+
|
|
5
|
+
// Define
|
|
6
|
+
function wrap (type, index, func) {
|
|
7
|
+
const cache = options.cache
|
|
8
|
+
const group = cache[type]
|
|
9
|
+
if (group.expire > 0 || group.permanent) {
|
|
10
|
+
return new Promise(function (resolve, reject) {
|
|
11
|
+
addIf(cache, type, index, {
|
|
12
|
+
done: resolve,
|
|
13
|
+
add: function (done) {
|
|
14
|
+
return func().then(done).catch(reject)
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
} else {
|
|
19
|
+
return func()
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = function (type, index, func) {
|
|
24
|
+
return wrap(type, index, func)
|
|
25
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const http = require('../util/http.js').func
|
|
2
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
|
3
|
+
const RobloxAPIError = require('../util/apiError.js')
|
|
4
|
+
|
|
5
|
+
exports.required = ['conversationId', 'userIds']
|
|
6
|
+
exports.optional = ['jar']
|
|
7
|
+
|
|
8
|
+
// Docs
|
|
9
|
+
/**
|
|
10
|
+
* 🔐 Add users to a conversation.
|
|
11
|
+
* @category Chat
|
|
12
|
+
* @alias addUsersToConversation
|
|
13
|
+
* @param {number} conversationId - The id of the conversation.
|
|
14
|
+
* @param {Array<number>} userIds - The userIds of the users to add.
|
|
15
|
+
* @returns {Promise<ConversationAddResponse>}
|
|
16
|
+
* @example const noblox = require("noblox.js")
|
|
17
|
+
* // Login using your cookie
|
|
18
|
+
* noblox.addUsersToConversation(1, [1, 2, 3])
|
|
19
|
+
**/
|
|
20
|
+
|
|
21
|
+
function addUsersToConversation (conversationId, userIds, jar, token) {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
const httpOpt = {
|
|
24
|
+
url: '//chat.roblox.com/v2/add-to-conversation',
|
|
25
|
+
options: {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
jar,
|
|
28
|
+
headers: {
|
|
29
|
+
'X-CSRF-TOKEN': token
|
|
30
|
+
},
|
|
31
|
+
json: {
|
|
32
|
+
conversationId,
|
|
33
|
+
participantUserIds: userIds
|
|
34
|
+
},
|
|
35
|
+
resolveWithFullResponse: true
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return http(httpOpt).then((res) => {
|
|
39
|
+
if (res.statusCode === 200) {
|
|
40
|
+
if (!res.body.resultType === 'Success') {
|
|
41
|
+
reject(new RobloxAPIError(res))
|
|
42
|
+
} else {
|
|
43
|
+
resolve(res.body)
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
reject(new RobloxAPIError(res))
|
|
47
|
+
}
|
|
48
|
+
}).catch(error => reject(error))
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
exports.func = (args) => {
|
|
53
|
+
const jar = args.jar
|
|
54
|
+
|
|
55
|
+
return getGeneralToken({ jar }).then((xcsrf) => {
|
|
56
|
+
return addUsersToConversation(args.conversationId, args.userIds, jar, xcsrf)
|
|
57
|
+
})
|
|
58
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const http = require('../util/http.js').func
|
|
2
|
+
const RobloxAPIError = require('../util/apiError.js')
|
|
3
|
+
|
|
4
|
+
exports.optional = ['jar']
|
|
5
|
+
|
|
6
|
+
// Docs
|
|
7
|
+
/**
|
|
8
|
+
* 🔐 Get the chat settings.
|
|
9
|
+
* @category Chat
|
|
10
|
+
* @alias chatSettings
|
|
11
|
+
* @returns {Promise<ChatSettings>}
|
|
12
|
+
* @example const noblox = require("noblox.js")
|
|
13
|
+
* // Login using your cookie
|
|
14
|
+
* const settings = await noblox.chatSettings()
|
|
15
|
+
**/
|
|
16
|
+
|
|
17
|
+
exports.func = (args) => {
|
|
18
|
+
const jar = args.jar
|
|
19
|
+
|
|
20
|
+
return http({
|
|
21
|
+
url: '//chat.roblox.com/v2/chat-settings',
|
|
22
|
+
options: {
|
|
23
|
+
method: 'GET',
|
|
24
|
+
jar,
|
|
25
|
+
resolveWithFullResponse: true
|
|
26
|
+
}
|
|
27
|
+
}).then((res) => {
|
|
28
|
+
if (res.statusCode !== 200) {
|
|
29
|
+
throw new RobloxAPIError(res)
|
|
30
|
+
} else {
|
|
31
|
+
return JSON.parse(res.body)
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const http = require('../util/http.js').func
|
|
2
|
+
const RobloxAPIError = require('../util/apiError.js')
|
|
3
|
+
|
|
4
|
+
exports.required = ['conversationId']
|
|
5
|
+
exports.optional = ['pageSize', 'exclusiveStartMessageId', 'jar']
|
|
6
|
+
|
|
7
|
+
// Docs
|
|
8
|
+
/**
|
|
9
|
+
* 🔐 Get the chat messages for a conversation.
|
|
10
|
+
* @category Chat
|
|
11
|
+
* @alias getChatMessages
|
|
12
|
+
* @param {number} conversationId - The id of the conversation.
|
|
13
|
+
* @param {number=} [pageSize=100] - The size of the page.
|
|
14
|
+
* @param {string=} exclusiveStartMessageId - The messageId to start at.
|
|
15
|
+
* @returns {Promise<ChatMessage[]>}
|
|
16
|
+
* @example const noblox = require("noblox.js")
|
|
17
|
+
* // Login using your cookie
|
|
18
|
+
* const messages = await noblox.getChatMessages(1, 25)
|
|
19
|
+
**/
|
|
20
|
+
|
|
21
|
+
exports.func = (args) => {
|
|
22
|
+
const jar = args.jar
|
|
23
|
+
const conversationId = parseInt(args.conversationId) ? parseInt(args.conversationId) : 0
|
|
24
|
+
const pageSize = parseInt(args.pageSize) ? parseInt(args.pageSize) : 100
|
|
25
|
+
const startMessageId = typeof (args.exclusiveStartMessageId) === 'string' ? args.exclusiveStartMessageId : ''
|
|
26
|
+
|
|
27
|
+
return http({
|
|
28
|
+
url: '//chat.roblox.com/v2/get-messages?conversationId=' + conversationId + '&pageSize=' + pageSize + '&exclusiveStartMessageId=' + startMessageId,
|
|
29
|
+
options: {
|
|
30
|
+
method: 'GET',
|
|
31
|
+
jar,
|
|
32
|
+
resolveWithFullResponse: true
|
|
33
|
+
}
|
|
34
|
+
}).then((res) => {
|
|
35
|
+
if (res.statusCode !== 200) {
|
|
36
|
+
throw new RobloxAPIError(res)
|
|
37
|
+
} else {
|
|
38
|
+
return JSON.parse(res.body)
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const http = require('../util/http.js').func
|
|
2
|
+
const RobloxAPIError = require('../util/apiError.js')
|
|
3
|
+
|
|
4
|
+
exports.required = ['conversationIds']
|
|
5
|
+
exports.optional = ['jar']
|
|
6
|
+
|
|
7
|
+
// Docs
|
|
8
|
+
/**
|
|
9
|
+
* 🔐 Get conversation details for the conversationIds specified in the parameters
|
|
10
|
+
* @category Chat
|
|
11
|
+
* @alias getConversations
|
|
12
|
+
* @param {Array<number>} conversationIds - An array with the ids of the conversations.
|
|
13
|
+
* @returns {Promise<ChatConversation[]>}
|
|
14
|
+
* @example const noblox = require("noblox.js")
|
|
15
|
+
* // Login using your cookie
|
|
16
|
+
* const conversations = await noblox.getConversations([1, 2, 3])
|
|
17
|
+
**/
|
|
18
|
+
|
|
19
|
+
exports.func = (args) => {
|
|
20
|
+
const jar = args.jar
|
|
21
|
+
const conversationIds = typeof (args.conversationIds) === 'object' ? args.conversationIds : []
|
|
22
|
+
|
|
23
|
+
return http({
|
|
24
|
+
url: '//chat.roblox.com/v2/get-conversations?conversationIds=' + conversationIds.join('&conversationIds='),
|
|
25
|
+
options: {
|
|
26
|
+
method: 'GET',
|
|
27
|
+
jar,
|
|
28
|
+
resolveWithFullResponse: true
|
|
29
|
+
}
|
|
30
|
+
}).then((res) => {
|
|
31
|
+
if (res.statusCode !== 200) {
|
|
32
|
+
throw new RobloxAPIError(res)
|
|
33
|
+
} else {
|
|
34
|
+
let response = JSON.parse(res.body)
|
|
35
|
+
|
|
36
|
+
response = response.map((entry) => {
|
|
37
|
+
entry.lastUpdated = new Date(entry.lastUpdated)
|
|
38
|
+
return entry
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
return response
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const http = require('../util/http.js').func
|
|
2
|
+
const RobloxAPIError = require('../util/apiError.js')
|
|
3
|
+
|
|
4
|
+
exports.optional = ['featureNames', 'jar']
|
|
5
|
+
|
|
6
|
+
// Docs
|
|
7
|
+
/**
|
|
8
|
+
* 🔐 Get the rollout settings.
|
|
9
|
+
* @category Chat
|
|
10
|
+
* @alias getRolloutSettings
|
|
11
|
+
* @param {Array<string>=} featureNames - The names of the features rolling out.
|
|
12
|
+
* @returns {Promise<GetRolloutSettingsResult>}
|
|
13
|
+
* @example const noblox = require("noblox.js")
|
|
14
|
+
* // Login using your cookie
|
|
15
|
+
* const settings = await noblox.getRolloutSettings(['LuaChat', 'Party'])
|
|
16
|
+
**/
|
|
17
|
+
|
|
18
|
+
exports.func = (args) => {
|
|
19
|
+
const jar = args.jar
|
|
20
|
+
const featureNames = typeof (args.featureNames) === 'object' ? args.featureNames : []
|
|
21
|
+
|
|
22
|
+
return http({
|
|
23
|
+
url: '//chat.roblox.com/v2/get-rollout-settings?featureNames=' + featureNames.join('&featureNames='),
|
|
24
|
+
options: {
|
|
25
|
+
method: 'GET',
|
|
26
|
+
jar,
|
|
27
|
+
resolveWithFullResponse: true
|
|
28
|
+
}
|
|
29
|
+
}).then((res) => {
|
|
30
|
+
if (res.statusCode !== 200) {
|
|
31
|
+
throw new RobloxAPIError(res)
|
|
32
|
+
} else {
|
|
33
|
+
return JSON.parse(res.body)
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const http = require('../util/http.js').func
|
|
2
|
+
const RobloxAPIError = require('../util/apiError.js')
|
|
3
|
+
|
|
4
|
+
exports.optional = ['jar']
|
|
5
|
+
|
|
6
|
+
// Docs
|
|
7
|
+
/**
|
|
8
|
+
* 🔐 Get the number of unread conversations.
|
|
9
|
+
* @category Chat
|
|
10
|
+
* @alias getUnreadConversationCount
|
|
11
|
+
* @returns {Promise<GetUnreadConversationCountResult>}
|
|
12
|
+
* @example const noblox = require("noblox.js")
|
|
13
|
+
* // Login using your cookie
|
|
14
|
+
* const unreadConversationCount = noblox.getUnreadConversationCount()
|
|
15
|
+
**/
|
|
16
|
+
|
|
17
|
+
exports.func = (args) => {
|
|
18
|
+
const jar = args.jar
|
|
19
|
+
|
|
20
|
+
return http({
|
|
21
|
+
url: '//chat.roblox.com/v2/get-unread-conversation-count',
|
|
22
|
+
options: {
|
|
23
|
+
method: 'GET',
|
|
24
|
+
jar,
|
|
25
|
+
resolveWithFullResponse: true
|
|
26
|
+
}
|
|
27
|
+
}).then((res) => {
|
|
28
|
+
if (res.statusCode !== 200) {
|
|
29
|
+
throw new RobloxAPIError(res)
|
|
30
|
+
} else {
|
|
31
|
+
return JSON.parse(res.body)
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const http = require('../util/http.js').func
|
|
2
|
+
const RobloxAPIError = require('../util/apiError.js')
|
|
3
|
+
|
|
4
|
+
exports.required = ['conversationIds']
|
|
5
|
+
exports.optional = ['pageSize', 'jar']
|
|
6
|
+
|
|
7
|
+
// Docs
|
|
8
|
+
/**
|
|
9
|
+
* 🔐 Returns unread messages in the given conversations
|
|
10
|
+
* @category Chat
|
|
11
|
+
* @alias getUnreadMessages
|
|
12
|
+
* @param {Array<number>} conversationIds - The IDs of the conversations you want unread messages from.
|
|
13
|
+
* @param {number} pageSize - Number of messages to return on each page.
|
|
14
|
+
* @returns {Promise<ChatConversationWithMessages[]>}
|
|
15
|
+
* @example const noblox = require("noblox.js")
|
|
16
|
+
* // Login using your cookie
|
|
17
|
+
* noblox.getUnreadMessages([8212952828])
|
|
18
|
+
**/
|
|
19
|
+
|
|
20
|
+
exports.func = (args) => {
|
|
21
|
+
const jar = args.jar
|
|
22
|
+
const conversationIds = typeof (args.conversationIds) === 'object' ? args.conversationIds : []
|
|
23
|
+
const pageSize = parseInt(args.pageSize) ? parseInt(args.pageSize) : 30
|
|
24
|
+
|
|
25
|
+
return http({
|
|
26
|
+
url: '//chat.roblox.com/v2/get-unread-messages?pageSize=' + pageSize + '&conversationIds=' + conversationIds.join('&conversationIds='),
|
|
27
|
+
options: {
|
|
28
|
+
method: 'GET',
|
|
29
|
+
jar,
|
|
30
|
+
resolveWithFullResponse: true
|
|
31
|
+
}
|
|
32
|
+
}).then((res) => {
|
|
33
|
+
if (res.statusCode !== 200) {
|
|
34
|
+
throw new RobloxAPIError(res)
|
|
35
|
+
} else {
|
|
36
|
+
return JSON.parse(res.body)
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const http = require('../util/http.js').func
|
|
2
|
+
const RobloxAPIError = require('../util/apiError.js')
|
|
3
|
+
|
|
4
|
+
exports.optional = ['pageNumber', 'pageSize', 'jar']
|
|
5
|
+
|
|
6
|
+
// Docs
|
|
7
|
+
/**
|
|
8
|
+
* 🔐 Get your conversations.
|
|
9
|
+
* @category Chat
|
|
10
|
+
* @alias getUserConversations
|
|
11
|
+
* @param {number=} pageNumber - The page index.
|
|
12
|
+
* @param {number=} pageSize - The size of each page.
|
|
13
|
+
* @returns {Promise<ChatConversation[]>}
|
|
14
|
+
* @example const noblox = require("noblox.js")
|
|
15
|
+
* // Login using your cookie
|
|
16
|
+
* const conversations = await noblox.getUserConversations()
|
|
17
|
+
**/
|
|
18
|
+
|
|
19
|
+
exports.func = (args) => {
|
|
20
|
+
const jar = args.jar
|
|
21
|
+
const pageNumber = parseInt(args.pageNumber) ? parseInt(args.pageNumber) : 1
|
|
22
|
+
const pageSize = parseInt(args.pageSize) ? parseInt(args.pageSize) : 30
|
|
23
|
+
|
|
24
|
+
return http({
|
|
25
|
+
url: '//chat.roblox.com/v2/get-user-conversations?pageNumber=' + pageNumber + '&pageSize=' + pageSize,
|
|
26
|
+
options: {
|
|
27
|
+
method: 'GET',
|
|
28
|
+
jar,
|
|
29
|
+
resolveWithFullResponse: true
|
|
30
|
+
}
|
|
31
|
+
}).then((res) => {
|
|
32
|
+
if (res.statusCode !== 200) {
|
|
33
|
+
throw new RobloxAPIError(res)
|
|
34
|
+
} else {
|
|
35
|
+
return JSON.parse(res.body)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const http = require('../util/http.js').func
|
|
2
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
|
3
|
+
const RobloxAPIError = require('../util/apiError.js')
|
|
4
|
+
|
|
5
|
+
exports.required = ['conversationId', 'endMessageId']
|
|
6
|
+
exports.optional = ['jar']
|
|
7
|
+
|
|
8
|
+
// Docs
|
|
9
|
+
/**
|
|
10
|
+
* 🔐 Mark a chat as read.
|
|
11
|
+
* @category Chat
|
|
12
|
+
* @alias markChatAsRead
|
|
13
|
+
* @param {number} conversationId - The id of the conversation.
|
|
14
|
+
* @param {string} endMessageId - The last message to read.
|
|
15
|
+
* @returns {Promise<void>}
|
|
16
|
+
* @example const noblox = require("noblox.js")
|
|
17
|
+
* // Login using your cookie
|
|
18
|
+
* noblox.markChatAsRead(8212952828, 'e775e103-876f-4332-84ab-1ea14f326d39')
|
|
19
|
+
**/
|
|
20
|
+
|
|
21
|
+
const nextFunction = (jar, token, conversationId, endMessageId) => {
|
|
22
|
+
return http({
|
|
23
|
+
url: '//chat.roblox.com/v2/mark-as-read',
|
|
24
|
+
options: {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
jar,
|
|
27
|
+
headers: {
|
|
28
|
+
'X-CSRF-TOKEN': token
|
|
29
|
+
},
|
|
30
|
+
json: {
|
|
31
|
+
conversationId,
|
|
32
|
+
endMessageId
|
|
33
|
+
},
|
|
34
|
+
resolveWithFullResponse: true
|
|
35
|
+
}
|
|
36
|
+
}).then((res) => {
|
|
37
|
+
if (res.statusCode === 200) {
|
|
38
|
+
if (!res.body.resultType === 'Success') {
|
|
39
|
+
throw new RobloxAPIError(res)
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
throw new RobloxAPIError(res)
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
exports.func = (args) => {
|
|
48
|
+
const jar = args.jar
|
|
49
|
+
|
|
50
|
+
return getGeneralToken({ jar }).then((xcsrf) => {
|
|
51
|
+
return nextFunction(jar, xcsrf, args.conversationId, args.endMessageId)
|
|
52
|
+
})
|
|
53
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const http = require('../util/http.js').func
|
|
2
|
+
const getGeneralToken = require('../util/getGeneralToken.js').func
|
|
3
|
+
const RobloxAPIError = require('../util/apiError.js')
|
|
4
|
+
|
|
5
|
+
exports.required = ['conversationIds']
|
|
6
|
+
exports.optional = ['jar']
|
|
7
|
+
|
|
8
|
+
// Docs
|
|
9
|
+
/**
|
|
10
|
+
* 🔐 Mark chats as seen.
|
|
11
|
+
* @category Chat
|
|
12
|
+
* @alias markChatAsSeen
|
|
13
|
+
* @param {Array<number>} conversationIds - An array with conversationIds.
|
|
14
|
+
* @returns {Promise<void>}
|
|
15
|
+
* @example const noblox = require("noblox.js")
|
|
16
|
+
* // Login using your cookie
|
|
17
|
+
* noblox.markChatAsSeen([1, 2, 3])
|
|
18
|
+
**/
|
|
19
|
+
|
|
20
|
+
const nextFunction = (jar, token, conversationIds) => {
|
|
21
|
+
return http({
|
|
22
|
+
url: '//chat.roblox.com/v2/mark-as-seen',
|
|
23
|
+
options: {
|
|
24
|
+
method: 'POST',
|
|
25
|
+
jar,
|
|
26
|
+
headers: {
|
|
27
|
+
'X-CSRF-TOKEN': token
|
|
28
|
+
},
|
|
29
|
+
json: {
|
|
30
|
+
conversationsToMarkSeen: conversationIds
|
|
31
|
+
},
|
|
32
|
+
resolveWithFullResponse: true
|
|
33
|
+
}
|
|
34
|
+
}).then((res) => {
|
|
35
|
+
if (res.statusCode === 200) {
|
|
36
|
+
if (!res.body.resultType === 'Success') {
|
|
37
|
+
throw new RobloxAPIError(res)
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
throw new RobloxAPIError(res)
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.func = (args) => {
|
|
46
|
+
const jar = args.jar
|
|
47
|
+
|
|
48
|
+
return getGeneralToken({ jar }).then((xcsrf) => {
|
|
49
|
+
return nextFunction(jar, xcsrf, args.conversationIds)
|
|
50
|
+
})
|
|
51
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const http = require('../util/http.js').func
|
|
2
|
+
const RobloxAPIError = require('../util/apiError.js')
|
|
3
|
+
|
|
4
|
+
exports.required = ['conversationIds']
|
|
5
|
+
exports.optional = ['pageSize', 'jar']
|
|
6
|
+
|
|
7
|
+
// Docs
|
|
8
|
+
/**
|
|
9
|
+
* 🔐 Get multiple of the latest messages.
|
|
10
|
+
* @category Chat
|
|
11
|
+
* @alias multiGetLatestMessages
|
|
12
|
+
* @param {Array<number>} conversationIds - An array with the conversationIds.
|
|
13
|
+
* @returns {Promise<ChatConversationWithMessages[]>}
|
|
14
|
+
* @example const noblox = require("noblox.js")
|
|
15
|
+
* // Login using your cookie
|
|
16
|
+
* const recentMessages = await noblox.multiGetLatestMessages([1, 2, 3])
|
|
17
|
+
**/
|
|
18
|
+
|
|
19
|
+
exports.func = (args) => {
|
|
20
|
+
const jar = args.jar
|
|
21
|
+
const conversationIds = typeof (args.conversationIds) === 'object' ? args.conversationIds : []
|
|
22
|
+
const pageSize = parseInt(args.pageSize) ? parseInt(args.pageSize) : 30
|
|
23
|
+
|
|
24
|
+
return http({
|
|
25
|
+
url: '//chat.roblox.com/v2/multi-get-latest-messages?pageSize=' + pageSize + '&conversationIds=' + conversationIds.join('&conversationIds='),
|
|
26
|
+
options: {
|
|
27
|
+
method: 'GET',
|
|
28
|
+
jar,
|
|
29
|
+
resolveWithFullResponse: true
|
|
30
|
+
}
|
|
31
|
+
}).then((res) => {
|
|
32
|
+
if (res.statusCode !== 200) {
|
|
33
|
+
throw new RobloxAPIError(res)
|
|
34
|
+
} else {
|
|
35
|
+
return JSON.parse(res.body)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const events = require('events')
|
|
2
|
+
|
|
3
|
+
const onNotification = require('../client/onNotification.js').func
|
|
4
|
+
|
|
5
|
+
exports.optional = ['jar']
|
|
6
|
+
|
|
7
|
+
// Docs
|
|
8
|
+
/**
|
|
9
|
+
* 🔐 An event for when a conversation is created.
|
|
10
|
+
* @category Chat
|
|
11
|
+
* @alias onNewConversation
|
|
12
|
+
* @returns An EventEmitter that emits when a conversation is created.
|
|
13
|
+
* @example const noblox = require("noblox.js")
|
|
14
|
+
* // Login using your cookie
|
|
15
|
+
* const conversationEvent = noblox.onNewConversation()
|
|
16
|
+
* conversationEvent.on("data", function(data) {
|
|
17
|
+
* console.log("New conversation! ", data)
|
|
18
|
+
* })
|
|
19
|
+
* conversationEvent.on("error", function(err) {
|
|
20
|
+
* console.error("Something went wrong: ", err)
|
|
21
|
+
* // Handle error as needed
|
|
22
|
+
* })
|
|
23
|
+
**/
|
|
24
|
+
|
|
25
|
+
exports.func = (args) => {
|
|
26
|
+
const jar = args.jar
|
|
27
|
+
const onChatEvent = new events.EventEmitter()
|
|
28
|
+
const notifications = onNotification({ jar })
|
|
29
|
+
|
|
30
|
+
notifications.on('data', (name, message) => {
|
|
31
|
+
if (name === 'ChatNotifications' && message.Type === 'NewConversation') {
|
|
32
|
+
onChatEvent.emit('data', message.ConversationId)
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
notifications.on('error', (err) => {
|
|
37
|
+
onChatEvent.emit('error', err)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
notifications.on('connect', () => {
|
|
41
|
+
onChatEvent.emit('connect')
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
notifications.on('close', (internal) => {
|
|
45
|
+
if (internal) return
|
|
46
|
+
notifications.emit('close', true)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
return onChatEvent
|
|
50
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const events = require('events')
|
|
2
|
+
|
|
3
|
+
const onNotification = require('../client/onNotification.js').func
|
|
4
|
+
|
|
5
|
+
exports.optional = ['jar']
|
|
6
|
+
|
|
7
|
+
// Docs
|
|
8
|
+
/**
|
|
9
|
+
* 🔐 An event for when someone messages you via. chat. This event will only emit for messages sent via. chat windows on
|
|
10
|
+
* the website - those in the pop-up/overlay window. To handle messages sent via. the older email-like
|
|
11
|
+
* message function, see onMessage.
|
|
12
|
+
* @see [onMessage()](global.html#onMessage)
|
|
13
|
+
* @category Chat
|
|
14
|
+
* @alias onNewMessage
|
|
15
|
+
* @returns An EventEmitter that emits when someone messages you.
|
|
16
|
+
* @example const noblox = require("noblox.js")
|
|
17
|
+
* // Login using your cookie
|
|
18
|
+
* const messageEvent = noblox.onNewMessage()
|
|
19
|
+
* messageEvent.on("data", function(data) {
|
|
20
|
+
* console.log("New chat message! ", data)
|
|
21
|
+
* })
|
|
22
|
+
* messageEvent.on("error", function(err) {
|
|
23
|
+
* console.error("Something went wrong: ", err)
|
|
24
|
+
* // Handle error as needed
|
|
25
|
+
* })
|
|
26
|
+
**/
|
|
27
|
+
|
|
28
|
+
exports.func = (args) => {
|
|
29
|
+
const jar = args.jar
|
|
30
|
+
const newEvent = new events.EventEmitter()
|
|
31
|
+
const notifications = onNotification({ jar })
|
|
32
|
+
|
|
33
|
+
notifications.on('data', (name, message) => {
|
|
34
|
+
if (name === 'ChatNotifications' && message.Type === 'NewMessage') {
|
|
35
|
+
newEvent.emit('data', message.ConversationId)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
notifications.on('error', (err) => {
|
|
40
|
+
newEvent.emit('error', err)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
notifications.on('connect', () => {
|
|
44
|
+
newEvent.emit('connect')
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
notifications.on('close', (internal) => {
|
|
48
|
+
if (internal) return
|
|
49
|
+
notifications.emit('close', true)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
return newEvent
|
|
53
|
+
}
|