fca-unofficial
Advanced tools
Comparing version 1.0.15 to 1.0.16
@@ -1002,3 +1002,3 @@ # Documentation | ||
<a name="listen"></a> | ||
### api.listen(callback) | ||
### api.listen(callback) (deprecated, use `api.listenMqtt` instead) | ||
@@ -1647,2 +1647,3 @@ Will call `callback` when a new message is received on this account. | ||
- `proxy`: (Default empty) Set this to proxy server address to use proxy. Note: Only HTTP Proxies which support CONNECT method is supported. | ||
- `online`: (Default `true`) Set account's online state. | ||
@@ -1649,0 +1650,0 @@ __Example__ |
54
index.js
@@ -6,2 +6,3 @@ "use strict"; | ||
var log = require("npmlog"); | ||
var deasync = require("deasync"); | ||
@@ -14,2 +15,5 @@ var defaultLogRecordSize = 100; | ||
switch (key) { | ||
case 'online': | ||
globalOptions.online = Boolean(options.online); | ||
break; | ||
case 'logLevel': | ||
@@ -377,3 +381,3 @@ log.level = options.logLevel; | ||
.then(function(_res) { | ||
log.info("login", 'Request to pull 1'); | ||
log.info("login", 'Request to base pull'); | ||
var form = { | ||
@@ -393,7 +397,5 @@ channel : 'p_' + ctx.userID, | ||
ctx.jar.setCookie("presence=" + presence + "; path=/; domain=.facebook.com; secure", "https://www.facebook.com"); | ||
ctx.jar.setCookie("presence=" + presence + "; path=/; domain=.messenger.com; secure", "https://www.messenger.com"); | ||
ctx.jar.setCookie("locale=en_US; path=/; domain=.facebook.com; secure", "https://www.facebook.com"); | ||
ctx.jar.setCookie("locale=en_US; path=/; domain=.messenger.com; secure", "https://www.messenger.com"); | ||
ctx.jar.setCookie("a11y=" + utils.generateAccessiblityCookie() + "; path=/; domain=.facebook.com; secure", "https://www.facebook.com"); | ||
return utils | ||
@@ -409,3 +411,2 @@ .get("https://0-edge-chat.facebook.com/pull", ctx.jar, form, globalOptions) | ||
} | ||
return ret; | ||
@@ -415,3 +416,3 @@ }); | ||
.then(function(resData) { | ||
if (resData.t !== 'lb') throw {error: "Bad response from pull 1"}; | ||
if (resData.t !== 'lb') throw {error: "Bad response from base pull"}; | ||
@@ -432,7 +433,37 @@ var form = { | ||
}; | ||
log.info("login", "Request to pull 2"); | ||
return utils | ||
.get("https://0-edge-chat.facebook.com/pull", ctx.jar, form, globalOptions) | ||
.then(utils.saveCookies(ctx.jar)); | ||
var lastOnlineTime = new Date(); | ||
setTimeout(function () { | ||
var done = false; | ||
for (;;) { | ||
log.info("login", "Request to pull (ping)"); | ||
done = false; | ||
utils.get("https://0-edge-chat.facebook.com/pull", ctx.jar, form, globalOptions) | ||
.then(utils.saveCookies(ctx.jar)) | ||
.then(function () { | ||
done = true; | ||
}); | ||
deasync.loopWhile(function () { | ||
return !done; | ||
}); | ||
if (globalOptions.online) { | ||
lastOnlineTime = new Date(); | ||
} | ||
form = { | ||
channel: 'p_' + ctx.userID, | ||
seq: 0, | ||
partition: -2, | ||
clientid: ctx.clientID, | ||
viewer_uid: ctx.userID, | ||
uid: ctx.userID, | ||
idle: Math.floor((new Date().getTime() - lastOnlineTime.getTime()) / 1000), | ||
cap: 8, | ||
msgs_recv: 0, | ||
sticky_token: resData.lb_info.sticky, | ||
sticky_pool: resData.lb_info.pool, | ||
}; | ||
if (globalOptions.online) { | ||
form.state = 'active'; | ||
} | ||
} | ||
}, 1); | ||
}); | ||
@@ -483,2 +514,3 @@ | ||
logRecordSize: defaultLogRecordSize, | ||
online: true, | ||
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/8.0.3 Safari/600.3.18" | ||
@@ -485,0 +517,0 @@ }; |
{ | ||
"name": "fca-unofficial", | ||
"version": "1.0.15", | ||
"version": "1.0.16", | ||
"description": "A Facebook chat API that doesn't rely on XMPP. Will NOT be deprecated after April 30th 2015.", | ||
@@ -27,2 +27,3 @@ "scripts": { | ||
"cheerio": "^0.22.0", | ||
"deasync": "^0.1.19", | ||
"https-proxy-agent": "^4.0.0", | ||
@@ -38,3 +39,3 @@ "mqtt": "^3.0.0", | ||
"eslint": "^4.19.1", | ||
"mocha": "^2.2.5", | ||
"mocha": "^7.0.1", | ||
"prettier": "^1.11.1" | ||
@@ -41,0 +42,0 @@ }, |
538053
6716
7
+ Addeddeasync@^0.1.19
+ Addedbindings@1.5.0(transitive)
+ Addeddeasync@0.1.30(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
+ Addednode-addon-api@1.7.2(transitive)