node-ainzfb-new 1.6.2911-test → 1.6.2916-test

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/changeAvt.js +73 -73
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-ainzfb-new",
3
- "version": "1.6.2911-test",
3
+ "version": "1.6.2916-test",
4
4
  "description": "A Facebook chat API that doesn't rely on XMPP. Will NOT be deprecated after April 30th 2015.",
5
5
  "scripts": {
6
6
  "test": "mocha",
@@ -26,7 +26,7 @@
26
26
  "aes-js": "latest",
27
27
  "assert": "latest",
28
28
  "better-sqlite3": "latest",
29
- "bluebird": "latest",
29
+ "bluebird": "^2.11.0",
30
30
  "chalk": "^4.1.2",
31
31
  "cheerio": "latest",
32
32
  "crypto": "latest",
package/src/changeAvt.js CHANGED
@@ -11,81 +11,81 @@ var log = require("npmlog");
11
11
  * {"__ar":1,"payload":null,"jsmods":{"require":[["ImageUploader","uploadPhoto",[{"__m":"__elem_0"},{"__m":"__elem_1"},{"__m":"__elem_2"},{"__m":"__
12
12
  */
13
13
  async function postImage(Api, BotID, form) {
14
- var Data = await Api.httpPostFormData(
15
- `https://www.facebook.com/profile/picture/upload/?profile_id=${BotID}&photo_source=57&av=${BotID}`,
16
- form
17
- );
18
- return JSON.parse(Data.split("for (;;);")[1]);
14
+ var Data = await Api.httpPostFormData(
15
+ `https://www.facebook.com/profile/picture/upload/?profile_id=${BotID}&photo_source=57&av=${BotID}`,
16
+ form
17
+ );
18
+ return JSON.parse(Data.split("for (;;);")[1]);
19
19
  }
20
20
 
21
- module.exports = function(defaultFuncs, api, ctx) {
22
- /* Changing the profile picture of the bot. */
23
- return function changeAvt(link, caption, callback) {
24
- var resolveFunc = function() {};
25
- var rejectFunc = function() {};
26
- var returnPromise = new Promise(function(resolve, reject) {
27
- resolveFunc = resolve;
28
- rejectFunc = reject;
29
- });
21
+ module.exports = function (defaultFuncs, api, ctx) {
22
+ /* Changing the profile picture of the bot. */
23
+ return function changeAvt(link, caption, callback) {
24
+ var resolveFunc = function () { };
25
+ var rejectFunc = function () { };
26
+ var returnPromise = new Promise(function (resolve, reject) {
27
+ resolveFunc = resolve;
28
+ rejectFunc = reject;
29
+ });
30
30
 
31
- if (!callback) {
32
- callback = function(err, data) {
33
- if (err) return rejectFunc(err);
34
- resolveFunc(data);
35
- };
36
- }
37
- try {
38
- var Fetch = require("axios");
39
- Fetch.get(link, { responseType: "stream" }).then(data => {
40
- postImage(api, ctx.userID, { file: data.data }).then(data => {
41
- if (data.error)
42
- throw new Error({
43
- error: data.error,
44
- des: data.error.errorDescription
45
- });
46
- var form = {
47
- av: ctx.userID,
48
- fb_api_req_friendly_name: "ProfileCometProfilePictureSetMutation",
49
- fb_api_caller_class: "RelayModern",
50
- doc_id: "5066134240065849",
51
- variables: JSON.stringify({
52
- input: {
53
- caption: caption || "",
54
- existing_photo_id: data.payload.fbid,
55
- expiration_time: null,
56
- profile_id: ctx.userID,
57
- profile_pic_method: "EXISTING",
58
- profile_pic_source: "TIMELINE",
59
- scaled_crop_rect: {
60
- height: 1,
61
- width: 1,
62
- x: 0,
63
- y: 0
64
- },
65
- skip_cropping: true,
66
- actor_id: ctx.userID,
67
- client_mutation_id: Math.round(Math.random() * 19).toString()
68
- },
69
- isPage: false,
70
- isProfile: true,
71
- scale: 3
72
- })
73
- };
74
- defaultFuncs
75
- .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
76
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
77
- .then(function(resData) {
78
- if (resData.error) throw resData;
79
- else return callback(null, true);
80
- })
81
- .catch(function(err) {
82
- return callback(err);
31
+ if (!callback) {
32
+ callback = function (err, data) {
33
+ if (err) return rejectFunc(err);
34
+ resolveFunc(data);
35
+ };
36
+ }
37
+ try {
38
+ var Fetch = require("axios");
39
+ Fetch.get(link, { responseType: "stream" }).then(data => {
40
+ postImage(api, ctx.userID, { file: data.data }).then(data => {
41
+ if (data.error)
42
+ throw new Error({
43
+ error: data.error,
44
+ des: data.error.errorDescription
45
+ });
46
+ var form = {
47
+ av: ctx.userID,
48
+ fb_api_req_friendly_name: "ProfileCometProfilePictureSetMutation",
49
+ fb_api_caller_class: "RelayModern",
50
+ doc_id: "5066134240065849",
51
+ variables: JSON.stringify({
52
+ input: {
53
+ caption: caption || "",
54
+ existing_photo_id: data.payload.fbid,
55
+ expiration_time: null,
56
+ profile_id: ctx.userID,
57
+ profile_pic_method: "EXISTING",
58
+ profile_pic_source: "TIMELINE",
59
+ scaled_crop_rect: {
60
+ height: 1,
61
+ width: 1,
62
+ x: 0,
63
+ y: 0
64
+ },
65
+ skip_cropping: true,
66
+ actor_id: ctx.userID,
67
+ client_mutation_id: Math.round(Math.random() * 19).toString()
68
+ },
69
+ isPage: false,
70
+ isProfile: true,
71
+ scale: 3
72
+ })
73
+ };
74
+ defaultFuncs
75
+ .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
76
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
77
+ .then(function (resData) {
78
+ if (resData.error) throw resData;
79
+ else return callback(null, true);
80
+ })
81
+ .catch(function (err) {
82
+ return callback(err);
83
+ });
84
+ });
83
85
  });
84
- });
85
- });
86
- } catch (e) {
87
- throw e;
88
- }
89
- return returnPromise;
90
- };
86
+ } catch (e) {
87
+ throw e;
88
+ }
89
+ return returnPromise;
90
+ };
91
91
  };