noblox.js
Advanced tools
Comparing version 4.6.3 to 4.6.4
// Exile specific members in a group, including by rank and by name. Useful for cleaning up bots. | ||
var rbx = require('noblox.js') | ||
var ProgressBar = require('progress') | ||
var cookie = '' | ||
var group = 0 | ||
var rank = null // Make this the rank number if you want to use rank. | ||
var pages = null | ||
const rbx = require('noblox.js') | ||
const ProgressBar = require('progress') | ||
const cookie = '' | ||
const group = 0 | ||
const rank = null // Make this the rank number if you want to use rank. | ||
const pages = null | ||
@@ -13,12 +13,12 @@ rbx.setCookie(cookie) | ||
/* pages = []; | ||
for (var i = 0; i <= 100; i++) { | ||
for (const i = 0; i <= 100; i++) { | ||
pages.push(i); | ||
} */ | ||
var getPlayers = new ProgressBar('Getting players [:bar] :current/:total = :percent :etas remaining ', { total: 10000 }) | ||
var promise = rbx.getPlayers(group, rank, pages) | ||
const getPlayers = new ProgressBar('Getting players [:bar] :current/:total = :percent :etas remaining ', { total: 10000 }) | ||
const promise = rbx.getPlayers(group, rank, pages) | ||
promise.then(function (res) { | ||
var plrs = res.players | ||
const plrs = res.players | ||
// This allows you to select only players that have a specific string in their name. | ||
/* for (var i = plrs.length - 1; i >= 0; i--) { | ||
var plr = plrs[i]; | ||
/* for (const i = plrs.length - 1; i >= 0; i--) { | ||
const plr = plrs[i]; | ||
if (!plr.name.includes('Bot')) { | ||
@@ -32,8 +32,8 @@ plrs.splice(i, 1); | ||
.then(function (roleset) { | ||
var exile = new ProgressBar('Exiling [:bar] :current/:total = :percent :etas remaining ', { total: 10000 }) | ||
const exile = new ProgressBar('Exiling [:bar] :current/:total = :percent :etas remaining ', { total: 10000 }) | ||
console.time('Time: ') | ||
var thread = rbx.threaded(function (i) { | ||
const thread = rbx.threaded(function (i) { | ||
return rbx.exile({ group: group, target: plrs[i].id, senderRolesetId: roleset }) | ||
}, 0, plrs.length) | ||
var ivl = setInterval(function () { | ||
const ivl = setInterval(function () { | ||
exile.update(thread.getStatus() / 100) | ||
@@ -48,3 +48,3 @@ }, 1000) | ||
}) | ||
var ivl = setInterval(function () { | ||
const ivl = setInterval(function () { | ||
getPlayers.update(promise.getStatus() / 100) | ||
@@ -51,0 +51,0 @@ }, 1000) |
// Delete posts from a group wall, including by post content and by author name. | ||
var rbx = require('noblox.js') | ||
var ProgressBar = require('progress') | ||
var cookie = '' | ||
var group = 0 | ||
const rbx = require('noblox.js') | ||
const ProgressBar = require('progress') | ||
const cookie = '' | ||
const group = 0 | ||
@@ -11,7 +11,7 @@ rbx.setCookie(cookie) | ||
/* pages = []; | ||
for (var i = 0; i <= 100; i++) { | ||
for (const i = 0; i <= 100; i++) { | ||
pages.push(i); | ||
} */ | ||
var wall = new ProgressBar('Getting wall [:bar] :current/:total = :percent :etas remaining ', { total: 10000 }) | ||
var promise = rbx.getWall({ | ||
const wall = new ProgressBar('Getting wall [:bar] :current/:total = :percent :etas remaining ', { total: 10000 }) | ||
const promise = rbx.getWall({ | ||
group: group, | ||
@@ -22,6 +22,6 @@ // page: pages, | ||
promise.then(function (wall) { | ||
var posts = wall.posts | ||
const posts = wall.posts | ||
// Remember these are reversed, it starts off with all the posts on the wall and you are REMOVING the ones you DON'T want to delete from the array | ||
/* for (var i = posts.length - 1; i >= 0; i--) { | ||
var post = posts[i]; | ||
/* for (const i = posts.length - 1; i >= 0; i--) { | ||
const post = posts[i]; | ||
if (post.author.name !== 'Bob') { // Delete all posts by Bob | ||
@@ -34,6 +34,6 @@ posts.splice(i, 1); | ||
} */ | ||
var deletion = new ProgressBar('Deleting posts [:bar] :current/:total = :percent :etas remaining ', { total: 10000 }) | ||
const deletion = new ProgressBar('Deleting posts [:bar] :current/:total = :percent :etas remaining ', { total: 10000 }) | ||
console.time('Time: ') | ||
var thread = rbx.threaded(function (i) { | ||
var post = posts[i] | ||
const thread = rbx.threaded(function (i) { | ||
const post = posts[i] | ||
return rbx.deleteWallPost({ | ||
@@ -49,3 +49,3 @@ group: group, | ||
}, 0, posts.length) | ||
var ivl = setInterval(function () { | ||
const ivl = setInterval(function () { | ||
deletion.update(thread.getStatus() / 100) | ||
@@ -58,3 +58,3 @@ }, 1000) | ||
}) | ||
var ivl = setInterval(function () { | ||
const ivl = setInterval(function () { | ||
wall.update(promise.getStatus() / 100) | ||
@@ -61,0 +61,0 @@ }, 1000) |
// Revert player ranks to their original rank in a certain range. | ||
var rbx = require('noblox.js') | ||
var ProgressBar = require('progress') | ||
var cookie = '' | ||
var group = 0 | ||
const rbx = require('noblox.js') | ||
const ProgressBar = require('progress') | ||
const cookie = '' | ||
const group = 0 | ||
var actionTypeId = 6 | ||
var targetUser = '' | ||
var startPage = 1 | ||
var endPage = 10 | ||
var afterDate = new Date('2000-01-01 00:00 CDT') | ||
const actionTypeId = 6 | ||
const targetUser = '' | ||
const startPage = 1 | ||
const endPage = 10 | ||
const afterDate = new Date('2000-01-01 00:00 CDT') | ||
rbx.setCookie(cookie) | ||
.then(function () { | ||
var pages = [] | ||
for (var i = startPage; i <= endPage; i++) { | ||
const pages = [] | ||
for (const i = startPage; i <= endPage; i++) { | ||
pages.push(i) | ||
} | ||
var audit = new ProgressBar('Getting audit log [:bar] :current/:total = :percent :etas remaining ', { total: 10000 }) | ||
var promise = rbx.getAuditLog({ | ||
const audit = new ProgressBar('Getting audit log [:bar] :current/:total = :percent :etas remaining ', { total: 10000 }) | ||
const promise = rbx.getAuditLog({ | ||
group: group, | ||
@@ -27,6 +27,6 @@ action: actionTypeId, | ||
promise.then(function (audit) { | ||
var logs = audit.logs | ||
var original = {} | ||
for (var i = 0; i < logs.length; i++) { | ||
var log = logs[i] | ||
const logs = audit.logs | ||
const original = {} | ||
for (const i = 0; i < logs.length; i++) { | ||
const log = logs[i] | ||
if (log.date > afterDate) { | ||
@@ -36,4 +36,4 @@ original[log.action.target] = log.action.params[0] | ||
} | ||
var reset = [] | ||
for (var target in original) { | ||
const reset = [] | ||
for (const target in original) { | ||
reset.push({ | ||
@@ -47,5 +47,5 @@ target: target, | ||
.then(function () { | ||
var revert = new ProgressBar('Reverting user ranks [:bar] :current/:total = :percent :etas remaining ', { total: 10000 }) | ||
const revert = new ProgressBar('Reverting user ranks [:bar] :current/:total = :percent :etas remaining ', { total: 10000 }) | ||
console.time('Time: ') | ||
var thread = rbx.threaded(function (i) { | ||
const thread = rbx.threaded(function (i) { | ||
return rbx.setRank({ | ||
@@ -57,3 +57,3 @@ group: group, | ||
}, 0, reset.length) | ||
var ivl = setInterval(function () { | ||
const ivl = setInterval(function () { | ||
revert.update(thread.getStatus() / 100) | ||
@@ -67,3 +67,3 @@ }, 1000) | ||
}) | ||
var ivl = setInterval(function () { | ||
const ivl = setInterval(function () { | ||
audit.update(promise.getStatus() / 100) | ||
@@ -70,0 +70,0 @@ }, 1000) |
// Save all the players in a group to a file with status updates. | ||
var rbx = require('noblox.js') | ||
var ProgressBar = require('progress') | ||
var js = require('JSONStream') | ||
var fs = require('fs') | ||
var group = 0 | ||
const rbx = require('noblox.js') | ||
const ProgressBar = require('progress') | ||
const js = require('JSONStream') | ||
const fs = require('fs') | ||
const group = 0 | ||
console.time('Time: ') | ||
var stream = js.stringify('[\n', ',\n', '\n]\n') | ||
const stream = js.stringify('[\n', ',\n', '\n]\n') | ||
stream.pipe(fs.createWriteStream('./players.json')) | ||
var promise = rbx.getPlayers({ | ||
const promise = rbx.getPlayers({ | ||
group: group, | ||
stream: stream | ||
}) | ||
var bar = new ProgressBar('Retrieving [:bar] :current/:total = :percent :etas remaining ', { total: 10000 }) | ||
var ivl = setInterval(function () { | ||
const bar = new ProgressBar('Retrieving [:bar] :current/:total = :percent :etas remaining ', { total: 10000 }) | ||
const ivl = setInterval(function () { | ||
bar.update(promise.getStatus() / 100) | ||
@@ -18,0 +18,0 @@ }, 1000) |
@@ -1,7 +0,7 @@ | ||
var rbx = require('noblox.js') | ||
var ProgressBar = require('progress') | ||
var js = require('JSONStream') | ||
var fs = require('fs') | ||
var group = 0 | ||
var cookie = '' | ||
const rbx = require('noblox.js') | ||
const ProgressBar = require('progress') | ||
const js = require('JSONStream') | ||
const fs = require('fs') | ||
const group = 0 | ||
const cookie = '' | ||
@@ -11,10 +11,10 @@ rbx.setCookie(cookie) | ||
console.time('Time: ') | ||
var stream = js.stringify('[\n', ',\n', '\n]\n') | ||
const stream = js.stringify('[\n', ',\n', '\n]\n') | ||
stream.pipe(fs.createWriteStream('./wall.json')) | ||
var promise = rbx.getWall({ | ||
const promise = rbx.getWall({ | ||
group: group, | ||
stream: stream | ||
}) | ||
var bar = new ProgressBar('Retrieving [:bar] :current/:total = :percent :etas remaining ', { total: 10000 }) | ||
var ivl = setInterval(function () { | ||
const bar = new ProgressBar('Retrieving [:bar] :current/:total = :percent :etas remaining ', { total: 10000 }) | ||
const ivl = setInterval(function () { | ||
bar.update(promise.getStatus() / 100) | ||
@@ -21,0 +21,0 @@ }, 1000) |
// Includes | ||
var http = require('../util/http.js').func | ||
var getProductInfo = require('./getProductInfo.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
const getProductInfo = require('./getProductInfo.js').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
@@ -12,4 +12,4 @@ // Args | ||
function buy (jar, token, product, price) { | ||
var robux = product.PriceInRobux || 0 | ||
var productId = product.ProductId | ||
const robux = product.PriceInRobux || 0 | ||
const productId = product.ProductId | ||
if (price) { | ||
@@ -21,4 +21,4 @@ if (typeof price === 'number') { | ||
} else if (typeof price === 'object') { | ||
var high = price.high | ||
var low = price.low | ||
const high = price.high | ||
const low = price.low | ||
if (high) { | ||
@@ -36,3 +36,3 @@ if (robux > high) { | ||
} | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: '//www.roblox.com/API/Item.ashx?rqtype=purchase&productID=' + productId + '&expectedCurrency=1&expectedPrice=' + robux + '&expectedSellerID=' + product.Creator.Id + '&userAssetID=' + product.UserAssetId, | ||
@@ -49,4 +49,4 @@ options: { | ||
.then(function (body) { | ||
var json = JSON.parse(body) | ||
var err = json.errorMsg | ||
const json = JSON.parse(body) | ||
let err = json.errorMsg | ||
if (json.showDivID === 'InsufficientFundsView') { | ||
@@ -64,3 +64,3 @@ err = 'You need ' + Math.abs(json.balanceAfterSale) + ' more robux to purchase this item.' | ||
function runWithToken (args) { | ||
var jar = args.jar | ||
const jar = args.jar | ||
return getGeneralToken({ | ||
@@ -67,0 +67,0 @@ jar: jar |
// Includes | ||
var generalRequest = require('../util/generalRequest.js').func | ||
const generalRequest = require('../util/generalRequest.js').func | ||
@@ -10,4 +10,4 @@ // Args | ||
function configure (jar, id, name, description, enableComments, sellForRobux, genreSelection) { | ||
var url = 'https://www.roblox.com/My/Item.aspx?ID=' + id | ||
var data = { | ||
const url = 'https://www.roblox.com/My/Item.aspx?ID=' + id | ||
const data = { | ||
__EVENTTARGET: 'ctl00$cphRoblox$SubmitButtonTop', | ||
@@ -14,0 +14,0 @@ ctl00$cphRoblox$DescriptionTextBox: description, |
// Includes | ||
var http = require('../util/http.js').func | ||
var cache = require('../cache') | ||
const http = require('../util/http.js').func | ||
const cache = require('../cache') | ||
@@ -10,3 +10,3 @@ // Args | ||
function getProductInfo (asset) { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: '//api.roblox.com/marketplace/productinfo?assetId=' + asset, | ||
@@ -29,3 +29,3 @@ options: { | ||
exports.func = function (args) { | ||
var asset = args.asset | ||
const asset = args.asset | ||
return cache.wrap('Product', asset, function () { | ||
@@ -32,0 +32,0 @@ return getProductInfo(asset) |
// Includes | ||
var http = require('../util/http.js').func | ||
var getVerification = require('../util/getVerification.js').func | ||
const http = require('../util/http.js').func | ||
const getVerification = require('../util/getVerification.js').func | ||
@@ -18,3 +18,3 @@ // Args | ||
}).then(function (ver) { | ||
var data = { | ||
const data = { | ||
name: name, | ||
@@ -43,7 +43,7 @@ assetTypeId: assetType, | ||
if (res.statusCode === 302) { | ||
var location = res.headers.location | ||
var errMsg = location.match('uploadedId=(.*)$') | ||
var match = location.match(/\d+$/) | ||
const location = res.headers.location | ||
const errMsg = location.match('uploadedId=(.*)$') | ||
const match = location.match(/\d+$/) | ||
if (match) { | ||
var id = parseInt(match[0], 10) | ||
const id = parseInt(match[0], 10) | ||
if (location.indexOf('/build/upload') === -1) { | ||
@@ -50,0 +50,0 @@ reject(new Error('Unknown redirect: ' + location)) |
// Includes | ||
var http = require('../util/http.js').func | ||
const http = require('../util/http.js').func | ||
@@ -10,3 +10,3 @@ // Args | ||
function upload (jar, data, itemOptions, asset) { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: '//data.roblox.com/Data/Upload.ashx?json=1&assetid=' + (asset || 0), | ||
@@ -24,4 +24,4 @@ options: { | ||
if (itemOptions) { | ||
var copyLocked = itemOptions.copyLocked | ||
var allowComments = itemOptions.allowComments | ||
const copyLocked = itemOptions.copyLocked | ||
const allowComments = itemOptions.allowComments | ||
httpOpt.url += '&type=Model&genreTypeId=1&name=' + | ||
@@ -43,4 +43,4 @@ itemOptions.name + | ||
if (res.statusCode === 200) { | ||
var body = res.body | ||
var parsed | ||
const body = res.body | ||
let parsed | ||
try { | ||
@@ -47,0 +47,0 @@ parsed = JSON.parse(body) |
@@ -22,7 +22,5 @@ const http = require('../util/http.js').func | ||
const json = JSON.parse(res.body) | ||
const result = (option ? json[option] : json) | ||
return result | ||
return (option ? json[option] : json) | ||
} | ||
}) | ||
} |
@@ -9,3 +9,3 @@ const http = require('../util/http.js').func | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: 'https://avatar.roblox.com/v1/avatar/assets/' + assetId + '/remove', | ||
@@ -12,0 +12,0 @@ options: { |
@@ -9,3 +9,3 @@ const http = require('../util/http.js').func | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: 'https://avatar.roblox.com/v1/avatar/assets/' + assetId + '/wear', | ||
@@ -12,0 +12,0 @@ options: { |
// Includes | ||
var levelOneCopy = require('../internal/levelOneCopy.js') | ||
const levelOneCopy = require('../internal/levelOneCopy.js') | ||
@@ -4,0 +4,0 @@ // Define |
// Includes | ||
var add = require('./add.js') | ||
var get = require('./get.js') | ||
const add = require('./add.js') | ||
const get = require('./get.js') | ||
// Define | ||
module.exports = function (cache, type, index, callbacks) { | ||
var got = get(cache, type, index) | ||
var item = got[0] | ||
var refresh = got[1] | ||
const got = get(cache, type, index) | ||
const item = got[0] | ||
const refresh = got[1] | ||
if (item) { | ||
callbacks.done(item) | ||
if (refresh) { | ||
var group = cache[type] | ||
const group = cache[type] | ||
group.refresh = false | ||
@@ -15,0 +15,0 @@ callbacks.add(function (element) { |
// Includes | ||
var levelOneCopy = require('../internal/levelOneCopy.js') | ||
const levelOneCopy = require('../internal/levelOneCopy.js') | ||
@@ -7,7 +7,8 @@ // Define | ||
if (cache[type]) { | ||
var group = cache[type] | ||
var cached = group.items[index] | ||
const group = cache[type] | ||
const cached = group.items[index] | ||
if (cached && cached.time) { | ||
let passed | ||
if (!group.permanent) { | ||
var passed = Date.now() / 1000 - cached.time | ||
passed = Date.now() / 1000 - cached.time | ||
if (passed > group.expire) { | ||
@@ -17,3 +18,3 @@ return false | ||
} | ||
var item = cached.item | ||
let item = cached.item | ||
if (item instanceof Object) { | ||
@@ -20,0 +21,0 @@ item = levelOneCopy(item) |
// Includes | ||
var newCache = require('./new.js') | ||
var add = require('./add.js') | ||
var addIf = require('./addIf.js') | ||
var get = require('./get.js') | ||
var clear = require('./clear.js') | ||
var wrap = require('./wrap.js') | ||
const newCache = require('./new.js') | ||
const add = require('./add.js') | ||
const addIf = require('./addIf.js') | ||
const get = require('./get.js') | ||
const clear = require('./clear.js') | ||
const wrap = require('./wrap.js') | ||
@@ -9,0 +9,0 @@ // Define |
// Define | ||
module.exports = function (types) { | ||
var cache = {} | ||
for (var i = 0; i < types.length; i++) { | ||
var type = types[i] | ||
var expireValue = type.expire | ||
var permanent = expireValue === true | ||
var expire = (permanent || expireValue === false ? 0 : expireValue) | ||
const cache = {} | ||
for (let i = 0; i < types.length; i++) { | ||
const type = types[i] | ||
const expireValue = type.expire | ||
const permanent = expireValue === true | ||
const expire = (permanent || expireValue === false ? 0 : expireValue) | ||
cache[type.name] = { items: {}, expire: expire, refresh: type.refresh, permanent: permanent } | ||
@@ -10,0 +10,0 @@ } |
// Includes | ||
var addIf = require('./addIf.js') | ||
var options = require('../options.js') | ||
var promise = require('../internal/promise.js') | ||
const addIf = require('./addIf.js') | ||
const options = require('../options.js') | ||
const promise = require('../internal/promise.js') | ||
// Define | ||
function wrap (type, index, func) { | ||
var cache = options.cache | ||
var group = cache[type] | ||
const cache = options.cache | ||
const group = cache[type] | ||
if (group.expire > 0 || group.permanent) { | ||
@@ -11,0 +11,0 @@ return promise(function (resolve, reject) { |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
@@ -9,5 +8,5 @@ // Args | ||
function getGameInstances (jar, token, placeId, startIndex) { | ||
function getGameInstances (jar, placeId, startIndex) { | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//www.roblox.com/games/getgameinstancesjson?placeId=${placeId}&startindex=${startIndex}`, | ||
@@ -17,5 +16,2 @@ options: { | ||
jar: jar, | ||
headers: { | ||
'X-CSRF-TOKEN': token | ||
}, | ||
resolveWithFullResponse: true | ||
@@ -31,3 +27,3 @@ } | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -46,8 +42,4 @@ }) | ||
exports.func = function (args) { | ||
const jar = args.jar | ||
const startIndex = Number(args.startIndex) || 0 | ||
return getGeneralToken({ jar: jar }).then(function (xcsrf) { | ||
return getGameInstances(args.jar, xcsrf, args.placeId, startIndex) | ||
}) | ||
return getGameInstances(args.jar, args.placeId, startIndex) | ||
} |
// Includes | ||
var setRank = require('./setRank.js').func | ||
var getRoles = require('./getRoles.js').func | ||
var getRankNameInGroup = require('./getRankNameInGroup.js').func | ||
const setRank = require('./setRank.js').func | ||
const getRoles = require('./getRoles.js').func | ||
const getRankNameInGroup = require('./getRankNameInGroup.js').func | ||
@@ -12,6 +12,6 @@ // Args | ||
exports.func = function (args) { | ||
var group = args.group | ||
var target = args.target | ||
var amount = args.change | ||
var jar = args.jar | ||
const group = args.group | ||
const target = args.target | ||
const amount = args.change | ||
const jar = args.jar | ||
return getRankNameInGroup({ group: group, userId: target }) | ||
@@ -24,9 +24,9 @@ .then(function (rank) { | ||
.then(function (roles) { | ||
for (var i = 0; i < roles.length; i++) { | ||
var role = roles[i] | ||
var thisRank = role.name | ||
for (let i = 0; i < roles.length; i++) { | ||
const role = roles[i] | ||
const thisRank = role.name | ||
if (thisRank === rank) { | ||
var change = i + amount | ||
var found = roles[change] | ||
const change = i + amount | ||
const found = roles[change] | ||
@@ -33,0 +33,0 @@ if (!found) { |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
@@ -12,3 +12,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//groups.roblox.com/v1/groups/${group}/wall/posts/${postId}`, | ||
@@ -31,3 +31,3 @@ options: { | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -43,4 +43,4 @@ }) | ||
exports.func = function (args) { | ||
var group = args.group | ||
var jar = args.jar | ||
const group = args.group | ||
const jar = args.jar | ||
return getGeneralToken({ jar: jar }) | ||
@@ -47,0 +47,0 @@ .then(function (xcsrf) { |
// Includes | ||
var changeRank = require('./changeRank.js').func | ||
const changeRank = require('./changeRank.js').func | ||
@@ -4,0 +4,0 @@ // Args |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
@@ -11,3 +11,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `https://groups.roblox.com/v1/groups/${group}/users/${target}`, | ||
@@ -14,0 +14,0 @@ options: { |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
@@ -8,5 +7,5 @@ exports.required = ['group'] | ||
function getAuditLog (group, actionType, userId, sortOrder, limit, cursor, jar, xcsrf) { | ||
function getAuditLog (group, actionType, userId, sortOrder, limit, cursor, jar) { | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `https://groups.roblox.com/v1/groups/${group}/audit-log?actionType=${actionType}&cursor=${cursor}&limit=${limit}&sortOrder=${sortOrder}&userId=${userId}`, | ||
@@ -16,6 +15,3 @@ options: { | ||
resolveWithFullResponse: true, | ||
jar: jar, | ||
headers: { | ||
'X-CSRF-TOKEN': xcsrf | ||
} | ||
jar: jar | ||
} | ||
@@ -48,6 +44,3 @@ } | ||
const cursor = args.cursor || '' | ||
return getGeneralToken({ jar: jar }) | ||
.then(function (xcsrf) { | ||
return getAuditLog(args.group, actionType, userId, sortOrder, limit, cursor, jar, xcsrf) | ||
}) | ||
return getAuditLog(args.group, actionType, userId, sortOrder, limit, cursor, jar) | ||
} |
// Includes | ||
var http = require('../util/http.js').func | ||
const http = require('../util/http.js').func | ||
@@ -11,3 +11,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//groups.roblox.com/v1/groups/${groupId}`, | ||
@@ -26,3 +26,3 @@ options: { | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -29,0 +29,0 @@ }) |
@@ -1,3 +0,2 @@ | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
@@ -7,5 +6,5 @@ exports.required = ['group'] | ||
function getTransactions (group, transactionType, limit, cursor, jar, xcsrf) { | ||
function getTransactions (group, transactionType, limit, cursor, jar) { | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `https://economy.roblox.com/v1/groups/${group}/transactions?limit=${limit}&transactionType=${transactionType}&cursor=${cursor}`, | ||
@@ -15,6 +14,3 @@ options: { | ||
resolveWithFullResponse: true, | ||
jar: jar, | ||
headers: { | ||
'X-CSRF-TOKEN': xcsrf | ||
} | ||
jar: jar | ||
} | ||
@@ -41,10 +37,6 @@ } | ||
exports.func = function (args) { | ||
const jar = args.jar | ||
const transactionType = args.transactionType || 'Sale' | ||
const limit = args.limit || 100 | ||
const cursor = args.cursor || '' | ||
return getGeneralToken({ jar: jar }) | ||
.then(function (xcsrf) { | ||
return getTransactions(args.group, transactionType, limit, cursor, xcsrf) | ||
}) | ||
return getTransactions(args.group, transactionType, limit, cursor) | ||
} |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
const Promise = require('bluebird') | ||
@@ -10,5 +10,5 @@ // Args | ||
// Define | ||
function getJoinRequests (jar, token, group, sortOrder, limit, cursor) { | ||
function getJoinRequests (jar, group, sortOrder, limit, cursor) { | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//groups.roblox.com/v1/groups/${group}/join-requests?limit=${limit}&sortOrder=${sortOrder}&cursor=${cursor}`, | ||
@@ -18,5 +18,2 @@ options: { | ||
jar: jar, | ||
headers: { | ||
'X-CSRF-TOKEN': token | ||
}, | ||
resolveWithFullResponse: true | ||
@@ -32,3 +29,3 @@ } | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -48,6 +45,3 @@ }) | ||
const cursor = args.cursor || '' | ||
return getGeneralToken({ jar: jar }) | ||
.then(function (xcsrf) { | ||
return getJoinRequests(jar, xcsrf, args.group, sortOrder, limit, cursor) | ||
}) | ||
return getJoinRequests(jar, args.group, sortOrder, limit, cursor) | ||
} |
// Includes | ||
var http = require('../util/http.js').func | ||
const http = require('../util/http.js').func | ||
@@ -9,3 +9,3 @@ // Args | ||
function getLogo (group) { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: '//api.roblox.com/groups/' + group | ||
@@ -17,4 +17,3 @@ } | ||
if (!group) throw new Error('Not found') | ||
var logo = group.EmblemUrl | ||
return logo | ||
return group.EmblemUrl | ||
}) | ||
@@ -21,0 +20,0 @@ } |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
@@ -10,5 +9,5 @@ // Args | ||
// Define | ||
function getPlayersInRoleOnPage (jar, token, group, rolesetId, sortOrder, limit, cursor) { | ||
function getPlayersInRoleOnPage (jar, group, rolesetId, sortOrder, limit, cursor) { | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//groups.roblox.com/v1/groups/${group}/roles/${rolesetId}/users?cursor=${cursor}&limit=${limit}&sortOrder=${sortOrder}`, | ||
@@ -18,5 +17,2 @@ options: { | ||
jar: jar, | ||
headers: { | ||
'X-CSRF-TOKEN': token | ||
}, | ||
resolveWithFullResponse: true | ||
@@ -32,3 +28,3 @@ } | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -43,10 +39,10 @@ }) | ||
function getPlayersInRole (jar, token, group, rolesetId, sortOrder, limit, cursor, currentPlayers) { | ||
function getPlayersInRole (jar, group, rolesetId, sortOrder, limit, cursor, currentPlayers) { | ||
return new Promise((resolve, reject) => { | ||
if (!currentPlayers) currentPlayers = [] | ||
getPlayersInRoleOnPage(jar, token, group, rolesetId, sortOrder, 100, cursor, currentPlayers) | ||
getPlayersInRoleOnPage(jar, group, rolesetId, sortOrder, 100, cursor, currentPlayers) | ||
.then(function (pageData) { | ||
var nextPageCursor = pageData.nextPageCursor | ||
var dataArray = pageData.data | ||
const nextPageCursor = pageData.nextPageCursor | ||
const dataArray = pageData.data | ||
@@ -63,3 +59,3 @@ if (!dataArray) return reject(new Error('Error while retreiving players!')) | ||
getPlayersInRole(jar, token, group, rolesetId, sortOrder, limit, nextPageCursor, currentPlayers) | ||
getPlayersInRole(jar, group, rolesetId, sortOrder, limit, nextPageCursor, currentPlayers) | ||
.then(function (newCurrentPlayers) { | ||
@@ -72,25 +68,23 @@ return resolve(newCurrentPlayers) | ||
function getPlayersInRoles (jar, token, group, rolesetIds, sortOrder, limit, cursor) { | ||
return async () => { | ||
var currentPlayers = [] | ||
async function getPlayersInRoles (jar, group, rolesetIds, sortOrder, limit, cursor) { | ||
let currentPlayers = [] | ||
for (let i = 0; i < rolesetIds.length; i++) { | ||
const rolesetId = rolesetIds[i] | ||
const roleLimit = limit <= 0 ? limit : limit - currentPlayers.length | ||
for (let i = 0; i < rolesetIds.length; i++) { | ||
const rolesetId = rolesetIds[i] | ||
const roleLimit = limit <= 0 ? limit : limit - currentPlayers.length | ||
await getPlayersInRole(jar, token, group, rolesetId, sortOrder, roleLimit, cursor) | ||
.then((newData) => { | ||
currentPlayers = currentPlayers.concat(newData) | ||
}) | ||
.catch((error) => { | ||
throw new Error(error) | ||
}) | ||
await getPlayersInRole(jar, group, rolesetId, sortOrder, roleLimit, cursor) | ||
.then((newData) => { | ||
currentPlayers = currentPlayers.concat(newData) | ||
}) | ||
.catch((error) => { | ||
throw new Error(error) | ||
}) | ||
if (limit > 0 && currentPlayers.length >= limit) { | ||
return currentPlayers | ||
} | ||
if (limit > 0 && currentPlayers.length >= limit) { | ||
return currentPlayers | ||
} | ||
} | ||
return currentPlayers | ||
} | ||
return currentPlayers | ||
} | ||
@@ -104,6 +98,3 @@ | ||
const cursor = args.cursor || '' | ||
return getGeneralToken({ jar: jar }) | ||
.then(function (xcsrf) { | ||
return getPlayersInRoles(jar, xcsrf, args.group, rolesetIds, sortOrder, limit, cursor) | ||
}) | ||
return getPlayersInRoles(jar, args.group, rolesetIds, sortOrder, limit, cursor) | ||
} |
// Includes | ||
var http = require('../util/http.js').func | ||
var cache = require('../cache') | ||
const http = require('../util/http.js').func | ||
const cache = require('../cache') | ||
@@ -27,3 +27,3 @@ // Args | ||
exports.func = function (args) { | ||
var id = args.userId | ||
const id = args.userId | ||
return cache.wrap('Rank', id, function () { | ||
@@ -30,0 +30,0 @@ return getRankInGroup(args.group, id) |
// Includes | ||
var http = require('../util/http.js').func | ||
var cache = require('../cache') | ||
const http = require('../util/http.js').func | ||
const cache = require('../cache') | ||
@@ -27,3 +27,3 @@ // Args | ||
exports.func = function (args) { | ||
var id = args.userId | ||
const id = args.userId | ||
return cache.wrap('Rank', id + 'Name', function () { | ||
@@ -30,0 +30,0 @@ return getRankNameInGroup(args.group, id) |
// Dependencies | ||
var entities = require('entities') | ||
var Promise = require('bluebird') | ||
const entities = require('entities') | ||
const Promise = require('bluebird') | ||
// Includes | ||
var getRoles = require('./getRoles.js').func | ||
const getRoles = require('./getRoles.js').func | ||
@@ -13,13 +13,13 @@ // Args | ||
function getRole (args) { | ||
var roles = args.roles | ||
var rank = args.rank | ||
var name = args.name | ||
var id = args.id | ||
var search = rank || name || id | ||
var found = {} | ||
var result = [] | ||
var isObject = search instanceof Object | ||
for (var i = 0; i < roles.length; i++) { | ||
var role = roles[i] | ||
var find | ||
const roles = args.roles | ||
const rank = args.rank | ||
const name = args.name | ||
const id = args.id | ||
const search = rank || name || id | ||
const found = {} | ||
const result = [] | ||
const isObject = search instanceof Object | ||
for (let i = 0; i < roles.length; i++) { | ||
const role = roles[i] | ||
let find | ||
if (rank) { | ||
@@ -35,3 +35,3 @@ find = role.rank | ||
} | ||
var index = isObject ? search.indexOf(find) : 0 | ||
const index = isObject ? search.indexOf(find) : 0 | ||
if (isObject ? index > -1 : search === find) { | ||
@@ -38,0 +38,0 @@ found[find] = true |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
@@ -8,5 +7,5 @@ exports.required = ['group', 'roleId'] | ||
function getRolePermissions (group, roleId, jar, xcsrf) { | ||
function getRolePermissions (group, roleId, jar) { | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `https://groups.roblox.com/v1/groups/${group}/roles/${roleId}/permissions`, | ||
@@ -16,6 +15,3 @@ options: { | ||
resolveWithFullResponse: true, | ||
jar: jar, | ||
headers: { | ||
'X-CSRF-TOKEN': xcsrf | ||
} | ||
jar: jar | ||
} | ||
@@ -43,6 +39,3 @@ } | ||
const jar = args.jar | ||
return getGeneralToken({ jar: jar }) | ||
.then(function (xcsrf) { | ||
return getRolePermissions(args.group, args.roleId, jar, xcsrf) | ||
}) | ||
return getRolePermissions(args.group, args.roleId, jar) | ||
} |
// Includes | ||
var http = require('../util/http.js').func | ||
var cache = require('../cache') | ||
const http = require('../util/http.js').func | ||
const cache = require('../cache') | ||
@@ -11,3 +11,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `https://groups.roblox.com/v1/groups/${group}/roles` | ||
@@ -17,6 +17,6 @@ } | ||
.then(function (body) { | ||
var roles = JSON.parse(body).roles | ||
let roles = JSON.parse(body).roles | ||
roles = roles.sort((a, b) => a.rank - b.rank) | ||
for (var i = 0; i < roles.length; i++) { | ||
var role = roles[i] | ||
for (let i = 0; i < roles.length; i++) { | ||
const role = roles[i] | ||
role.ID = role.id | ||
@@ -31,3 +31,3 @@ delete role.id | ||
exports.func = function (args) { | ||
var group = args.group | ||
const group = args.group | ||
return cache.wrap('Roles', group, function () { | ||
@@ -34,0 +34,0 @@ return getRoles(group) |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
@@ -10,5 +9,5 @@ // Args | ||
// Define | ||
function getShout (group, jar, xcsrf) { | ||
function getShout (group, jar) { | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `https://groups.roblox.com/v1/groups/${group}`, | ||
@@ -18,6 +17,3 @@ options: { | ||
resolveWithFullResponse: true, | ||
jar: jar, | ||
headers: { | ||
'X-CSRF-TOKEN': xcsrf | ||
} | ||
jar: jar | ||
} | ||
@@ -43,7 +39,3 @@ } | ||
exports.func = function (args) { | ||
const jar = args.jar | ||
return getGeneralToken({ jar: jar }) | ||
.then(function (xcsrf) { | ||
return getShout(args.group, args.jar, xcsrf) | ||
}) | ||
return getShout(args.group, args.jar) | ||
} |
@@ -1,3 +0,2 @@ | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
@@ -7,5 +6,5 @@ exports.required = ['group'] | ||
function getPosts (group, sortOrder, limit, cursor, jar, xcsrf) { | ||
function getPosts (group, sortOrder, limit, cursor, jar) { | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `https://groups.roblox.com/v2/groups/${group}/wall/posts?limit=${limit}&sortOrder=${sortOrder}&cursor=${cursor}`, | ||
@@ -15,6 +14,3 @@ options: { | ||
resolveWithFullResponse: true, | ||
jar: jar, | ||
headers: { | ||
'X-CSRF-TOKEN': xcsrf | ||
} | ||
jar: jar | ||
} | ||
@@ -41,10 +37,6 @@ } | ||
exports.func = function (args) { | ||
const jar = args.jar | ||
const sortOrder = args.sortOrder || 'Asc' | ||
const limit = args.limit || 100 | ||
const cursor = args.cursor || '' | ||
return getGeneralToken({ jar: jar }) | ||
.then(function (xcsrf) { | ||
return getPosts(args.group, sortOrder, limit, cursor, args.jar, xcsrf) | ||
}) | ||
return getPosts(args.group, sortOrder, limit, cursor, args.jar) | ||
} |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
@@ -12,3 +12,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//groups.roblox.com/v1/groups/${group}/payouts${recurring ? '/recurring' : ''}`, | ||
@@ -36,3 +36,3 @@ options: { | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -49,16 +49,12 @@ }) | ||
function isPercentage (num) { | ||
if (num >= 0 && num <= 100 && num % 1 === 0) { | ||
return true | ||
} else { | ||
return false | ||
} | ||
return num >= 0 && num <= 100 && num % 1 === 0 | ||
} | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
var member = args.member | ||
var amount = args.amount | ||
var recurring = args.recurring || false | ||
var usePercentage = recurring ? true : args.usePercentage | ||
var data = [] | ||
const jar = args.jar | ||
let member = args.member | ||
let amount = args.amount | ||
const recurring = args.recurring || false | ||
const usePercentage = recurring ? true : args.usePercentage | ||
const data = [] | ||
@@ -71,5 +67,5 @@ if (!(member instanceof Array)) { | ||
} | ||
var total = 0 | ||
for (var i = 0; i < member.length; i++) { | ||
var value = amount[i] | ||
let total = 0 | ||
for (let i = 0; i < member.length; i++) { | ||
const value = amount[i] | ||
if (usePercentage) { | ||
@@ -76,0 +72,0 @@ if (!isPercentage(value)) { |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
@@ -11,3 +11,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `https://groups.roblox.com/v1/groups/${group}/join-requests/users/${userId}`, | ||
@@ -14,0 +14,0 @@ options: { |
// Includes | ||
var generalRequest = require('../util/generalRequest.js').func | ||
const generalRequest = require('../util/generalRequest.js').func | ||
@@ -10,3 +10,3 @@ // Args | ||
exports.func = function (args) { | ||
var events = { | ||
const events = { | ||
__EVENTTARGET: 'JoinGroupDiv', | ||
@@ -13,0 +13,0 @@ __EVENTARGUMENT: 'Click' |
// Includes | ||
var http = require('../util/http.js').func | ||
var getCurrentUser = require('../util/getCurrentUser').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
const getCurrentUser = require('../util/getCurrentUser').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
@@ -13,3 +13,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `https://groups.roblox.com/v1/groups/${group}/users/${userId}`, | ||
@@ -16,0 +16,0 @@ options: { |
// Includes | ||
var shortPoll = require('../util/shortPoll.js').func | ||
var getAuditLog = require('./getAuditLog.js').func | ||
const shortPoll = require('../util/shortPoll.js').func | ||
const getAuditLog = require('./getAuditLog.js').func | ||
@@ -11,3 +11,3 @@ // Args | ||
exports.func = function (args) { | ||
var empty = false | ||
let empty = false | ||
return shortPoll({ | ||
@@ -17,7 +17,7 @@ getLatest: function (latest) { | ||
.then(function (audit) { | ||
var given = [] | ||
const given = [] | ||
if (audit) { | ||
for (var key in audit.data) { | ||
for (const key in audit.data) { | ||
if (Object.prototype.hasOwnProperty.call(audit.data, key)) { | ||
var date = new Date(audit.data[key].created.slice(0, audit.data[key].created.lastIndexOf('.'))) | ||
const date = new Date(audit.data[key].created.slice(0, audit.data[key].created.lastIndexOf('.'))) | ||
if (date > latest) { | ||
@@ -29,3 +29,3 @@ latest = date | ||
} else if (!empty) { | ||
date = new Date() | ||
const date = new Date() | ||
given.push({ audit: '', author: { name: '', id: '-1' }, date: date }) | ||
@@ -32,0 +32,0 @@ latest = date |
// Dependencies | ||
var Promise = require('bluebird') | ||
const Promise = require('bluebird') | ||
// Includes | ||
var settings = require('../../settings.json') | ||
var shortPoll = require('../util/shortPoll.js').func | ||
var getJoinRequests = require('./getJoinRequests.js').func | ||
var handleJoinRequest = require('./handleJoinRequest.js').func | ||
const settings = require('../../settings.json') | ||
const shortPoll = require('../util/shortPoll.js').func | ||
const getJoinRequests = require('./getJoinRequests.js').func | ||
const handleJoinRequest = require('./handleJoinRequest.js').func | ||
@@ -16,8 +16,7 @@ // Args | ||
const requests = [] | ||
await getJoinRequests({ jar, group, cursor, limit: 100 }).timeout(settings.event.timeout).then(async (res) => { | ||
requests.push.apply(requests, res.data) | ||
if (res.nextPageCursor) { | ||
requests.push.apply(requests, await getRequests(jar, group, res.nextPageCursor)) | ||
} | ||
}) | ||
const res = await getJoinRequests({ jar, group, cursor, limit: 100 }).timeout(settings.event.timeout) | ||
requests.push.apply(requests, res.data) | ||
if (res.nextPageCursor) { | ||
requests.push.apply(requests, await getRequests(jar, group, res.nextPageCursor)) | ||
} | ||
return requests | ||
@@ -28,8 +27,8 @@ } | ||
exports.func = function (args) { | ||
var group = args.group | ||
var jar = args.jar | ||
const group = args.group | ||
const jar = args.jar | ||
function getLatest (latest, evt) { | ||
return getRequests(jar, group) | ||
.then(function (requests) { | ||
var complete = { | ||
const complete = { | ||
data: [], | ||
@@ -39,8 +38,8 @@ latest: -2, | ||
} | ||
var handled = 0 | ||
var promise | ||
let handled = 0 | ||
let promise | ||
if (requests.length > 0) { | ||
promise = new Promise(function (resolve, reject) { | ||
evt.on('handle', function (request, accept, callback) { | ||
var id = request.requester.userId | ||
const id = request.requester.userId | ||
handleJoinRequest({ jar: jar, group, userId: id, accept: accept }) | ||
@@ -61,4 +60,4 @@ .then(function () { | ||
} | ||
for (var i = 0; i < requests.length; i++) { | ||
var request = requests[i] | ||
for (let i = 0; i < requests.length; i++) { | ||
const request = requests[i] | ||
evt.emit('data', request) | ||
@@ -65,0 +64,0 @@ } |
// Includes | ||
var shortPoll = require('../util/shortPoll.js').func | ||
var getShout = require('./getShout.js').func | ||
const shortPoll = require('../util/shortPoll.js').func | ||
const getShout = require('./getShout.js').func | ||
@@ -11,3 +11,3 @@ // Args | ||
exports.func = function (args) { | ||
var empty = false | ||
let empty = false | ||
return shortPoll({ | ||
@@ -17,5 +17,5 @@ getLatest: function (latest) { | ||
.then(function (shout) { | ||
var given = [] | ||
const given = [] | ||
if (shout) { | ||
var date = new Date(shout.updated.slice(0, shout.updated.lastIndexOf('.'))) | ||
const date = new Date(shout.updated.slice(0, shout.updated.lastIndexOf('.'))) | ||
if (date > latest) { | ||
@@ -27,3 +27,3 @@ latest = date | ||
} else if (!empty) { | ||
date = new Date() | ||
const date = new Date() | ||
given.push({ message: '', author: { name: '', id: '-1' }, date: date }) | ||
@@ -30,0 +30,0 @@ latest = date |
// Includes | ||
var shortPoll = require('../util/shortPoll.js').func | ||
var getWall = require('./getWall.js').func | ||
const shortPoll = require('../util/shortPoll.js').func | ||
const getWall = require('./getWall.js').func | ||
@@ -11,5 +11,5 @@ // Args | ||
exports.func = function (args) { | ||
var group = args.group | ||
var jar = args.jar | ||
var view = args.view | ||
const group = args.group | ||
const jar = args.jar | ||
const view = args.view | ||
return shortPoll({ | ||
@@ -19,7 +19,7 @@ getLatest: function (latest) { | ||
.then(function (wall) { | ||
var posts = wall.data | ||
var given = [] | ||
for (var i = posts.length - 1; i >= 0; i--) { | ||
var post = posts[i] | ||
var id = post.id | ||
const posts = wall.data | ||
const given = [] | ||
for (let i = posts.length - 1; i >= 0; i--) { | ||
const post = posts[i] | ||
const id = post.id | ||
if (id > latest) { | ||
@@ -26,0 +26,0 @@ latest = id |
// Includes | ||
var changeRank = require('./changeRank.js').func | ||
const changeRank = require('./changeRank.js').func | ||
@@ -4,0 +4,0 @@ // Args |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
var getRole = require('./getRole.js').func | ||
const http = require('../util/http.js').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
const getRole = require('./getRole.js').func | ||
@@ -13,3 +13,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//groups.roblox.com/v1/groups/${group}/users/${target}`, | ||
@@ -36,3 +36,3 @@ options: { | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -48,3 +48,3 @@ }) | ||
function runWithToken (args) { | ||
var jar = args.jar | ||
const jar = args.jar | ||
return getGeneralToken({ jar: jar }) | ||
@@ -58,4 +58,4 @@ .then(function (xcsrf) { | ||
if (!args.roleset) { | ||
var rank = args.rank | ||
var opt = { | ||
const rank = args.rank | ||
const opt = { | ||
group: args.group | ||
@@ -62,0 +62,0 @@ } |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
@@ -11,3 +11,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `https://groups.roblox.com/v1/groups/${group}/status`, | ||
@@ -34,3 +34,3 @@ options: { | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -37,0 +37,0 @@ }) |
@@ -1,10 +0,10 @@ | ||
var path = require('path') | ||
var fs = require('fs') | ||
var include = ['cache'] | ||
const path = require('path') | ||
const fs = require('fs') | ||
const include = ['cache'] | ||
var rbx = {} | ||
const rbx = {} | ||
function search (dir) { | ||
require('fs').readdirSync(dir).forEach(function (file) { | ||
var stat = fs.statSync(path.join(dir, file)) | ||
const stat = fs.statSync(path.join(dir, file)) | ||
if (stat.isFile() || include.indexOf(file) !== -1) { | ||
@@ -20,4 +20,4 @@ rbx[file.replace('.js', '')] = require(dir + '/' + file) | ||
for (var name in rbx) { | ||
var exporter = rbx[name] | ||
for (const name in rbx) { | ||
const exporter = rbx[name] | ||
if (exporter.func) { | ||
@@ -24,0 +24,0 @@ module.exports[name] = rbx.wrap.wrapExport(exporter.func, exporter.required || [], exporter.optional || []) |
@@ -7,5 +7,5 @@ // Define | ||
module.exports = function (obj) { | ||
var newObj = shallowCopy(obj) | ||
for (var index in obj) { | ||
var value = obj[index] | ||
const newObj = shallowCopy(obj) | ||
for (const index in obj) { | ||
let value = obj[index] | ||
if (value instanceof Object) { | ||
@@ -12,0 +12,0 @@ value = shallowCopy(value) |
// Dependencies | ||
var Promise = require('bluebird') | ||
const Promise = require('bluebird') | ||
@@ -4,0 +4,0 @@ // Define |
// Includes | ||
var promise = require('./promise.js') | ||
var options = require('../options.js') | ||
const promise = require('./promise.js') | ||
const options = require('../options.js') | ||
// Define | ||
module.exports = function (type, index, func, handler) { | ||
var group = options.queue[type] | ||
const group = options.queue[type] | ||
if (!group[index]) { | ||
@@ -13,3 +13,3 @@ group[index] = { | ||
} | ||
var home = group[index] | ||
const home = group[index] | ||
function run (time) { | ||
@@ -22,2 +22,3 @@ return function (resolve, reject) { | ||
} | ||
const jobs = home.jobs | ||
function deactivate (err) { | ||
@@ -34,8 +35,7 @@ jobs.shift() | ||
if (group.delay > 0) { | ||
var jobs = home.jobs | ||
var delay = group.delay | ||
var last = home.last | ||
const delay = group.delay | ||
const last = home.last | ||
if (jobs.length === 0) { | ||
var item | ||
var diff = Date.now() - last | ||
let item | ||
const diff = Date.now() - last | ||
if (!last || diff > delay) { | ||
@@ -50,8 +50,8 @@ item = func() | ||
} else { | ||
var job = jobs[jobs.length - 1].then(function () { | ||
var item = promise(run(delay)) | ||
const job = jobs[jobs.length - 1].then(function () { | ||
const item = promise(run(delay)) | ||
item.then(next).catch(deactivate) | ||
return item | ||
}).catch(function (err) { | ||
var item = handler && handler(err) ? func() : promise(run(delay)) | ||
const item = handler && handler(err) ? func() : promise(run(delay)) | ||
item.then(next).catch(deactivate) | ||
@@ -58,0 +58,0 @@ return item |
/* | ||
var args = ['jar', 'username', 'password'] | ||
const args = ['jar', 'username', 'password'] | ||
@@ -15,16 +15,16 @@ raw function login (jar, username, password) | ||
exports.wrapExport = function (wrapFunction, required, optional) { | ||
var reqLength = required.length | ||
const reqLength = required.length | ||
if ((reqLength + optional.length) > 0) { | ||
return function () { | ||
var options = {} | ||
var length = arguments.length | ||
var assume = false | ||
let options = {} | ||
const length = arguments.length | ||
let assume = false | ||
if (length > 0) { | ||
var first = arguments[0] | ||
var collectOptions = true | ||
const first = arguments[0] | ||
let collectOptions = true | ||
if (length === 1 && (first instanceof Object)) { | ||
assume = true | ||
var firstArg = required[0] || optional | ||
const firstArg = required[0] || optional | ||
if (firstArg && firstArg instanceof Object) { | ||
for (var i = 0; i < firstArg.length; i++) { | ||
for (let i = 0; i < firstArg.length; i++) { | ||
if (first[firstArg[i]]) { | ||
@@ -42,5 +42,5 @@ options = first | ||
if (collectOptions) { | ||
for (i = 0; i <= length; i++) { | ||
var list = (i >= reqLength ? optional : required) | ||
var index = list[(i >= reqLength ? (i - reqLength) : i)] | ||
for (let i = 0; i <= length; i++) { | ||
const list = (i >= reqLength ? optional : required) | ||
const index = list[(i >= reqLength ? (i - reqLength) : i)] | ||
if (index instanceof Object) { | ||
@@ -54,7 +54,7 @@ options[index[0]] = arguments[i] | ||
} | ||
for (i = 0; i < reqLength; i++) { | ||
var arg = required[i] | ||
var found = false | ||
for (let i = 0; i < reqLength; i++) { | ||
const arg = required[i] | ||
let found = false | ||
if (arg instanceof Object) { | ||
for (var k = 0; k <= arg.length; k++) { | ||
for (let k = 0; k <= arg.length; k++) { | ||
if (options[arg[k]] != null) { | ||
@@ -61,0 +61,0 @@ found = true |
// Includes | ||
var settings = require('../settings.json') | ||
var jar = require('./util/jar.js').func | ||
var newCache = require('./cache/new.js') | ||
const settings = require('../settings.json') | ||
const jar = require('./util/jar.js').func | ||
const newCache = require('./cache/new.js') | ||
@@ -10,7 +10,7 @@ // Define | ||
var cacheList = [] | ||
var cache = settings.cache | ||
for (var name in cache) { | ||
var item = cache[name] | ||
var cacheObj = { | ||
const cacheList = [] | ||
const cache = settings.cache | ||
for (const name of Object.keys(cache)) { | ||
const item = cache[name] | ||
const cacheObj = { | ||
name: name, | ||
@@ -24,7 +24,5 @@ refresh: item.refresh, | ||
var queue = settings.queue | ||
exports.queue = queue | ||
exports.queue = settings.queue | ||
} | ||
exports.init() |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
@@ -12,3 +12,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: '//presence.roblox.com/v1/presence/users', | ||
@@ -15,0 +15,0 @@ options: { |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
@@ -12,3 +12,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//friends.roblox.com/v1/users/${userId}/accept-friend-request`, | ||
@@ -31,3 +31,3 @@ options: { | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -43,3 +43,3 @@ }) | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
const jar = args.jar | ||
return getGeneralToken({ jar: jar }) | ||
@@ -46,0 +46,0 @@ .then(function (xcsrf) { |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
@@ -11,3 +11,3 @@ // Args | ||
function block (jar, token, userId) { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: '//www.roblox.com/userblock/blockuser', | ||
@@ -29,3 +29,3 @@ options: { | ||
if (res.statusCode === 200) { | ||
var body = res.body | ||
const body = res.body | ||
if (!body.success) { | ||
@@ -41,3 +41,3 @@ throw new Error(body.message) | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
const jar = args.jar | ||
return getGeneralToken({ jar: jar }) | ||
@@ -44,0 +44,0 @@ .then(function (xcsrf) { |
// Allows user to login with a cookie.json, bypassing the username/password captcha issues. | ||
// Includes | ||
var relog = require('../util/relog.js') | ||
const relog = require('../util/relog.js') | ||
// Args | ||
exports.required = ['cookie'] | ||
exports.optional = [] | ||
var interval | ||
var day = 86400000 | ||
let interval | ||
const day = 86400000 | ||
exports.func = function (args) { | ||
@@ -10,0 +10,0 @@ // Run relog |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
@@ -12,3 +12,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: '//friends.roblox.com/v1/user/friend-requests/decline-all', | ||
@@ -31,3 +31,3 @@ options: { | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -43,3 +43,3 @@ }) | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
const jar = args.jar | ||
return getGeneralToken({ jar: jar }) | ||
@@ -46,0 +46,0 @@ .then(function (xcsrf) { |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
@@ -12,3 +12,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//friends.roblox.com/v1/users/${userId}/decline-friend-request`, | ||
@@ -31,3 +31,3 @@ options: { | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -43,3 +43,3 @@ }) | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
const jar = args.jar | ||
return getGeneralToken({ jar: jar }) | ||
@@ -46,0 +46,0 @@ .then(function (xcsrf) { |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
@@ -12,3 +12,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//friends.roblox.com/v1/users/${userId}/follow`, | ||
@@ -31,3 +31,3 @@ options: { | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -43,3 +43,3 @@ }) | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
const jar = args.jar | ||
return getGeneralToken({ jar: jar }) | ||
@@ -46,0 +46,0 @@ .then(function (xcsrf) { |
// Includes | ||
var http = require('../util/http.js').func | ||
var parser = require('cheerio') | ||
const http = require('../util/http.js').func | ||
const parser = require('cheerio') | ||
@@ -5,0 +5,0 @@ // Args |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
@@ -10,5 +9,5 @@ // Args | ||
// Define | ||
function getFollowers (jar, token, userId, sortOrder, limit, cursor) { | ||
function getFollowers (jar, userId, sortOrder, limit, cursor) { | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//friends.roblox.com/v1/users/${userId}/followers?limit=${limit}&sortOrder=${sortOrder}&cursor=${cursor}`, | ||
@@ -18,5 +17,2 @@ options: { | ||
jar: jar, | ||
headers: { | ||
'X-CSRF-TOKEN': token | ||
}, | ||
resolveWithFullResponse: true | ||
@@ -32,3 +28,3 @@ } | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -48,6 +44,3 @@ }) | ||
const cursor = args.cursor || '' | ||
return getGeneralToken({ jar: jar }) | ||
.then(function (xcsrf) { | ||
return getFollowers(jar, xcsrf, args.userId, sortOrder, limit, cursor) | ||
}) | ||
return getFollowers(jar, args.userId, sortOrder, limit, cursor) | ||
} |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
@@ -10,5 +9,5 @@ // Args | ||
// Define | ||
function getFollowings (jar, token, userId, sortOrder, limit, cursor) { | ||
function getFollowings (jar, userId, sortOrder, limit, cursor) { | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//friends.roblox.com/v1/users/${userId}/followings?limit=${limit}&sortOrder=${sortOrder}&cursor=${cursor}`, | ||
@@ -18,5 +17,2 @@ options: { | ||
jar: jar, | ||
headers: { | ||
'X-CSRF-TOKEN': token | ||
}, | ||
resolveWithFullResponse: true | ||
@@ -32,3 +28,3 @@ } | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -48,6 +44,3 @@ }) | ||
const cursor = args.cursor || '' | ||
return getGeneralToken({ jar: jar }) | ||
.then(function (xcsrf) { | ||
return getFollowings(jar, xcsrf, args.userId, sortOrder, limit, cursor) | ||
}) | ||
return getFollowings(jar, args.userId, sortOrder, limit, cursor) | ||
} |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
@@ -10,5 +9,6 @@ // Args | ||
// Define | ||
function getFriendsRequests (jar, token, sortOrder, limit, cursor) { | ||
function getFriendsRequests (args) { | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const jar = args.jar | ||
const httpOpt = { | ||
url: '//friends.roblox.com/v1/my/friends/requests', | ||
@@ -18,5 +18,2 @@ options: { | ||
jar: jar, | ||
headers: { | ||
'X-CSRF-TOKEN': token | ||
}, | ||
resolveWithFullResponse: true | ||
@@ -32,3 +29,3 @@ } | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -43,11 +40,2 @@ }) | ||
exports.func = function (args) { | ||
const jar = args.jar | ||
const sortOrder = args.sortOrder || 'Asc' | ||
const limit = args.limit || (10).toString() | ||
const cursor = args.cursor || '' | ||
return getGeneralToken({ jar: jar }) | ||
.then(function (xcsrf) { | ||
return getFriendsRequests(jar, xcsrf, sortOrder, limit, cursor) | ||
}) | ||
} | ||
exports.func = getFriendsRequests |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
// Args | ||
@@ -10,5 +8,5 @@ exports.required = ['userId'] | ||
// Define | ||
function getFriends (jar, token, userId) { | ||
function getFriends (jar, userId) { | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//friends.roblox.com/v1/users/${userId}/friends`, | ||
@@ -18,5 +16,2 @@ options: { | ||
jar: jar, | ||
headers: { | ||
'X-CSRF-TOKEN': token | ||
}, | ||
resolveWithFullResponse: true | ||
@@ -32,3 +27,3 @@ } | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -44,7 +39,3 @@ }) | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
return getGeneralToken({ jar: jar }) | ||
.then(function (xcsrf) { | ||
return getFriends(jar, xcsrf, args.userId) | ||
}) | ||
return getFriends(args.jar, args.userId) | ||
} |
// Includes | ||
var http = require('../util/http.js').func | ||
const http = require('../util/http.js').func | ||
@@ -11,3 +11,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//api.roblox.com/users/${userId}/groups`, | ||
@@ -27,3 +27,3 @@ options: { | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -39,4 +39,4 @@ }) | ||
exports.func = function (args, senderUserId) { | ||
var jar = args.jar | ||
const jar = args.jar | ||
return getGroups(jar, args.userId) | ||
} |
// Includes | ||
var http = require('../util/http.js').func | ||
var cache = require('../cache') | ||
const http = require('../util/http.js').func | ||
const cache = require('../cache') | ||
@@ -10,3 +10,3 @@ // Args | ||
function getIdFromUsername (username) { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: '//api.roblox.com/users/get-by-username?username=' + username | ||
@@ -16,6 +16,6 @@ } | ||
.then(function (body) { | ||
var json = JSON.parse(body) | ||
var id = json.Id | ||
var errorMessage = json.errorMessage | ||
var message = json.message | ||
const json = JSON.parse(body) | ||
const id = json.Id | ||
const errorMessage = json.errorMessage | ||
const message = json.message | ||
if (id) { | ||
@@ -30,3 +30,3 @@ return id | ||
exports.func = function (args) { | ||
var username = args.username | ||
const username = args.username | ||
// Case does not affect the result and should not affect the cache | ||
@@ -33,0 +33,0 @@ return cache.wrap('IDFromName', username.toLowerCase(), function () { |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
@@ -12,3 +11,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//privatemessages.roblox.com/v1/messages?pageNumber=${pageNumber}&pageSize=${pageSize}&messageTab=${messageTab}`, | ||
@@ -18,5 +17,2 @@ options: { | ||
jar: jar, | ||
headers: { | ||
'X-CSRF-TOKEN': token | ||
}, | ||
resolveWithFullResponse: true | ||
@@ -32,3 +28,3 @@ } | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -53,6 +49,3 @@ }) | ||
} | ||
return getGeneralToken({ jar: jar }) | ||
.then(function (xcsrf) { | ||
return getMessages(jar, xcsrf, pageNumber, pageSize, messageTab) | ||
}) | ||
return getMessages(jar, pageNumber, pageSize, messageTab) | ||
} |
// Includes | ||
var http = require('../util/http.js').func | ||
const http = require('../util/http.js').func | ||
@@ -11,3 +11,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//api.roblox.com/ownership/hasasset?userId=${userId}&assetId=${assetId}`, | ||
@@ -26,3 +26,3 @@ options: { | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -29,0 +29,0 @@ }) |
// Includes | ||
var http = require('../util/http.js').func | ||
var rbxDate = require('../util/getDate.js').func | ||
var parser = require('cheerio') | ||
const http = require('../util/http.js').func | ||
const rbxDate = require('../util/getDate.js').func | ||
const parser = require('cheerio') | ||
@@ -6,0 +6,0 @@ // Args |
// Includes | ||
var http = require('../util/http.js').func | ||
const http = require('../util/http.js').func | ||
@@ -4,0 +4,0 @@ // Args |
// Includes | ||
var http = require('../util/http.js').func | ||
var cache = require('../cache') | ||
const http = require('../util/http.js').func | ||
const cache = require('../cache') | ||
@@ -10,3 +10,3 @@ // Args | ||
function getUsernameFromId (id) { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: '//api.roblox.com/users/' + id, | ||
@@ -21,3 +21,3 @@ options: { | ||
if (res.statusCode === 200) { | ||
var json = JSON.parse(res.body) | ||
const json = JSON.parse(res.body) | ||
return json.Username | ||
@@ -31,3 +31,3 @@ } else { | ||
exports.func = function (args) { | ||
var id = args.id | ||
const id = args.id | ||
return cache.wrap('NameFromID', id, function () { | ||
@@ -34,0 +34,0 @@ return getUsernameFromId(id) |
const http = require('../util/http.js').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
const getCurrentUser = require('../util/getCurrentUser.js').func | ||
@@ -8,5 +7,5 @@ | ||
function getTransactions (userId, transactionType, limit, cursor, jar, xcsrf) { | ||
function getTransactions (userId, transactionType, limit, cursor, jar) { | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `https://economy.roblox.com/v1/users/${userId}/transactions?limit=${limit}&transactionType=${transactionType}&cursor=${cursor}`, | ||
@@ -16,6 +15,3 @@ options: { | ||
resolveWithFullResponse: true, | ||
jar: jar, | ||
headers: { | ||
'X-CSRF-TOKEN': xcsrf | ||
} | ||
jar: jar | ||
} | ||
@@ -41,3 +37,3 @@ } | ||
// Define | ||
exports.func = function (args) { | ||
exports.func = async function (args) { | ||
const jar = args.jar | ||
@@ -47,7 +43,4 @@ const transactionType = args.transactionType || 'Sale' | ||
const cursor = args.cursor || '' | ||
return getGeneralToken({ jar: jar }) | ||
.then(async function (xcsrf) { | ||
const currentUser = await getCurrentUser({ jar: jar }) | ||
return getTransactions(currentUser.UserID, transactionType, limit, cursor, xcsrf) | ||
}) | ||
const currentUser = await getCurrentUser({ jar: jar }) | ||
return getTransactions(currentUser.UserID, transactionType, limit, cursor) | ||
} |
// Includes | ||
var http = require('../util/http.js').func | ||
var queue = require('../internal/queue.js') | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
var getHash = require('../util/getHash.js').func | ||
var getSenderId = require('../util/getSenderUserId.js').func | ||
const http = require('../util/http.js').func | ||
const queue = require('../internal/queue.js') | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
const getHash = require('../util/getHash.js').func | ||
const getSenderId = require('../util/getSenderUserId.js').func | ||
@@ -15,3 +15,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: '//privatemessages.roblox.com/v1/messages/send', | ||
@@ -43,3 +43,3 @@ options: { | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -55,3 +55,3 @@ }) | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
const jar = args.jar | ||
return queue('Message', getHash({ jar: jar }), function () { | ||
@@ -58,0 +58,0 @@ return getGeneralToken({ jar: jar }) |
// Includes | ||
var shortPoll = require('../util/shortPoll.js').func | ||
var getBlurb = require('./getBlurb.js').func | ||
const shortPoll = require('../util/shortPoll.js').func | ||
const getBlurb = require('./getBlurb.js').func | ||
@@ -14,3 +14,3 @@ // Args | ||
.then(function (blurb) { | ||
var given = [] | ||
const given = [] | ||
if (blurb !== latest) { | ||
@@ -17,0 +17,0 @@ latest = blurb |
// Dependencies | ||
var events = require('events') | ||
const events = require('events') | ||
// Includes | ||
var onNotification = require('./onNotification.js').func | ||
const onNotification = require('./onNotification.js').func | ||
@@ -12,5 +12,5 @@ // Args | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
var onFriendRequest = new events.EventEmitter() | ||
var notifications = onNotification({ jar: jar }) | ||
const jar = args.jar | ||
const onFriendRequest = new events.EventEmitter() | ||
const notifications = onNotification({ jar: jar }) | ||
notifications.on('data', function (name, message) { | ||
@@ -17,0 +17,0 @@ if (name === 'FriendshipNotifications' && message.Type === 'FriendshipRequested') { |
// Dependencies | ||
var events = require('events') | ||
const events = require('events') | ||
// Includes | ||
var onNotification = require('./onNotification.js').func | ||
var getMessages = require('./getMessages.js').func | ||
const onNotification = require('./onNotification.js').func | ||
const getMessages = require('./getMessages.js').func | ||
@@ -13,10 +13,10 @@ // Args | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
var onMessage = new events.EventEmitter() | ||
var waitingForRequest = false | ||
var latest | ||
const jar = args.jar | ||
const onMessage = new events.EventEmitter() | ||
let waitingForRequest = false | ||
let latest | ||
getMessages({ jar: jar, messageTab: 'Inbox', pageNumber: 0 }) | ||
.then(function (initial) { | ||
latest = initial.collection[0] ? initial.collection[0].id : 0 | ||
var notifications = onNotification({ jar: jar }) | ||
const notifications = onNotification({ jar: jar }) | ||
notifications.on('data', function (name, message) { | ||
@@ -33,6 +33,6 @@ if (name === 'NotificationStream' && message.Type === 'NewNotification') { | ||
.then(function (inbox) { | ||
var messages = inbox.collection | ||
for (var i = messages.length - 1; i >= 0; i--) { | ||
var message = messages[i] | ||
var id = message.id | ||
const messages = inbox.collection | ||
for (let i = messages.length - 1; i >= 0; i--) { | ||
const message = messages[i] | ||
const id = message.id | ||
if (id > latest) { | ||
@@ -39,0 +39,0 @@ latest = id |
// Dependencies | ||
var SignalR = require('signalr-client').client | ||
var events = require('events') | ||
const SignalR = require('signalr-client').client | ||
const events = require('events') | ||
// Includes | ||
var getSession = require('../util/getSession.js').func | ||
var settings = require('../../settings.json') | ||
const getSession = require('../util/getSession.js').func | ||
const settings = require('../../settings.json') | ||
@@ -14,7 +14,7 @@ // Args | ||
exports.func = function (args) { | ||
var max = settings.event.maxRetries | ||
var notifications = new events.EventEmitter() | ||
const max = settings.event.maxRetries | ||
const notifications = new events.EventEmitter() | ||
function connect (retries) { | ||
var session = getSession({ jar: args.jar }) | ||
var client = new SignalR('wss://realtime.roblox.com/notifications', ['usernotificationhub'], 3, true) // wss for https | ||
const session = getSession({ jar: args.jar }) | ||
const client = new SignalR('wss://realtime.roblox.com/notifications', ['usernotificationhub'], 3, true) // wss for https | ||
client.headers.Cookie = '.ROBLOSECURITY=' + session + ';' | ||
@@ -21,0 +21,0 @@ client.on('usernotificationhub', 'notification', function (name, message) { |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
@@ -12,3 +12,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//friends.roblox.com/v1/users/${userId}/unfriend`, | ||
@@ -31,3 +31,3 @@ options: { | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -43,3 +43,3 @@ }) | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
const jar = args.jar | ||
return getGeneralToken({ jar: jar }) | ||
@@ -46,0 +46,0 @@ .then(function (xcsrf) { |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
@@ -12,3 +12,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//friends.roblox.com/v1/users/${userId}/request-friendship`, | ||
@@ -31,3 +31,3 @@ options: { | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -43,3 +43,3 @@ }) | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
const jar = args.jar | ||
return getGeneralToken({ jar: jar }) | ||
@@ -46,0 +46,0 @@ .then(function (xcsrf) { |
@@ -1,3 +0,3 @@ | ||
var options = require('../options.js') | ||
var getCurrentUser = require('../util/getCurrentUser.js').func | ||
const options = require('../options.js') | ||
const getCurrentUser = require('../util/getCurrentUser.js').func | ||
@@ -4,0 +4,0 @@ exports.required = ['cookie'] |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
@@ -11,3 +11,3 @@ // Args | ||
function unblock (jar, token, userId) { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: '//www.roblox.com/userblock/unblockuser', | ||
@@ -29,3 +29,3 @@ options: { | ||
if (res.statusCode === 200) { | ||
var body = res.body | ||
const body = res.body | ||
if (!body.success) { | ||
@@ -41,3 +41,3 @@ throw new Error(body.message) | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
const jar = args.jar | ||
return getGeneralToken({ jar: jar }) | ||
@@ -44,0 +44,0 @@ .then(function (xcsrf) { |
// Includes | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
const http = require('../util/http.js').func | ||
const getGeneralToken = require('../util/getGeneralToken.js').func | ||
@@ -12,3 +12,3 @@ // Args | ||
return new Promise((resolve, reject) => { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: `//friends.roblox.com/v1/users/${userId}/unfollow`, | ||
@@ -31,3 +31,3 @@ options: { | ||
if (body.errors && body.errors.length > 0) { | ||
var errors = body.errors.map((e) => { | ||
const errors = body.errors.map((e) => { | ||
return e.message | ||
@@ -43,3 +43,3 @@ }) | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
const jar = args.jar | ||
return getGeneralToken({ jar: jar }) | ||
@@ -46,0 +46,0 @@ .then(function (xcsrf) { |
// Includes | ||
var settings = require('../../settings.json') | ||
const settings = require('../../settings.json') | ||
@@ -9,9 +9,9 @@ // Args | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
const jar = args.jar | ||
if (settings.session_only) { | ||
jar.session = '' | ||
} else { | ||
var cookies = jar._jar.store.idx['roblox.com'] | ||
const cookies = jar._jar.store.idx['roblox.com'] | ||
if (cookies) { | ||
var cookie = cookies['/'] | ||
const cookie = cookies['/'] | ||
if (cookie && cookie['.ROBLOSECURITY']) { | ||
@@ -18,0 +18,0 @@ delete cookies['/']['.ROBLOSECURITY'] |
// Includes | ||
var http = require('./http.js').func | ||
var getVerification = require('./getVerification.js').func | ||
const http = require('./http.js').func | ||
const getVerification = require('./getVerification.js').func | ||
@@ -11,6 +11,6 @@ // Args | ||
function general (jar, url, inputs, events, customOpt, body) { | ||
for (var input in events) { | ||
for (const input in events) { | ||
inputs[input] = events[input] | ||
} | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: url, | ||
@@ -39,5 +39,5 @@ options: { | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
var url = args.url | ||
var custom = args.http | ||
const jar = args.jar | ||
const url = args.url | ||
const custom = args.http | ||
return getVerification({ url: custom ? (custom.url || url) : url, jar: jar, ignoreCache: args.ignoreCache, getBody: args.getBody }) | ||
@@ -44,0 +44,0 @@ .then(function (response) { |
@@ -5,3 +5,3 @@ // Args | ||
// Define | ||
var regex = [ | ||
const regex = [ | ||
/rank from (.+) to (.+)\.$/, | ||
@@ -11,11 +11,13 @@ /deleted post "(.+)" by user .+\.$/, | ||
] | ||
// This is no longer used within the library and is maintained only for the purposes of backwards compatibility | ||
// TODO: Remove this in next Semver major version | ||
exports.func = function (args) { | ||
var row = args.row | ||
var text = row.text() | ||
var params = [] | ||
for (var i = 0; i < regex.length; i++) { | ||
var match = text.match(regex[i]) | ||
const row = args.row | ||
const text = row.text() | ||
const params = [] | ||
for (let i = 0; i < regex.length; i++) { | ||
const match = text.match(regex[i]) | ||
if (match) { | ||
for (var j = 1; j < match.length; j++) { | ||
for (let j = 1; j < match.length; j++) { | ||
params.push(match[j]) | ||
@@ -25,4 +27,4 @@ } | ||
} | ||
var target = row.find('a').last().attr('href') | ||
var found = target.match(/\?ID=(\d+)$/) | ||
const target = row.find('a').last().attr('href') | ||
let found = target.match(/\?ID=(\d+)$/) | ||
if (!found) { | ||
@@ -29,0 +31,0 @@ found = target.match(/^games\/(\d+)\//) |
// Includes | ||
var http = require('./http.js').func | ||
const http = require('./http.js').func | ||
@@ -9,5 +9,5 @@ // Args | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
var option = args.option | ||
var httpOpt = { | ||
const jar = args.jar | ||
const option = args.option | ||
const httpOpt = { | ||
url: '//www.roblox.com/mobileapi/userinfo', | ||
@@ -26,7 +26,6 @@ options: { | ||
} else { | ||
var json = JSON.parse(res.body) | ||
var result = (option ? json[option] : json) | ||
return result | ||
const json = JSON.parse(res.body) | ||
return (option ? json[option] : json) | ||
} | ||
}) | ||
} |
@@ -6,7 +6,7 @@ // Args | ||
exports.isDST = function (time) { | ||
var today = new Date(time) | ||
var month = today.getMonth() | ||
var dow = today.getDay() | ||
var day = today.getDate() | ||
var hours = today.getHours() | ||
const today = new Date(time) | ||
const month = today.getMonth() | ||
const dow = today.getDay() | ||
const day = today.getDate() | ||
const hours = today.getHours() | ||
if (month < 2 || month > 10) { | ||
@@ -29,3 +29,3 @@ return false | ||
} | ||
var previousSunday = day - dow | ||
const previousSunday = day - dow | ||
if (month === 2) { | ||
@@ -38,5 +38,5 @@ return previousSunday >= 8 | ||
exports.func = function (args) { | ||
var time = args.time | ||
var timezone = args.timezone | ||
const time = args.time | ||
const timezone = args.timezone | ||
return new Date(time + ' ' + timezone.substring(0, 1) + (exports.isDST(time) ? 'D' : 'S') + timezone.substring(1)) | ||
} |
// Includes | ||
var getHash = require('./getHash.js').func | ||
var http = require('./http.js').func | ||
var cache = require('../cache') | ||
const getHash = require('./getHash.js').func | ||
const http = require('./http.js').func | ||
const cache = require('../cache') | ||
const options = require('../options.js') | ||
@@ -11,3 +12,6 @@ // Args | ||
function getGeneralToken (jar) { | ||
var httpOpt = { | ||
if (!jar && !options.jar.session) { | ||
throw new Error('Cannot get CSRF: You are not logged in.') | ||
} | ||
const httpOpt = { | ||
// This will never actually sign you out because an X-CSRF-TOKEN isn't provided, only received | ||
@@ -23,3 +27,3 @@ url: '//auth.roblox.com/v2/logout', // REQUIRES https. Thanks for letting me know, ROBLOX... | ||
.then(function (res) { | ||
var xcsrf = res.headers['x-csrf-token'] | ||
const xcsrf = res.headers['x-csrf-token'] | ||
if (xcsrf) { | ||
@@ -34,3 +38,3 @@ return xcsrf | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
const jar = args.jar | ||
return cache.wrap('XCSRF', getHash({ jar: jar }), function () { | ||
@@ -37,0 +41,0 @@ return getGeneralToken(jar) |
// Dependencies | ||
var crypto = require('crypto') | ||
const crypto = require('crypto') | ||
// Includes | ||
var getSession = require('./getSession.js').func | ||
const getSession = require('./getSession.js').func | ||
@@ -12,4 +12,4 @@ // Args | ||
exports.func = function (args) { | ||
var session = getSession({ jar: args.jar }) | ||
const session = getSession({ jar: args.jar }) | ||
return crypto.createHash('md5').update(session).digest('hex') | ||
} |
// Dependencies | ||
var parser = require('cheerio') | ||
const parser = require('cheerio') | ||
@@ -10,8 +10,8 @@ // Args | ||
exports.func = function (args) { | ||
var $ = parser.load(args.html) | ||
var inputs = {} | ||
var find = args.find | ||
const $ = parser.load(args.html) | ||
const inputs = {} | ||
const find = args.find | ||
if (find) { | ||
for (var i = 0; i < find.length; i++) { | ||
var get = find[i] | ||
for (let i = 0; i < find.length; i++) { | ||
const get = find[i] | ||
inputs[get] = $('input[name=' + get + ']').val() | ||
@@ -21,3 +21,3 @@ } | ||
$('input[name]').each(function (index, element) { | ||
var here = $(this) | ||
const here = $(this) | ||
inputs[here.attr('name')] = here.val() | ||
@@ -24,0 +24,0 @@ }) |
// Includes | ||
var getCurrentUser = require('./getCurrentUser.js').func | ||
var getHash = require('./getHash.js').func | ||
var cache = require('../cache') | ||
const getCurrentUser = require('./getCurrentUser.js').func | ||
const getHash = require('./getHash.js').func | ||
const cache = require('../cache') | ||
@@ -11,3 +11,3 @@ // Args | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
const jar = args.jar | ||
return cache.wrap('SenderID', getHash({ jar: jar }), function () { | ||
@@ -14,0 +14,0 @@ return getCurrentUser({ jar: jar }) |
// Includes | ||
var settings = require('../../settings.json') | ||
var options = require('../options.js') | ||
const settings = require('../../settings.json') | ||
const options = require('../options.js') | ||
@@ -10,9 +10,9 @@ // Args | ||
exports.func = function (args) { | ||
var jar = args.jar || options.jar | ||
const jar = args.jar || options.jar | ||
if (settings.session_only) { | ||
return jar.session | ||
} else { | ||
var cookies = jar.getCookies('https://roblox.com') | ||
for (var i = 0; i < cookies.length; i++) { | ||
var element = cookies[i] | ||
const cookies = jar.getCookies('https://roblox.com') | ||
for (let i = 0; i < cookies.length; i++) { | ||
const element = cookies[i] | ||
if (element.key === '.ROBLOSECURITY') { | ||
@@ -19,0 +19,0 @@ return element.value |
// Includes | ||
var http = require('./http.js').func | ||
var getHash = require('./getHash.js').func | ||
var getVerificationInputs = require('./getVerificationInputs.js').func | ||
var cache = require('../cache') | ||
var URL = require('url').URL | ||
const http = require('./http.js').func | ||
const getHash = require('./getHash.js').func | ||
const getVerificationInputs = require('./getVerificationInputs.js').func | ||
const cache = require('../cache') | ||
const URL = require('url').URL | ||
@@ -14,3 +14,3 @@ // Args | ||
function getVerification (jar, url, getBody) { | ||
var httpOpt = { | ||
const httpOpt = { | ||
url: url, | ||
@@ -24,4 +24,4 @@ options: { | ||
.then(function (res) { | ||
var inputs = getVerificationInputs({ html: res.body }) | ||
var match | ||
const inputs = getVerificationInputs({ html: res.body }) | ||
let match | ||
if (res.headers && res.headers['set-cookie']) { | ||
@@ -39,3 +39,3 @@ match = res.headers['set-cookie'].toString().match(/__RequestVerificationToken=(.*?);/) | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
const jar = args.jar | ||
if (args.ignoreCache) { | ||
@@ -42,0 +42,0 @@ return getVerification(jar, args.url, args.getBody) |
// Dependencies | ||
var parser = require('cheerio') | ||
const parser = require('cheerio') | ||
@@ -9,10 +9,10 @@ // Args | ||
exports.func = function (args) { | ||
var $ = args.selector | ||
let $ = args.selector | ||
if (!$) { | ||
$ = parser.load(args.html) | ||
} | ||
var inputs = {} | ||
var find = ['__VIEWSTATE', '__VIEWSTATEGENERATOR', '__EVENTVALIDATION', '__RequestVerificationToken'] | ||
for (var i = 0; i < find.length; i++) { | ||
var get = find[i] | ||
const inputs = {} | ||
const find = ['__VIEWSTATE', '__VIEWSTATEGENERATOR', '__EVENTVALIDATION', '__RequestVerificationToken'] | ||
for (let i = 0; i < find.length; i++) { | ||
const get = find[i] | ||
inputs[get] = $('input[name=' + get + ']').val() | ||
@@ -19,0 +19,0 @@ } |
// Dependencies | ||
var request = require('request-promise') | ||
let request = require('request-promise') | ||
// Includes | ||
var options = require('../options.js') | ||
var settings = require('../../settings.json') | ||
var cache = require('../cache') | ||
var getHash = require('./getHash.js').func | ||
const options = require('../options.js') | ||
const settings = require('../../settings.json') | ||
const cache = require('../cache') | ||
const getHash = require('./getHash.js').func | ||
@@ -40,3 +40,3 @@ // Args | ||
} | ||
var verify = '__RequestVerificationToken=' + opt.verification + ';' | ||
const verify = '__RequestVerificationToken=' + opt.verification + ';' | ||
if (opt.headers.cookie) { | ||
@@ -55,8 +55,8 @@ opt.headers.cookie += verify | ||
exports.func = function (args) { | ||
var opt = args.options || {} | ||
var jar = opt.jar | ||
var depth = args.depth || 0 | ||
var full = opt.resolveWithFullResponse || false | ||
const opt = args.options || {} | ||
const jar = opt.jar | ||
let depth = args.depth || 0 | ||
const full = opt.resolveWithFullResponse || false | ||
opt.resolveWithFullResponse = true | ||
var follow = opt.followRedirect === undefined || opt.followRedirect | ||
const follow = opt.followRedirect === undefined || opt.followRedirect | ||
opt.followRedirect = function (res) { | ||
@@ -75,3 +75,3 @@ if (!args.ignoreLoginError && res.headers.location && (res.headers.location.startsWith('https://www.roblox.com/newlogin') || res.headers.location.startsWith('/Login/Default.aspx'))) { | ||
} | ||
var token = res.headers['x-csrf-token'] | ||
const token = res.headers['x-csrf-token'] | ||
if (token) { | ||
@@ -78,0 +78,0 @@ opt.headers['X-CSRF-TOKEN'] = token |
// Dependencies | ||
var request = require('request-promise') | ||
const request = require('request-promise') | ||
// Includes | ||
var settings = require('../../settings.json') | ||
const settings = require('../../settings.json') | ||
@@ -7,0 +7,0 @@ // Define |
// Includes | ||
var options = require('../options.js') | ||
var getGeneralToken = require('./getGeneralToken.js').func | ||
var getVerification = require('./getVerification.js').func | ||
var http = require('./http.js').func | ||
const options = require('../options.js') | ||
const getGeneralToken = require('./getGeneralToken.js').func | ||
const getVerification = require('./getVerification.js').func | ||
const http = require('./http.js').func | ||
// Args | ||
@@ -35,3 +35,3 @@ exports.required = [] | ||
}).then((res) => { | ||
var cookies = res.headers['set-cookie'] | ||
const cookies = res.headers['set-cookie'] | ||
if (cookies) { | ||
@@ -38,0 +38,0 @@ const cookie = cookies.toString().match(/\.ROBLOSECURITY=(.*?);/)[1] |
// Includes | ||
var options = require('../options.js') | ||
var getGeneralToken = require('./getGeneralToken.js').func | ||
var getVerification = require('./getVerification.js').func | ||
var getCurrentUser = require('./getCurrentUser.js').func | ||
var http = require('./http.js').func | ||
var cookieFile = './cookie' | ||
var fs = require('fs') | ||
const options = require('../options.js') | ||
const getGeneralToken = require('./getGeneralToken.js').func | ||
const getVerification = require('./getVerification.js').func | ||
const getCurrentUser = require('./getCurrentUser.js').func | ||
const http = require('./http.js').func | ||
const cookieFile = './cookie' | ||
const fs = require('fs') | ||
// Args | ||
@@ -13,3 +13,3 @@ exports.required = ['cookie'] | ||
var day = 86400000 | ||
const day = 86400000 | ||
@@ -39,3 +39,3 @@ // Define | ||
}).then((res) => { | ||
var cookies = res.headers['set-cookie'] | ||
const cookies = res.headers['set-cookie'] | ||
if (cookies) { | ||
@@ -60,3 +60,3 @@ options.jar.session = cookies.toString().match(/\.ROBLOSECURITY=(.*?);/)[1] | ||
if (fs.existsSync(cookieFile)) { | ||
var json = JSON.parse(fs.readFileSync(cookieFile)) | ||
const json = JSON.parse(fs.readFileSync(cookieFile)) | ||
@@ -63,0 +63,0 @@ // Check its new enough |
// Dependencies | ||
var events = require('events') | ||
const events = require('events') | ||
// Includes | ||
var settings = require('../../settings.json') | ||
const settings = require('../../settings.json') | ||
@@ -13,18 +13,16 @@ // Args | ||
exports.func = function (args) { | ||
var latest = args.getLatest | ||
var delay = args.delay | ||
const latest = args.getLatest | ||
let delay = args.delay | ||
delay = typeof delay === 'string' || delay instanceof String ? settings.event[delay] : delay | ||
var retries = 0 | ||
var max = settings.event.maxRetries | ||
var timeout = args.timeout || settings.event.timeout | ||
var stop = false | ||
var current | ||
var evt = new events.EventEmitter() | ||
var run | ||
run = function (value) { | ||
let retries = 0 | ||
const max = settings.event.maxRetries | ||
const timeout = args.timeout || settings.event.timeout | ||
let stop = false | ||
let current | ||
const evt = new events.EventEmitter() | ||
const run = function (value) { | ||
if (stop) { | ||
return | ||
} | ||
var promise = latest(value, evt) | ||
let promise = latest(value, evt) | ||
if (timeout > 0) { | ||
@@ -41,6 +39,6 @@ promise = promise.timeout(timeout) | ||
retries = 0 | ||
var data = response.data | ||
const data = response.data | ||
if (data.length > 0 && (value !== -1 || current === -2)) { | ||
current = response.latest | ||
for (var i = 0; i < data.length; i++) { | ||
for (let i = 0; i < data.length; i++) { | ||
evt.emit('data', data[i]) | ||
@@ -47,0 +45,0 @@ } |
// Dependencies | ||
var Promise = require('bluebird') | ||
const Promise = require('bluebird') | ||
// Includes | ||
var settings = require('../../settings.json') | ||
const settings = require('../../settings.json') | ||
@@ -12,8 +12,8 @@ // Args | ||
exports.func = function (args) { | ||
var getPage = args.getPage | ||
var start = args.start | ||
var end = args.end | ||
var completed = 0 | ||
var expected = end - start | ||
var rslv | ||
const getPage = args.getPage | ||
const start = args.start | ||
const end = args.end | ||
let completed = 0 | ||
let expected = end - start | ||
let rslv | ||
function next (i, ivl, tries) { | ||
@@ -37,3 +37,3 @@ if (i >= end) { | ||
} | ||
var res = getPage(i) | ||
const res = getPage(i) | ||
if (res && res.then) { | ||
@@ -64,3 +64,3 @@ res.then(function () { | ||
var promise = new Promise(function (resolve) { | ||
const promise = new Promise(function (resolve) { | ||
rslv = resolve | ||
@@ -71,4 +71,4 @@ if (expected <= 0) { | ||
} | ||
var ivl = Math.min(settings.maxThreads, expected) | ||
for (var i = 0; i < ivl; i++) { | ||
const ivl = Math.min(settings.maxThreads, expected) | ||
for (let i = 0; i < ivl; i++) { | ||
next(i, ivl, 0) | ||
@@ -75,0 +75,0 @@ } |
{ | ||
"name": "noblox.js", | ||
"version": "4.6.3", | ||
"version": "4.6.4", | ||
"description": "A Node.js wrapper for ROBLOX. (original from sentanos)", | ||
@@ -36,3 +36,4 @@ "main": "lib/index.js", | ||
"contributors": [ | ||
"Joshua Lanese <froastj@gmail.com>" | ||
"Joshua Lanese <froastj@gmail.com>", | ||
"Neztore <hi@nezto.re>" | ||
], | ||
@@ -39,0 +40,0 @@ "homepage": "https://github.com/suufi/noblox.js", |
@@ -12,3 +12,3 @@ <h1 align="center"> | ||
<a href="https://npmjs.org/noblox.js"><img src="https://img.shields.io/npm/v/noblox.js.svg?style=flat-square" alt="NPM package"/> | ||
<a href="https://travis-ci.org/suufi/noblox.js"><img src="https://img.shields.io/travis/suufi/noblox.js/master.svg?style=flat-square" alt="Travis Build Status"/></a> | ||
<a href="https://travis-ci.org/suufi/noblox.js"><img src="https://img.shields.io/travis/suufi/noblox.js/master.svg?style=flat-square" alt="Travis Build Status"/></a></a> | ||
</p> | ||
@@ -53,12 +53,13 @@ | ||
## Making use of new login workaround | ||
> Note, as of v4.6.0 The way you login to Noblox has changed significantly. | ||
> Note, as of v4.6.0 The way you log in to Noblox has changed significantly. | ||
> The library is no longer responsible for refreshing your cookies | ||
> | ||
> This is because of many reasons including that creating a file caused many security & usability issues and made the library incompatible with some hosts. | ||
> This is because of many reasons including that creating a file caused several security/usability issues and made the library incompatible with some hosts. | ||
### Initial setup | ||
1. Remove any usages of the `login` or `cookieLogin` methods. | ||
2. Run `setCookie` with your cookie. This will store your cookie internally and validate it, but will perform **no** cookie refresh automatically | ||
3. While this works, Roblox `.ROBLOSECURITY` cookies expire after an unknown length of time. For applications which run continuously, **you must** use the function `refreshCookie` to prevent this. This will refresh either the cookie you pass or the internally stored cookie and return the new one. | ||
4. You need to store this new cookie somewhere - whether it be in a database or a JSON file file. | ||
3. While this works, Roblox `.ROBLOSECURITY` cookies expire after an unknown length of time. For applications which run continuously, **you must** use the function `refreshCookie` to prevent this. This will refresh either the cookie you pass or the internally stored cookie and return the new one.* | ||
4. You need to store this new cookie somewhere - whether it be in a database, or a JSON file. | ||
\* See [Cookie expiration](#Cookie expiration) for an in depth discussion of cookie expiration. | ||
> Note: By default, setCookie will validate the cookie you provide by making a HTTP request. | ||
@@ -71,3 +72,3 @@ > To Disable this behaviour, pass `false` as the second parameter (validate) | ||
3. Click `Application` | ||
4. Find `.ROBLOSECURITY`. Copy it's contents, which will start with `_|WARNING:-DO` | ||
4. Find `.ROBLOSECURITY`. Copy its contents, which will start with: `_|WARNING:-DO` | ||
5. Put this full token, *including* the warning into cookieLogin: `rbx.setCookie( tokenHere )` | ||
@@ -88,6 +89,18 @@ | ||
- You need to set up something to store and refresh cookies yourself | ||
- If the application is offline for like a week to a month you may need to get the cookie again | ||
- Roblox-js-server is **not** currently compatible. Use [noblox.js-server](https://github.com/Hamzah-z/noblox.js-server) instead. | ||
## Common issues | ||
### CSRF | ||
In July 2020 Roblox updated the endpoint we used to get CSRF tokens (`auth.roblox.com/v1/logout`) and essentially disabled it. | ||
They didn't warn anyone of this change so as of v4.6.3 we've updated to a new endpoint that works. | ||
To make use of the new fix, run `npm install noblox.js@4.6.3`. Alternatively, use `latest` to get the latest version. | ||
### Cookie expiration | ||
We do not know for a fact whether Roblox cookies expire. Roblox has not enlightened us on this fact, so we're pretty much in the dark. | ||
We advise that you refresh your cookies in a production environment **no more often than** once every 24 hours. | ||
However, several users have noted lately that they've had cookies last for several months - meaning you could choose not to refresh your cookie. | ||
## Credits | ||
@@ -94,0 +107,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Type definitions for noblox.js@4.5.2 | ||
// Type definitions for noblox.js@4.6.0 | ||
// Authored by Gamenew09 w/ changes by suufi | ||
@@ -1096,4 +1096,12 @@ | ||
/** | ||
* Allows user to login with a cookie.json, bypassing the username/password captcha issues. | ||
* Allows the user to login with a provided cookie string, bypassing the username/password captcha issues. | ||
* By default, the provided cookie will be validated by making a HTTP request. To disable this behaviour, pass false as the second optional parameter (shouldValidate). | ||
*/ | ||
function setCookie<B extends boolean = true>(cookie: string, shouldValidate?: B): B extends false ? boolean : Promise<LoggedInUserData> | ||
/** | ||
* Allows the user to login with a cookie.json file, bypassing the username/password captcha issues. | ||
* | ||
* NOTE: Usage of this function is deprecated as of v4.6.0. | ||
*/ | ||
function cookieLogin(cookie: string): Promise<LoggedInUserData>; | ||
@@ -1112,5 +1120,5 @@ | ||
/** | ||
* Logs into `username` with `password` and stores their cookie in `jar`. | ||
* Logs into the user account with a provided `username` and `password`. On success -, stores the account cookie in `jar`. | ||
* | ||
* NOTE: Calling login requires passing the robot test. | ||
* NOTE: Usage of this function is deprecated as of v4.6.0 and calling requires passing the robot test. | ||
*/ | ||
@@ -1321,2 +1329,7 @@ function login(username: string, password: string, jar?: CookieJar): Promise<UserLoginApiData>; | ||
/** | ||
* Refreshes the internally stored cookie, or the cookie provided, stores the new cookie and returns it. | ||
*/ | ||
function refreshCookie(cookie?: string): Promise<string>; | ||
/** | ||
* This is the base for events that do not rely on true streams. The `getLatest` function receives some value that represents the latest version of something (eg. a date or unique ID) and determines if there is new information, every time it is fired it waits `delay` ms before being fired again. Every time it must return an object with the field `latest`, representing the latest value (which will not change if new information was not received), and an array `data` which has the new values (if there are multiple they each have their own index, if there is only one then it is by itself in the array). If `latest` is equal to -2, the returned data will be processed even if it is the initial run (which usually only establishes the latest value). If the return object has a true `repeat` value, the function latest will be run again immediately after. If `delay` is a string it will take the number from that string key in the `event` object of the settings.json file. | ||
@@ -1484,7 +1497,7 @@ * When the function is first called it will initialize `getLatest` with the value -1 and then emit the `connect` event. Whenever data is received, it will emit the `data` event for each value. If the `close` event is emitted the function will no longer run. If an error occurs the `error` event will be emitted, the function will log a retry and after the number of max retries as specified by settings, it will emit the `close` event. | ||
* ```javascript | ||
* var blacklist = [1, 261] | ||
* var evt = rbx.onJoinRequestHandle(18) | ||
* const blacklist = [1, 261] | ||
* const evt = rbx.onJoinRequestHandle(18) | ||
* evt.on('data', function (request) { | ||
* rbx.getIdFromUsername(request.username).then(function (id) { | ||
* for (var i = 0; i < blacklist.length; i++) { | ||
* for (const i = 0; i < blacklist.length; i++) { | ||
* if (blacklist[i] === id) { | ||
@@ -1491,0 +1504,0 @@ * evt.emit('handle', request, false); |
109
259657
162
6609