Comparing version 4.1.3 to 4.1.4
// Includes | ||
var generalRequest = require('../util/generalRequest.js').func | ||
var http = require('../util/http.js').func | ||
var getGeneralToken = require('../util/getGeneralToken.js').func | ||
@@ -8,17 +9,51 @@ // Args | ||
// Define | ||
exports.func = function (args) { | ||
var jar = args.jar | ||
var group = args.group | ||
var message = args.message || '' | ||
var events = { | ||
ctl00$cphRoblox$GroupStatusPane$StatusTextBox: message, | ||
ctl00$cphRoblox$GroupStatusPane$StatusSubmitButton: 'Group Shout' | ||
function shoutOnGroup (group, shoutMessage, jar, xcsrf) { | ||
var httpOpt = { | ||
url: `https://groups.roblox.com/v1/groups/${group}/status`, | ||
options: { | ||
method: 'PATCH', | ||
resolveWithFullResponse: true, | ||
json: { | ||
message: shoutMessage | ||
}, | ||
jar: jar, | ||
headers: { | ||
'X-CSRF-TOKEN': xcsrf | ||
} | ||
} | ||
} | ||
return generalRequest({jar: jar, url: '//www.roblox.com/My/Groups.aspx?gid=' + group, events: events}) | ||
.then(function (result) { | ||
if (result.res.statusCode !== 200) { | ||
throw new Error('Shout failed, verify login, permissions, and message') | ||
return http(httpOpt) | ||
.then(function(res) { | ||
if(res.statusCode === 403) { | ||
throw new Error('Token Validation Failed - Failed to verify XCSRF Token.') | ||
} | ||
if(res.statusCode === 401) { | ||
throw new Error('Shout failed, verify that you are logged in.') | ||
} | ||
if(res.statusCode === 400) { | ||
let resErrors = res.body.errors | ||
for (let i = 0; i < resErrors.length; i++) { | ||
let resError = resErrors[i] | ||
if(resError.code === 7) { | ||
throw new Error('Shout failed, verify that you are providing a message to shout.') | ||
} | ||
if(resError.code === 6) { | ||
throw new Error('Shout failed, verify that the logged in user has permissions to shout.') | ||
} | ||
if(resError.code === 1) { | ||
throw new Error('Shout failed, verify that the group provided exists.') | ||
} | ||
} | ||
}) | ||
} | ||
}) | ||
} | ||
// Define | ||
exports.func = function(args) { | ||
let jar = args.jar | ||
return getGeneralToken({jar: jar}) | ||
.then(function(xcsrf) { | ||
return shoutOnGroup(args.group, args.message, args.jar, xcsrf) | ||
}) | ||
} |
{ | ||
"name": "noblox.js", | ||
"version": "4.1.3", | ||
"version": "4.1.4", | ||
"description": "A Node.js wrapper for ROBLOX. (original from sentanos)", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -51,2 +51,35 @@ <h1 align="center"> | ||
## Making use of new login workaround | ||
### Initial setup | ||
1. Remove any usages of the `login` method. | ||
2. Run `cookieLogin` when your app starts. You only need to run it on app start. Supply it with a cookie, guide on obtaining that below. | ||
3. This cookie will be automatically refreshed. You never need to supply it again, but supplying it is unlikely to cause problems | ||
### Getting your cookie (Chrome): | ||
1. Open any Roblox page and login | ||
2. Press `Control + Shift + i` on your keyboard | ||
3. Click `Application` | ||
4. Find `.ROBLOSECURITY`. Copy it's contents, which will start with `_|WARNING:-DO` | ||
5. Put this full token, *including* the warning into cookieLogin: `rbx.cookieLogin( tokenHere )` | ||
### Example | ||
This example makes use of the new async-await syntax. | ||
```js | ||
const rbx = require("noblox.js") | ||
async function startApp () { | ||
await rbx.cookieLogin("_|WARNING:-DO-NOT-SHARE-THIS.--Sharing-this-will-allow-someone-to-log-in-as-you-and-to-steal-your-ROBUX-and-items.|_F9F1EA531adk") | ||
// Do everything else, calling functions and the like. | ||
let currentUser = await rbx.getCurrentUser() | ||
} | ||
``` | ||
## Drawbacks | ||
- Only one application can be logged in at once. | ||
- If the application is offline for like a week to a month you may need to get the cookie again | ||
- Your cookie is stored within a file in the lib | ||
- Roblox-js-server is **not** currently compatible. Use [noblox.js-server](https://github.com/suufi/noblox.js-server) instead. | ||
- The application will **not** work on Heroku. This is because we store the cookie internally in a file, and files do not persist in Heroku. | ||
## Credits | ||
@@ -53,0 +86,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
196836
148
5581
91