alicezetion 1.7.9 → 1.8.1

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.
@@ -1 +1 @@
1
- {"nonce":463111461828362637,"last_updated":{"seconds":1696932298,"nanos":311873000}}
1
+ {"nonce":4541222632038562979,"last_updated":{"seconds":1696933204,"nanos":504530000}}
package/index.js CHANGED
@@ -199,7 +199,7 @@ function buildAPI(globalOptions, html, jar) {
199
199
  'removeUserFromGroup',
200
200
  'resolvePhotoUrl',
201
201
  'searchForThread',
202
- 'seen'
202
+ 'seen',
203
203
  'sendMessage',
204
204
  'sendTypingIndicator',
205
205
  'setMessageReaction',
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ const log = require("npmlog");
5
+ const bluebird = require("bluebird");
6
+
7
+ module.exports = function (defaultFuncs, api, ctx) {
8
+ function handleUpload(image, callback) {
9
+ const uploads = [];
10
+
11
+ const form = {
12
+ profile_id: ctx.i_userID || ctx.userID,
13
+ photo_source: 57,
14
+ av: ctx.i_userID || ctx.userID,
15
+ file: image
16
+ };
17
+
18
+ uploads.push(
19
+ defaultFuncs
20
+ .postFormData(
21
+ "https://www.facebook.com/profile/picture/upload/",
22
+ ctx.jar,
23
+ form,
24
+ {}
25
+ )
26
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
27
+ .then(function (resData) {
28
+ if (resData.error) {
29
+ throw resData;
30
+ }
31
+ return resData;
32
+ })
33
+ );
34
+
35
+ // resolve all promises
36
+ bluebird
37
+ .all(uploads)
38
+ .then(function (resData) {
39
+ callback(null, resData);
40
+ })
41
+ .catch(function (err) {
42
+ log.error("handleUpload", err);
43
+ return callback(err);
44
+ });
45
+ }
46
+
47
+ return function changeAvatar(image, caption = "", timestamp = null, callback) {
48
+ let resolveFunc = function () { };
49
+ let rejectFunc = function () { };
50
+ const returnPromise = new Promise(function (resolve, reject) {
51
+ resolveFunc = resolve;
52
+ rejectFunc = reject;
53
+ });
54
+
55
+ if (!timestamp && utils.getType(caption) === "Number") {
56
+ timestamp = caption;
57
+ caption = "";
58
+ }
59
+
60
+ if (!timestamp && !callback && (utils.getType(caption) == "Function" || utils.getType(caption) == "AsyncFunction")) {
61
+ callback = caption;
62
+ caption = "";
63
+ timestamp = null;
64
+ }
65
+
66
+ if (!callback) callback = function (err, data) {
67
+ if (err) {
68
+ return rejectFunc(err);
69
+ }
70
+ resolveFunc(data);
71
+ };
72
+
73
+ if (!utils.isReadableStream(image))
74
+ return callback("Image is not a readable stream");
75
+
76
+ handleUpload(image, function (err, payload) {
77
+ if (err) {
78
+ return callback(err);
79
+ }
80
+
81
+ const form = {
82
+ av: ctx.i_userID || ctx.userID,
83
+ fb_api_req_friendly_name: "ProfileCometProfilePictureSetMutation",
84
+ fb_api_caller_class: "RelayModern",
85
+ doc_id: "5066134240065849",
86
+ variables: JSON.stringify({
87
+ input: {
88
+ caption,
89
+ existing_photo_id: payload[0].payload.fbid,
90
+ expiration_time: timestamp,
91
+ profile_id: ctx.i_userID || ctx.userID,
92
+ profile_pic_method: "EXISTING",
93
+ profile_pic_source: "TIMELINE",
94
+ scaled_crop_rect: {
95
+ height: 1,
96
+ width: 1,
97
+ x: 0,
98
+ y: 0
99
+ },
100
+ skip_cropping: true,
101
+ actor_id: ctx.i_userID || ctx.userID,
102
+ client_mutation_id: Math.round(Math.random() * 19).toString()
103
+ },
104
+ isPage: false,
105
+ isProfile: true,
106
+ scale: 3
107
+ })
108
+ };
109
+
110
+ defaultFuncs
111
+ .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
112
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
113
+ .then(function (resData) {
114
+ if (resData.errors) {
115
+ throw resData;
116
+ }
117
+ return callback(null, resData[0].data.profile_picture_set);
118
+ })
119
+ .catch(function (err) {
120
+ log.error("changeAvatar", err);
121
+ return callback(err);
122
+ });
123
+ });
124
+
125
+ return returnPromise;
126
+ };
127
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alicezetion",
3
- "version": "1.7.9",
3
+ "version": "1.8.1",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "start": "node index.js"
@@ -26,42 +26,5 @@
26
26
  "npmlog": "^7.0.1",
27
27
  "request": "^2.88.2",
28
28
  "websocket-stream": "^5.5.2"
29
- },
30
- "engines": {
31
- "node": ">=10.x"
32
- },
33
- "eslintConfig": {
34
- "env": {
35
- "es6": true,
36
- "es2017": true,
37
- "node": true
38
- },
39
- "extends": "eslint:recommended",
40
- "parserOptions": {
41
- "sourceType": "module"
42
- },
43
- "rules": {
44
- "linebreak-style": [
45
- "error",
46
- "unix"
47
- ],
48
- "semi": [
49
- "error",
50
- "always"
51
- ],
52
- "no-unused-vars": [
53
- 1,
54
- {
55
- "argsIgnorePattern": "^_",
56
- "varsIgnorePattern": "^_"
57
- }
58
- ],
59
- "no-empty": [
60
- "error",
61
- {
62
- "allowEmptyCatch": true
63
- }
64
- ]
65
- }
66
29
  }
67
30
  }
package/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - "6"
4
-
5
- script:
6
- - npm run lint