node-ainzfb-new 1.7.7-iu0tg78 → 1.7.10-11
Sign up to get free protection for your applications and to get access to all the features.
- package/DOCS.md +56 -25
- package/index.js +83 -41
- package/package.json +2 -2
- package/src/changeAvt.js +73 -73
- package/src/editMessage.js +84 -0
- package/src/getAccessToken.js +21 -21
- package/src/getThreadInfo.js +3423 -18
- package/src/getUserInfoV2.js +19 -22
- package/src/pinMessage.js +61 -0
- package/src/shareContact.js +56 -0
- package/src/shareLink.js +57 -0
- package/utils.js +1480 -1063
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
});
|
84
|
-
});
|
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);
|
85
83
|
});
|
86
|
-
}
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
}
|
84
|
+
});
|
85
|
+
});
|
86
|
+
} catch (e) {
|
87
|
+
throw e;
|
88
|
+
}
|
89
|
+
return returnPromise;
|
90
|
+
};
|
91
91
|
};
|
@@ -0,0 +1,84 @@
|
|
1
|
+
"use_strict";
|
2
|
+
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
+
return function editMessage(text, messageID, callback) {
|
8
|
+
let reqID = ctx.wsReqNumber + 1;
|
9
|
+
var resolveFunc = function() {};
|
10
|
+
var rejectFunc = function() {};
|
11
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
12
|
+
resolveFunc = resolve;
|
13
|
+
rejectFunc = reject;
|
14
|
+
});
|
15
|
+
|
16
|
+
if (!callback) {
|
17
|
+
callback = function(err, data) {
|
18
|
+
if (err) {
|
19
|
+
return rejectFunc(err);
|
20
|
+
}
|
21
|
+
resolveFunc(data);
|
22
|
+
};
|
23
|
+
}
|
24
|
+
|
25
|
+
var form = {
|
26
|
+
message_id: messageID,
|
27
|
+
text: text
|
28
|
+
};
|
29
|
+
|
30
|
+
var content = {
|
31
|
+
app_id: "2220391788200892",
|
32
|
+
payload: JSON.stringify({
|
33
|
+
data_trace_id: null,
|
34
|
+
epoch_id: parseInt(utils.generateOfflineThreadingID()),
|
35
|
+
tasks: [
|
36
|
+
{
|
37
|
+
failure_count: null,
|
38
|
+
label: "742",
|
39
|
+
payload: JSON.stringify(form),
|
40
|
+
queue_name: "edit_message",
|
41
|
+
task_id: ++ctx.wsTaskNumber
|
42
|
+
}
|
43
|
+
],
|
44
|
+
version_id: "6903494529735864"
|
45
|
+
}),
|
46
|
+
request_id: ++ctx.wsReqNumber,
|
47
|
+
type: 3
|
48
|
+
};
|
49
|
+
|
50
|
+
ctx.mqttClient.publish("/ls_req", JSON.stringify(content), {
|
51
|
+
qos: 1,
|
52
|
+
retain: false
|
53
|
+
});
|
54
|
+
const handleRes = function(topic, message, _packet) {
|
55
|
+
if (topic === "/ls_resp") {
|
56
|
+
let jsonMsg = JSON.parse(message.toString());
|
57
|
+
jsonMsg.payload = JSON.parse(jsonMsg.payload);
|
58
|
+
if (jsonMsg.request_id != reqID) return;
|
59
|
+
ctx.mqttClient.removeListener("message", handleRes);
|
60
|
+
|
61
|
+
let msgID = jsonMsg.payload.step[1][2][2][1][2];
|
62
|
+
let msgReplace = jsonMsg.payload.step[1][2][2][1][4];
|
63
|
+
|
64
|
+
if (msgReplace != text) {
|
65
|
+
let err = { error: "The message is too old or not from you!" };
|
66
|
+
log.error("editMessage", err);
|
67
|
+
|
68
|
+
return callback(err, {
|
69
|
+
body: msgReplace,
|
70
|
+
messageID: msgID
|
71
|
+
});
|
72
|
+
}
|
73
|
+
|
74
|
+
return callback(undefined, {
|
75
|
+
body: msgReplace,
|
76
|
+
messageID: msgID
|
77
|
+
});
|
78
|
+
}
|
79
|
+
};
|
80
|
+
ctx.mqttClient.on("message", handleRes);
|
81
|
+
|
82
|
+
return returnPromise;
|
83
|
+
};
|
84
|
+
};
|
package/src/getAccessToken.js
CHANGED
@@ -4,29 +4,29 @@
|
|
4
4
|
var utils = require("../utils");
|
5
5
|
var log = require("npmlog");
|
6
6
|
|
7
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
8
|
+
return function getAccessToken(callback) {
|
9
|
+
var resolveFunc = function() {};
|
10
|
+
var rejectFunc = function() {};
|
11
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
12
|
+
resolveFunc = resolve;
|
13
|
+
rejectFunc = reject;
|
14
|
+
});
|
7
15
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
resolveFunc = resolve;
|
14
|
-
rejectFunc = reject;
|
15
|
-
});
|
16
|
-
|
17
|
-
if (!callback) {
|
18
|
-
callback = function (err, userInfo) {
|
19
|
-
if (err) return rejectFunc(err);
|
20
|
-
resolveFunc(userInfo);
|
21
|
-
};
|
22
|
-
}
|
23
|
-
try {
|
24
|
-
var { getAccessToken } = require('../Extra/ExtraAddons');
|
25
|
-
getAccessToken(ctx.jar,ctx,defaultFuncs).then(data => callback(null,data));
|
16
|
+
if (!callback) {
|
17
|
+
callback = function(err, userInfo) {
|
18
|
+
if (err) return rejectFunc(err);
|
19
|
+
resolveFunc(userInfo);
|
20
|
+
};
|
26
21
|
}
|
27
|
-
|
22
|
+
try {
|
23
|
+
var { getAccessToken } = require("../Extra/ExtraAddons");
|
24
|
+
getAccessToken(ctx.jar, ctx, defaultFuncs).then(data =>
|
25
|
+
callback(null, data)
|
26
|
+
);
|
27
|
+
} catch (e) {
|
28
28
|
callback(null, e);
|
29
29
|
}
|
30
30
|
return returnPromise;
|
31
|
-
|
32
|
-
|
31
|
+
};
|
32
|
+
};
|