@dongdev/fca-unofficial 1.0.19 → 2.0.0

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 (128) hide show
  1. package/.gitattributes +1 -0
  2. package/CHANGELOG.md +30 -27
  3. package/DOCS.md +727 -592
  4. package/README.md +94 -97
  5. package/func/logger.js +112 -0
  6. package/html.html +474 -0
  7. package/index.js +1 -379
  8. package/module/config.js +26 -0
  9. package/module/login.js +45 -0
  10. package/module/loginHelper.js +634 -0
  11. package/module/options.js +49 -0
  12. package/package.json +6 -39
  13. package/src/api/action/addExternalModule.js +25 -0
  14. package/src/api/action/changeAvatar.js +136 -0
  15. package/src/api/action/changeBio.js +76 -0
  16. package/src/api/action/getCurrentUserID.js +7 -0
  17. package/src/api/action/handleFriendRequest.js +57 -0
  18. package/src/api/action/logout.js +75 -0
  19. package/src/{refreshFb_dtsg.js → api/action/refreshFb_dtsg.js} +8 -8
  20. package/src/api/action/setPostReaction.js +107 -0
  21. package/src/api/action/unfriend.js +55 -0
  22. package/src/api/http/httpGet.js +65 -0
  23. package/src/api/http/httpPost.js +65 -0
  24. package/src/{postFormData.js → api/http/postFormData.js} +10 -10
  25. package/src/api/messaging/addUserToGroup.js +69 -0
  26. package/src/api/messaging/changeAdminStatus.js +103 -0
  27. package/src/api/messaging/changeArchivedStatus.js +55 -0
  28. package/src/api/messaging/changeBlockedStatus.js +49 -0
  29. package/src/api/messaging/changeGroupImage.js +135 -0
  30. package/src/api/messaging/changeNickname.js +59 -0
  31. package/src/api/messaging/changeThreadColor.js +65 -0
  32. package/src/api/messaging/createNewGroup.js +88 -0
  33. package/src/api/messaging/createPoll.js +70 -0
  34. package/src/api/messaging/deleteMessage.js +56 -0
  35. package/src/api/messaging/deleteThread.js +56 -0
  36. package/src/api/messaging/forwardAttachment.js +60 -0
  37. package/src/api/messaging/getEmojiUrl.js +29 -0
  38. package/src/api/messaging/getFriendsList.js +83 -0
  39. package/src/api/messaging/getMessage.js +834 -0
  40. package/src/api/messaging/getThreadHistory.js +681 -0
  41. package/src/api/messaging/handleMessageRequest.js +65 -0
  42. package/src/api/messaging/markAsDelivered.js +57 -0
  43. package/src/api/messaging/markAsRead.js +88 -0
  44. package/src/api/messaging/markAsReadAll.js +50 -0
  45. package/src/api/messaging/markAsSeen.js +61 -0
  46. package/src/api/messaging/muteThread.js +51 -0
  47. package/src/api/messaging/removeUserFromGroup.js +79 -0
  48. package/src/api/messaging/resolvePhotoUrl.js +44 -0
  49. package/src/api/messaging/searchForThread.js +53 -0
  50. package/src/api/messaging/sendMessage.js +306 -0
  51. package/src/api/messaging/sendMessageMqtt.js +321 -0
  52. package/src/api/messaging/sendTypingIndicator.js +110 -0
  53. package/src/{setMessageReaction.js → api/messaging/setMessageReaction.js} +20 -20
  54. package/src/api/messaging/setTitle.js +90 -0
  55. package/src/api/messaging/shareContact.js +51 -0
  56. package/src/api/messaging/threadColors.js +131 -0
  57. package/src/api/messaging/unsendMessage.js +44 -0
  58. package/src/api/messaging/uploadAttachment.js +93 -0
  59. package/src/api/socket/detail/buildStream.js +100 -0
  60. package/src/{listenMqtt.js → api/socket/listenMqtt.js} +172 -256
  61. package/src/api/threads/changeThreadEmoji.js +55 -0
  62. package/src/api/threads/getThreadInfo.js +572 -0
  63. package/src/{getThreadList.js → api/threads/getThreadList.js} +110 -54
  64. package/src/api/threads/getThreadPictures.js +79 -0
  65. package/src/api/users/getUserID.js +66 -0
  66. package/src/api/users/getUserInfo.js +88 -0
  67. package/src/core/sendReqMqtt.js +63 -0
  68. package/{lib → src}/database/models/index.js +12 -10
  69. package/{lib → src}/database/models/thread.js +5 -5
  70. package/{lib → src}/database/threadData.js +19 -14
  71. package/src/utils/client.js +159 -0
  72. package/src/utils/constants.js +13 -0
  73. package/src/utils/format.js +60 -0
  74. package/src/utils/headers.js +41 -0
  75. package/src/utils/index.js +1497 -0
  76. package/src/utils/request.js +147 -0
  77. package/lib/logger.js +0 -96
  78. package/src/addExternalModule.js +0 -19
  79. package/src/addUserToGroup.js +0 -113
  80. package/src/changeAdminStatus.js +0 -79
  81. package/src/changeArchivedStatus.js +0 -55
  82. package/src/changeAvatar.js +0 -126
  83. package/src/changeBio.js +0 -77
  84. package/src/changeBlockedStatus.js +0 -47
  85. package/src/changeGroupImage.js +0 -132
  86. package/src/changeNickname.js +0 -59
  87. package/src/changeThreadColor.js +0 -65
  88. package/src/changeThreadEmoji.js +0 -55
  89. package/src/createNewGroup.js +0 -86
  90. package/src/createPoll.js +0 -71
  91. package/src/deleteMessage.js +0 -56
  92. package/src/deleteThread.js +0 -56
  93. package/src/forwardAttachment.js +0 -60
  94. package/src/getCurrentUserID.js +0 -7
  95. package/src/getEmojiUrl.js +0 -29
  96. package/src/getFriendsList.js +0 -83
  97. package/src/getMessage.js +0 -796
  98. package/src/getThreadHistory.js +0 -666
  99. package/src/getThreadInfo.js +0 -535
  100. package/src/getThreadPictures.js +0 -79
  101. package/src/getUserID.js +0 -66
  102. package/src/getUserInfo.js +0 -80
  103. package/src/handleFriendRequest.js +0 -61
  104. package/src/handleMessageRequest.js +0 -65
  105. package/src/httpGet.js +0 -57
  106. package/src/httpPost.js +0 -57
  107. package/src/httpPostFormData.js +0 -63
  108. package/src/logout.js +0 -75
  109. package/src/markAsDelivered.js +0 -58
  110. package/src/markAsRead.js +0 -80
  111. package/src/markAsReadAll.js +0 -50
  112. package/src/markAsSeen.js +0 -59
  113. package/src/muteThread.js +0 -52
  114. package/src/removeUserFromGroup.js +0 -79
  115. package/src/resolvePhotoUrl.js +0 -45
  116. package/src/searchForThread.js +0 -53
  117. package/src/sendMessage.js +0 -328
  118. package/src/sendMessageMqtt.js +0 -316
  119. package/src/sendTypingIndicator.js +0 -103
  120. package/src/setPostReaction.js +0 -109
  121. package/src/setTitle.js +0 -86
  122. package/src/shareContact.js +0 -49
  123. package/src/threadColors.js +0 -131
  124. package/src/unfriend.js +0 -52
  125. package/src/unsendMessage.js +0 -49
  126. package/src/uploadAttachment.js +0 -95
  127. package/utils.js +0 -1387
  128. /package/{lib → func}/login.js +0 -0
package/DOCS.md CHANGED
@@ -1,49 +1,49 @@
1
1
  # Documentation
2
2
 
3
- * [`login`](#login)
4
- * [`api.addUserToGroup`](#addUserToGroup)
5
- * [`api.changeAdminStatus`](#changeAdminStatus)
6
- * [`api.changeArchivedStatus`](#changeArchivedStatus)
7
- * [`api.changeBlockedStatus`](#changeBlockedStatus)
8
- * [`api.changeGroupImage`](#changeGroupImage)
9
- * [`api.changeNickname`](#changeNickname)
10
- * [`api.changeThreadColor`](#changeThreadColor)
11
- * [`api.changeThreadEmoji`](#changeThreadEmoji)
12
- * [`api.createNewGroup`](#createNewGroup)
13
- * [`api.createPoll`](#createPoll)
14
- * [`api.deleteMessage`](#deleteMessage)
15
- * [`api.deleteThread`](#deleteThread)
16
- * [`api.forwardAttachment`](#forwardAttachment)
17
- * [`api.getAppState`](#getAppState)
18
- * [`api.getCurrentUserID`](#getCurrentUserID)
19
- * [`api.getEmojiUrl`](#getEmojiUrl)
20
- * [`api.getFriendsList`](#getFriendsList)
21
- * [`api.getThreadHistory`](#getThreadHistory)
22
- * [`api.getThreadInfo`](#getThreadInfo)
23
- * [`api.getThreadList`](#getThreadList)
24
- * [`api.getThreadPictures`](#getThreadPictures)
25
- * [`api.getUserID`](#getUserID)
26
- * [`api.getUserInfo`](#getUserInfo)
27
- * [`api.handleMessageRequest`](#handleMessageRequest)
28
- * [`api.listenMqtt`](#listenMqtt)
29
- * [`api.logout`](#logout)
30
- * [`api.markAsDelivered`](#markAsDelivered)
31
- * [`api.markAsRead`](#markAsRead)
32
- * [`api.markAsReadAll`](#markAsReadAll)
33
- * [`api.markAsSeen`](#markAsSeen)
34
- * [`api.muteThread`](#muteThread)
35
- * [`api.removeUserFromGroup`](#removeUserFromGroup)
36
- * [`api.resolvePhotoUrl`](#resolvePhotoUrl)
37
- * [`api.searchForThread`](#searchForThread)
38
- * [`api.sendMessage`](#sendMessage)
39
- * [`api.sendTypingIndicator`](#sendTypingIndicator)
40
- * [`api.setMessageReaction`](#setMessageReaction)
41
- * [`api.setOptions`](#setOptions)
42
- * [`api.setTitle`](#setTitle)
43
- * [`api.threadColors`](#threadColors)
44
- * [`api.unsendMessage`](#unsendMessage)
45
-
46
- ---------------------------------------
3
+ - [`login`](#login)
4
+ - [`api.addUserToGroup`](#addUserToGroup)
5
+ - [`api.changeAdminStatus`](#changeAdminStatus)
6
+ - [`api.changeArchivedStatus`](#changeArchivedStatus)
7
+ - [`api.changeBlockedStatus`](#changeBlockedStatus)
8
+ - [`api.changeGroupImage`](#changeGroupImage)
9
+ - [`api.changeNickname`](#changeNickname)
10
+ - [`api.changeThreadColor`](#changeThreadColor)
11
+ - [`api.changeThreadEmoji`](#changeThreadEmoji)
12
+ - [`api.createNewGroup`](#createNewGroup)
13
+ - [`api.createPoll`](#createPoll)
14
+ - [`api.deleteMessage`](#deleteMessage)
15
+ - [`api.deleteThread`](#deleteThread)
16
+ - [`api.forwardAttachment`](#forwardAttachment)
17
+ - [`api.getAppState`](#getAppState)
18
+ - [`api.getCurrentUserID`](#getCurrentUserID)
19
+ - [`api.getEmojiUrl`](#getEmojiUrl)
20
+ - [`api.getFriendsList`](#getFriendsList)
21
+ - [`api.getThreadHistory`](#getThreadHistory)
22
+ - [`api.getThreadInfo`](#getThreadInfo)
23
+ - [`api.getThreadList`](#getThreadList)
24
+ - [`api.getThreadPictures`](#getThreadPictures)
25
+ - [`api.getUserID`](#getUserID)
26
+ - [`api.getUserInfo`](#getUserInfo)
27
+ - [`api.handleMessageRequest`](#handleMessageRequest)
28
+ - [`api.listenMqtt`](#listenMqtt)
29
+ - [`api.logout`](#logout)
30
+ - [`api.markAsDelivered`](#markAsDelivered)
31
+ - [`api.markAsRead`](#markAsRead)
32
+ - [`api.markAsReadAll`](#markAsReadAll)
33
+ - [`api.markAsSeen`](#markAsSeen)
34
+ - [`api.muteThread`](#muteThread)
35
+ - [`api.removeUserFromGroup`](#removeUserFromGroup)
36
+ - [`api.resolvePhotoUrl`](#resolvePhotoUrl)
37
+ - [`api.searchForThread`](#searchForThread)
38
+ - [`api.sendMessage`](#sendMessage)
39
+ - [`api.sendTypingIndicator`](#sendTypingIndicator)
40
+ - [`api.setMessageReaction`](#setMessageReaction)
41
+ - [`api.setOptions`](#setOptions)
42
+ - [`api.setTitle`](#setTitle)
43
+ - [`api.threadColors`](#threadColors)
44
+ - [`api.unsendMessage`](#unsendMessage)
45
+
46
+ ---
47
47
 
48
48
  ### Password safety
49
49
 
@@ -51,30 +51,34 @@
51
51
 
52
52
  You should not store Facebook password in your scripts.
53
53
  There are few good reasons:
54
- * People who are standing behind you may look at your "code" and get your password if it is on the screen
55
- * Backups of source files may be readable by someone else. "_There is nothing secret in my code, why should I ever password protect my backups_"
56
- * You can't push your code to Github (or any onther service) without removing your password from the file. Remember: Even if you undo your accidential commit with password, Git doesn't delete it, that commit is just not used but is still readable by everybody.
57
- * If you change your password in the future (maybe it leaked because _someone_ stored password in source file oh… well…) you will have to change every occurrence in your scripts
54
+
55
+ - People who are standing behind you may look at your "code" and get your password if it is on the screen
56
+ - Backups of source files may be readable by someone else. "_There is nothing secret in my code, why should I ever password protect my backups_"
57
+ - You can't push your code to Github (or any onther service) without removing your password from the file. Remember: Even if you undo your accidential commit with password, Git doesn't delete it, that commit is just not used but is still readable by everybody.
58
+ - If you change your password in the future (maybe it leaked because _someone_ stored password in source file… oh… well…) you will have to change every occurrence in your scripts
58
59
 
59
60
  Preferred method is to have `login.js` that saves `AppState` to a file and then use that file from all your scripts.
60
61
  This way you can put password in your code for a minute, login to facebook and then remove it.
61
62
 
62
- If you want to be even more safe: _login.js_ can get password with `require("readline")` or with environment variables like this:
63
+ If you want to be even more safe: _login.js_ can get password with `require("readline")` or with environment variables like this:
64
+
63
65
  ```js
64
66
  var credentials = {
65
- email: process.env.FB_EMAIL,
66
- password: process.env.FB_PASSWORD
67
- }
67
+ email: process.env.FB_EMAIL,
68
+ password: process.env.FB_PASSWORD
69
+ };
68
70
  ```
71
+
69
72
  ```bash
70
73
  FB_EMAIL="john.doe@example.com"
71
74
  FB_PASSWORD="MySuperHardP@ssw0rd"
72
75
  nodejs login.js
73
76
  ```
74
77
 
75
- ---------------------------------------
78
+ ---
76
79
 
77
80
  <a name="login"></a>
81
+
78
82
  ### login(credentials[, options][, callback])
79
83
 
80
84
  This function is returned by `require(...)` and is the main entry point to the API.
@@ -85,61 +89,64 @@ Return a Promise that will resolve if logged in successfully, or reject if faile
85
89
 
86
90
  If `callback` is supplied:
87
91
 
88
- * `callback` will be called with a `null` object (for potential errors) and with an object containing all the available functions if logged in successfully.
92
+ - `callback` will be called with a `null` object (for potential errors) and with an object containing all the available functions if logged in successfully.
89
93
 
90
- * `callback` will be called with an error object if failed to login.
94
+ - `callback` will be called with an error object if failed to login.
91
95
 
92
96
  If `login-approval` error was thrown: Inside error object is `continue` function, you can call that function with 2FA code. The behaviour of this function depends on how you call `login` with:
93
97
 
94
- * If `callback` is not supplied (using `Promise`), this function will return a `Promise` that behaves like `Promise` received from `login`.
98
+ - If `callback` is not supplied (using `Promise`), this function will return a `Promise` that behaves like `Promise` received from `login`.
95
99
 
96
- * If `callback` is supplied, this function will still return a `Promise`, but it will not resolve. Instead, the result is called to `callback`.
100
+ - If `callback` is supplied, this function will still return a `Promise`, but it will not resolve. Instead, the result is called to `callback`.
97
101
 
98
- __Arguments__
102
+ **Arguments**
99
103
 
100
- * `credentials`: An object containing the fields `email` and `password` used to login, __*or*__ an object containing the field `appState`.
101
- * `options`: An object representing options to use when logging in (as described in [api.setOptions](#setOptions)).
102
- * `callback(err, api)`: A callback called when login is done (successful or not). `err` is an object containing a field `error`.
104
+ - `credentials`: An object containing the fields `email` and `password` used to login, **_or_** an object containing the field `appState`.
105
+ - `options`: An object representing options to use when logging in (as described in [api.setOptions](#setOptions)).
106
+ - `callback(err, api)`: A callback called when login is done (successful or not). `err` is an object containing a field `error`.
103
107
 
104
- __Example (Email & Password)__
108
+ **Example (Email & Password)**
105
109
 
106
110
  ```js
107
111
  const login = require("fca-unofficial");
108
112
 
109
- login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
110
- if(err) return console.error(err);
111
- // Here you can use the api
113
+ login({ email: "FB_EMAIL", password: "FB_PASSWORD" }, (err, api) => {
114
+ if (err) return console.error(err);
115
+ // Here you can use the api
112
116
  });
113
117
  ```
114
118
 
115
- __Example (Email & Password then save appState to file)__
119
+ **Example (Email & Password then save appState to file)**
116
120
 
117
121
  ```js
118
122
  const fs = require("fs");
119
123
  const login = require("fca-unofficial");
120
124
 
121
- login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
122
- if(err) return console.error(err);
125
+ login({ email: "FB_EMAIL", password: "FB_PASSWORD" }, (err, api) => {
126
+ if (err) return console.error(err);
123
127
 
124
- fs.writeFileSync('appstate.json', JSON.stringify(api.getAppState()));
128
+ fs.writeFileSync("appstate.json", JSON.stringify(api.getAppState()));
125
129
  });
126
130
  ```
127
131
 
128
- __Example (AppState loaded from file)__
132
+ **Example (AppState loaded from file)**
129
133
 
130
134
  ```js
131
135
  const fs = require("fs");
132
136
  const login = require("fca-unofficial");
133
137
 
134
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
135
- if(err) return console.error(err);
138
+ login(
139
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
140
+ (err, api) => {
141
+ if (err) return console.error(err);
136
142
  // Here you can use the api
137
- });
143
+ }
144
+ );
138
145
  ```
139
146
 
140
- __Login Approvals (2-Factor Auth)__: When you try to login with Login Approvals enabled, your callback will be called with an error `'login-approval'` that has a `continue` function that accepts the approval code as a `string` or a `number`.
147
+ **Login Approvals (2-Factor Auth)**: When you try to login with Login Approvals enabled, your callback will be called with an error `'login-approval'` that has a `continue` function that accepts the approval code as a `string` or a `number`.
141
148
 
142
- __Example__:
149
+ **Example**:
143
150
 
144
151
  ```js
145
152
  const fs = require("fs");
@@ -151,62 +158,66 @@ var rl = readline.createInterface({
151
158
  output: process.stdout
152
159
  });
153
160
 
154
- const obj = {email: "FB_EMAIL", password: "FB_PASSWORD"};
161
+ const obj = { email: "FB_EMAIL", password: "FB_PASSWORD" };
155
162
  login(obj, (err, api) => {
156
- if(err) {
157
- switch (err.error) {
158
- case 'login-approval':
159
- console.log('Enter code > ');
160
- rl.on('line', (line) => {
161
- err.continue(line);
162
- rl.close();
163
- });
164
- break;
165
- default:
166
- console.error(err);
167
- }
168
- return;
163
+ if (err) {
164
+ switch (err.error) {
165
+ case "login-approval":
166
+ console.log("Enter code > ");
167
+ rl.on("line", line => {
168
+ err.continue(line);
169
+ rl.close();
170
+ });
171
+ break;
172
+ default:
173
+ console.error(err);
169
174
  }
175
+ return;
176
+ }
170
177
 
171
- // Logged in!
178
+ // Logged in!
172
179
  });
173
180
  ```
174
181
 
175
- __Review Recent Login__: Sometimes Facebook will ask you to review your recent logins. This means you've recently logged in from a unrecognized location. This will will result in the callback being called with an error `'review-recent-login'` by default. If you wish to automatically approve all recent logins, you can set the option `forceLogin` to `true` in the `loginOptions`.
182
+ **Review Recent Login**: Sometimes Facebook will ask you to review your recent logins. This means you've recently logged in from a unrecognized location. This will will result in the callback being called with an error `'review-recent-login'` by default. If you wish to automatically approve all recent logins, you can set the option `forceLogin` to `true` in the `loginOptions`.
176
183
 
177
-
178
- ---------------------------------------
184
+ ---
179
185
 
180
186
  <a name="addUserToGroup"></a>
187
+
181
188
  ### api.addUserToGroup(userID, threadID[, callback])
182
189
 
183
190
  Adds a user (or array of users) to a group chat.
184
191
 
185
- __Arguments__
192
+ **Arguments**
186
193
 
187
- * `userID`: User ID or array of user IDs.
188
- * `threadID`: Group chat ID.
189
- * `callback(err)`: A callback called when the query is done (either with an error or with no arguments).
194
+ - `userID`: User ID or array of user IDs.
195
+ - `threadID`: Group chat ID.
196
+ - `callback(err)`: A callback called when the query is done (either with an error or with no arguments).
190
197
 
191
- ---------------------------------------
198
+ ---
192
199
 
193
200
  <a name="changeAdminStatus"></a>
201
+
194
202
  ### api.changeAdminStatus(threadID, adminIDs, adminStatus)
195
203
 
196
204
  Given a adminID, or an array of adminIDs, will set the admin status of the user(s) to `adminStatus`.
197
205
 
198
- __Arguments__
199
- * `threadID`: ID of a group chat (can't use in one-to-one conversations)
200
- * `adminIDs`: The id(s) of users you wish to admin/unadmin (string or an array).
201
- * `adminStatus`: Boolean indicating whether the user(s) should be promoted to admin (`true`) or demoted to a regular user (`false`).
206
+ **Arguments**
207
+
208
+ - `threadID`: ID of a group chat (can't use in one-to-one conversations)
209
+ - `adminIDs`: The id(s) of users you wish to admin/unadmin (string or an array).
210
+ - `adminStatus`: Boolean indicating whether the user(s) should be promoted to admin (`true`) or demoted to a regular user (`false`).
202
211
 
203
- __Example__
212
+ **Example**
204
213
 
205
214
  ```js
206
215
  const fs = require("fs");
207
216
  const login = require("fca-unofficial");
208
217
 
209
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, async function(err, api) {
218
+ login(
219
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
220
+ async function(err, api) {
210
221
  if (err) return console.error(err);
211
222
 
212
223
  let threadID = "0000000000000000";
@@ -215,109 +226,129 @@ login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, async fu
215
226
 
216
227
  let adminToRemove = "333333333333333";
217
228
  await api.changeAdminStatus(threadID, adminToRemove, false);
218
-
219
- });
220
-
229
+ }
230
+ );
221
231
  ```
222
232
 
223
- ---------------------------------------
233
+ ---
224
234
 
225
235
  <a name="changeArchivedStatus"></a>
236
+
226
237
  ### api.changeArchivedStatus(threadOrThreads, archive[, callback])
227
238
 
228
239
  Given a threadID, or an array of threadIDs, will set the archive status of the threads to `archive`. Archiving a thread will hide it from the logged-in user's inbox until the next time a message is sent or received.
229
240
 
230
- __Arguments__
231
- * `threadOrThreads`: The id(s) of the threads you wish to archive/unarchive.
232
- * `archive`: Boolean indicating the new archive status to assign to the thread(s).
233
- * `callback(err)`: A callback called when the query is done (either with an error or null).
241
+ **Arguments**
234
242
 
235
- __Example__
243
+ - `threadOrThreads`: The id(s) of the threads you wish to archive/unarchive.
244
+ - `archive`: Boolean indicating the new archive status to assign to the thread(s).
245
+ - `callback(err)`: A callback called when the query is done (either with an error or null).
246
+
247
+ **Example**
236
248
 
237
249
  ```js
238
250
  const fs = require("fs");
239
251
  const login = require("fca-unofficial");
240
252
 
241
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
242
- if(err) return console.error(err);
253
+ login(
254
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
255
+ (err, api) => {
256
+ if (err) return console.error(err);
243
257
 
244
- api.changeArchivedStatus("000000000000000", true, (err) => {
245
- if(err) return console.error(err);
258
+ api.changeArchivedStatus("000000000000000", true, err => {
259
+ if (err) return console.error(err);
246
260
  });
247
- });
261
+ }
262
+ );
248
263
  ```
249
264
 
250
- ---------------------------------------
265
+ ---
251
266
 
252
267
  <a name="changeBlockedStatus"></a>
268
+
253
269
  ### api.changeBlockedStatus(userID, block[, callback])
254
270
 
255
271
  Prevents a user from privately contacting you. (Messages in a group chat will still be seen by both parties).
256
272
 
257
- __Arguments__
273
+ **Arguments**
258
274
 
259
- * `userID`: User ID.
260
- * `block`: Boolean indicating whether to block or unblock the user (true for block).
261
- * `callback(err)`: A callback called when the query is done (either with an error or with no arguments).
275
+ - `userID`: User ID.
276
+ - `block`: Boolean indicating whether to block or unblock the user (true for block).
277
+ - `callback(err)`: A callback called when the query is done (either with an error or with no arguments).
262
278
 
263
- ---------------------------------------
279
+ ---
264
280
 
265
281
  <a name="changeGroupImage"></a>
282
+
266
283
  ### api.changeGroupImage(image, threadID[, callback])
267
284
 
268
285
  Will change the group chat's image to the given image.
269
286
 
270
- __Arguments__
271
- * `image`: File stream of image.
272
- * `threadID`: String representing the ID of the thread.
273
- * `callback(err)`: A callback called when the change is done (either with an error or null).
287
+ **Arguments**
288
+
289
+ - `image`: File stream of image.
290
+ - `threadID`: String representing the ID of the thread.
291
+ - `callback(err)`: A callback called when the change is done (either with an error or null).
274
292
 
275
- __Example__
293
+ **Example**
276
294
 
277
295
  ```js
278
296
  const fs = require("fs");
279
297
  const login = require("fca-unofficial");
280
298
 
281
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
282
- if(err) return console.error(err);
299
+ login(
300
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
301
+ (err, api) => {
302
+ if (err) return console.error(err);
283
303
 
284
- api.changeGroupImage(fs.createReadStream("./avatar.png"), "000000000000000", (err) => {
285
- if(err) return console.error(err);
286
- });
287
- });
304
+ api.changeGroupImage(
305
+ fs.createReadStream("./avatar.png"),
306
+ "000000000000000",
307
+ err => {
308
+ if (err) return console.error(err);
309
+ }
310
+ );
311
+ }
312
+ );
288
313
  ```
289
314
 
290
- ---------------------------------------
315
+ ---
291
316
 
292
317
  <a name="changeNickname"></a>
318
+
293
319
  ### api.changeNickname(nickname, threadID, participantID[, callback])
294
320
 
295
321
  Will change the thread user nickname to the one provided.
296
322
 
297
- __Arguments__
298
- * `nickname`: String containing a nickname. Leave empty to reset nickname.
299
- * `threadID`: String representing the ID of the thread.
300
- * `participantID`: String representing the ID of the user.
301
- * `callback(err)`: An optional callback called when the change is done (either with an error or null).
323
+ **Arguments**
302
324
 
303
- __Example__
325
+ - `nickname`: String containing a nickname. Leave empty to reset nickname.
326
+ - `threadID`: String representing the ID of the thread.
327
+ - `participantID`: String representing the ID of the user.
328
+ - `callback(err)`: An optional callback called when the change is done (either with an error or null).
329
+
330
+ **Example**
304
331
 
305
332
  ```js
306
333
  const fs = require("fs");
307
334
  const login = require("fca-unofficial");
308
335
 
309
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
310
- if(err) return console.error(err);
336
+ login(
337
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
338
+ (err, api) => {
339
+ if (err) return console.error(err);
311
340
 
312
- api.changeNickname("Example", "000000000000000", "000000000000000", (err) => {
313
- if(err) return console.error(err);
341
+ api.changeNickname("Example", "000000000000000", "000000000000000", err => {
342
+ if (err) return console.error(err);
314
343
  });
315
- });
344
+ }
345
+ );
316
346
  ```
317
347
 
318
- ---------------------------------------
348
+ ---
319
349
 
320
350
  <a name="changeThreadColor"></a>
351
+
321
352
  ### api.changeThreadColor(color, threadID[, callback])
322
353
 
323
354
  Will change the thread color to the given hex string color ("#0000ff"). Set it
@@ -325,334 +356,382 @@ to empty string if you want the default.
325
356
 
326
357
  Note: the color needs to start with a "#".
327
358
 
328
- __Arguments__
329
- * `color`: String representing a theme ID (a list of theme ID can be found at `api.threadColors`).
330
- * `threadID`: String representing the ID of the thread.
331
- * `callback(err)`: A callback called when the change is done (either with an error or null).
359
+ **Arguments**
332
360
 
333
- __Example__
361
+ - `color`: String representing a theme ID (a list of theme ID can be found at `api.threadColors`).
362
+ - `threadID`: String representing the ID of the thread.
363
+ - `callback(err)`: A callback called when the change is done (either with an error or null).
364
+
365
+ **Example**
334
366
 
335
367
  ```js
336
368
  const fs = require("fs");
337
369
  const login = require("fca-unofficial");
338
370
 
339
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
340
- if(err) return console.error(err);
371
+ login(
372
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
373
+ (err, api) => {
374
+ if (err) return console.error(err);
341
375
 
342
- api.changeThreadColor("#0000ff", "000000000000000", (err) => {
343
- if(err) return console.error(err);
376
+ api.changeThreadColor("#0000ff", "000000000000000", err => {
377
+ if (err) return console.error(err);
344
378
  });
345
- });
379
+ }
380
+ );
346
381
  ```
347
382
 
348
- ---------------------------------------
383
+ ---
349
384
 
350
385
  <a name="changeThreadEmoji"></a>
386
+
351
387
  ### api.changeThreadEmoji(emoji, threadID[, callback])
352
388
 
353
389
  Will change the thread emoji to the one provided.
354
390
 
355
391
  Note: The UI doesn't play nice with all emoji.
356
392
 
357
- __Arguments__
358
- * `emoji`: String containing a single emoji character.
359
- * `threadID`: String representing the ID of the thread.
360
- * `callback(err)`: A callback called when the change is done (either with an error or null).
393
+ **Arguments**
394
+
395
+ - `emoji`: String containing a single emoji character.
396
+ - `threadID`: String representing the ID of the thread.
397
+ - `callback(err)`: A callback called when the change is done (either with an error or null).
361
398
 
362
- __Example__
399
+ **Example**
363
400
 
364
401
  ```js
365
402
  const fs = require("fs");
366
403
  const login = require("fca-unofficial");
367
404
 
368
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
369
- if(err) return console.error(err);
405
+ login(
406
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
407
+ (err, api) => {
408
+ if (err) return console.error(err);
370
409
 
371
- api.changeThreadEmoji("💯", "000000000000000", (err) => {
372
- if(err) return console.error(err);
410
+ api.changeThreadEmoji("💯", "000000000000000", err => {
411
+ if (err) return console.error(err);
373
412
  });
374
- });
413
+ }
414
+ );
375
415
  ```
376
416
 
377
- ---------------------------------------
417
+ ---
378
418
 
379
419
  <a name="createNewGroup"></a>
420
+
380
421
  ### api.createNewGroup(participantIDs[, groupTitle][, callback])
381
422
 
382
423
  Create a new group chat.
383
424
 
384
- __Arguments__
385
- * `participantIDs`: An array containing participant IDs. (*Length must be >= 2*)
386
- * `groupTitle`: The title of the new group chat.
387
- * `callback(err, threadID)`: A callback called when created.
425
+ **Arguments**
426
+
427
+ - `participantIDs`: An array containing participant IDs. (_Length must be >= 2_)
428
+ - `groupTitle`: The title of the new group chat.
429
+ - `callback(err, threadID)`: A callback called when created.
388
430
 
389
- ---------------------------------------
431
+ ---
390
432
 
391
433
  <a name="createPoll"></a>
392
- ### api.createPoll(title, threadID[, options][, callback]) (*temporary deprecated because Facebook is updating this feature*)
434
+
435
+ ### api.createPoll(title, threadID[, options][, callback]) (_temporary deprecated because Facebook is updating this feature_)
393
436
 
394
437
  Creates a poll with the specified title and optional poll options, which can also be initially selected by the logged-in user.
395
438
 
396
- __Arguments__
397
- * `title`: String containing a title for the poll.
398
- * `threadID`: String representing the ID of the thread.
399
- * `options`: An optional `string : bool` dictionary to specify initial poll options and their initial states (selected/not selected), respectively.
400
- * `callback(err)`: An optional callback called when the poll is posted (either with an error or null) - can omit the `options` parameter and use this as the third parameter if desired.
439
+ **Arguments**
440
+
441
+ - `title`: String containing a title for the poll.
442
+ - `threadID`: String representing the ID of the thread.
443
+ - `options`: An optional `string : bool` dictionary to specify initial poll options and their initial states (selected/not selected), respectively.
444
+ - `callback(err)`: An optional callback called when the poll is posted (either with an error or null) - can omit the `options` parameter and use this as the third parameter if desired.
401
445
 
402
- __Example__
446
+ **Example**
403
447
 
404
448
  ```js
405
449
  const fs = require("fs");
406
450
  const login = require("fca-unofficial");
407
451
 
408
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
409
- if(err) return console.error(err);
452
+ login(
453
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
454
+ (err, api) => {
455
+ if (err) return console.error(err);
410
456
 
411
- api.createPoll("Example Poll", "000000000000000", {
457
+ api.createPoll(
458
+ "Example Poll",
459
+ "000000000000000",
460
+ {
412
461
  "Option 1": false,
413
462
  "Option 2": true
414
- }, (err) => {
415
- if(err) return console.error(err);
416
- });
417
- });
463
+ },
464
+ err => {
465
+ if (err) return console.error(err);
466
+ }
467
+ );
468
+ }
469
+ );
418
470
  ```
419
471
 
420
- ---------------------------------------
472
+ ---
421
473
 
422
474
  <a name="deleteMessage"></a>
475
+
423
476
  ### api.deleteMessage(messageOrMessages[, callback])
424
477
 
425
478
  Takes a messageID or an array of messageIDs and deletes the corresponding message.
426
479
 
427
- __Arguments__
428
- * `messageOrMessages`: A messageID string or messageID string array
429
- * `callback(err)`: A callback called when the query is done (either with an error or null).
480
+ **Arguments**
481
+
482
+ - `messageOrMessages`: A messageID string or messageID string array
483
+ - `callback(err)`: A callback called when the query is done (either with an error or null).
484
+
485
+ **Example**
430
486
 
431
- __Example__
432
487
  ```js
433
488
  const fs = require("fs");
434
489
  const login = require("fca-unofficial");
435
490
 
436
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
437
- if(err) return console.error(err);
491
+ login(
492
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
493
+ (err, api) => {
494
+ if (err) return console.error(err);
438
495
 
439
496
  api.listen((err, message) => {
440
- if(message.body) {
441
- api.sendMessage(message.body, message.threadID, (err, messageInfo) => {
442
- if(err) return console.error(err);
497
+ if (message.body) {
498
+ api.sendMessage(message.body, message.threadID, (err, messageInfo) => {
499
+ if (err) return console.error(err);
443
500
 
444
- api.deleteMessage(messageInfo.messageID);
445
- });
446
- }
501
+ api.deleteMessage(messageInfo.messageID);
502
+ });
503
+ }
447
504
  });
448
- });
505
+ }
506
+ );
449
507
  ```
450
508
 
451
- ---------------------------------------
509
+ ---
452
510
 
453
511
  <a name="deleteThread"></a>
512
+
454
513
  ### api.deleteThread(threadOrThreads[, callback])
455
514
 
456
- Given a threadID, or an array of threadIDs, will delete the threads from your account. Note that this does *not* remove the messages from Facebook's servers - anyone who hasn't deleted the thread can still view all of the messages.
515
+ Given a threadID, or an array of threadIDs, will delete the threads from your account. Note that this does _not_ remove the messages from Facebook's servers - anyone who hasn't deleted the thread can still view all of the messages.
457
516
 
458
- __Arguments__
517
+ **Arguments**
459
518
 
460
- * `threadOrThreads` - The id(s) of the threads you wish to remove from your account.
461
- * `callback(err)` - A callback called when the operation is done, maybe with an object representing an error.
519
+ - `threadOrThreads` - The id(s) of the threads you wish to remove from your account.
520
+ - `callback(err)` - A callback called when the operation is done, maybe with an object representing an error.
462
521
 
463
- __Example__
522
+ **Example**
464
523
 
465
524
  ```js
466
525
  const fs = require("fs");
467
526
  const login = require("fca-unofficial");
468
527
 
469
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
470
- if(err) return console.error(err);
528
+ login(
529
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
530
+ (err, api) => {
531
+ if (err) return console.error(err);
471
532
 
472
- api.deleteThread("000000000000000", (err) => {
473
- if(err) return console.error(err);
533
+ api.deleteThread("000000000000000", err => {
534
+ if (err) return console.error(err);
474
535
  });
475
- });
536
+ }
537
+ );
476
538
  ```
477
539
 
478
- ---------------------------------------
540
+ ---
479
541
 
480
542
  <a name="forwardAttachment"></a>
543
+
481
544
  ### api.forwardAttachment(attachmentID, userOrUsers[, callback])
482
545
 
483
546
  Forwards corresponding attachment to given userID or to every user from an array of userIDs
484
547
 
485
- __Arguments__
486
- * `attachmentID`: The ID field in the attachment object. Recorded audio cannot be forwarded.
487
- * `userOrUsers`: A userID string or usersID string array
488
- * `callback(err)`: A callback called when the query is done (either with an error or null).
548
+ **Arguments**
549
+
550
+ - `attachmentID`: The ID field in the attachment object. Recorded audio cannot be forwarded.
551
+ - `userOrUsers`: A userID string or usersID string array
552
+ - `callback(err)`: A callback called when the query is done (either with an error or null).
489
553
 
490
- ---------------------------------------
554
+ ---
491
555
 
492
556
  <a name="getAppState"></a>
557
+
493
558
  ### api.getAppState()
494
559
 
495
560
  Returns current appState which can be saved to a file or stored in a variable.
496
561
 
497
- ---------------------------------------
562
+ ---
498
563
 
499
564
  <a name="getCurrentUserID"></a>
565
+
500
566
  ### api.getCurrentUserID()
501
567
 
502
568
  Returns the currently logged-in user's Facebook user ID.
503
569
 
504
- ---------------------------------------
570
+ ---
505
571
 
506
572
  <a name="getEmojiUrl"></a>
573
+
507
574
  ### api.getEmojiUrl(c, size[, pixelRatio])
508
575
 
509
576
  Returns the URL to a Facebook Messenger-style emoji image asset.
510
577
 
511
- __note__: This function will return a URL regardless of whether the image at the URL actually exists.
578
+ **note**: This function will return a URL regardless of whether the image at the URL actually exists.
512
579
  This can happen if, for example, Messenger does not have an image asset for the requested emoji.
513
580
 
514
- __Arguments__
581
+ **Arguments**
515
582
 
516
- * `c` - The emoji character
517
- * `size` - The width and height of the emoji image; supported sizes are 32, 64, and 128
518
- * `pixelRatio` - The pixel ratio of the emoji image; supported ratios are '1.0' and '1.5' (default is '1.0')
583
+ - `c` - The emoji character
584
+ - `size` - The width and height of the emoji image; supported sizes are 32, 64, and 128
585
+ - `pixelRatio` - The pixel ratio of the emoji image; supported ratios are '1.0' and '1.5' (default is '1.0')
519
586
 
520
- __Example__
587
+ **Example**
521
588
 
522
589
  ```js
523
590
  const fs = require("fs");
524
591
  const login = require("fca-unofficial");
525
592
 
526
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
527
- if(err) return console.error(err);
593
+ login(
594
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
595
+ (err, api) => {
596
+ if (err) return console.error(err);
528
597
 
529
598
  // Prints https://static.xx.fbcdn.net/images/emoji.php/v8/z9c/1.0/128/1f40d.png
530
- console.log('Snake emoji, 128px (128x128 with pixel ratio of 1.0');
531
- console.log(api.getEmojiUrl('\ud83d\udc0d', 128));
599
+ console.log("Snake emoji, 128px (128x128 with pixel ratio of 1.0");
600
+ console.log(api.getEmojiUrl("\ud83d\udc0d", 128));
532
601
 
533
602
  // Prints https://static.xx.fbcdn.net/images/emoji.php/v8/ze1/1.5/128/1f40d.png
534
- console.log('Snake emoji, 192px (128x128 with pixel ratio of 1.5');
535
- console.log(api.getEmojiUrl('\ud83d\udc0d', 128, '1.5'));
536
- });
603
+ console.log("Snake emoji, 192px (128x128 with pixel ratio of 1.5");
604
+ console.log(api.getEmojiUrl("\ud83d\udc0d", 128, "1.5"));
605
+ }
606
+ );
537
607
  ```
538
608
 
539
- ---------------------------------------
609
+ ---
540
610
 
541
611
  <a name="getFriendsList"></a>
612
+
542
613
  ### api.getFriendsList(callback)
543
614
 
544
615
  Returns an array of objects with some information about your friends.
545
616
 
546
- __Arguments__
617
+ **Arguments**
547
618
 
548
- * `callback(err, arr)` - A callback called when the query is done (either with an error or with an confirmation object). `arr` is an array of objects with the following fields: `alternateName`, `firstName`, `gender`, `userID`, `isFriend`, `fullName`, `profilePicture`, `type`, `profileUrl`, `vanity`, `isBirthday`.
619
+ - `callback(err, arr)` - A callback called when the query is done (either with an error or with an confirmation object). `arr` is an array of objects with the following fields: `alternateName`, `firstName`, `gender`, `userID`, `isFriend`, `fullName`, `profilePicture`, `type`, `profileUrl`, `vanity`, `isBirthday`.
549
620
 
550
- __Example__
621
+ **Example**
551
622
 
552
623
  ```js
553
624
  const fs = require("fs");
554
625
  const login = require("fca-unofficial");
555
626
 
556
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
557
- if(err) return console.error(err);
627
+ login(
628
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
629
+ (err, api) => {
630
+ if (err) return console.error(err);
558
631
 
559
632
  api.getFriendsList((err, data) => {
560
- if(err) return console.error(err);
633
+ if (err) return console.error(err);
561
634
 
562
- console.log(data.length);
635
+ console.log(data.length);
563
636
  });
564
- });
637
+ }
638
+ );
565
639
  ```
566
640
 
567
- ---------------------------------------
641
+ ---
568
642
 
569
643
  <a name="getThreadHistory"></a>
644
+
570
645
  ### api.getThreadHistory(threadID, amount, timestamp, callback)
571
646
 
572
647
  Takes a threadID, number of messages, a timestamp, and a callback.
573
648
 
574
- __note__: if you're getting a 500 error, it's possible that you're requesting too many messages. Try reducing that number and see if that works.
649
+ **note**: if you're getting a 500 error, it's possible that you're requesting too many messages. Try reducing that number and see if that works.
650
+
651
+ **Arguments**
575
652
 
576
- __Arguments__
577
- * `threadID`: A threadID corresponding to the target chat
578
- * `amount`: The amount of messages to *request*
579
- * `timestamp`: Used to described the time of the most recent message to load. If timestamp is `undefined`, facebook will load the most recent messages.
580
- * `callback(error, history)`: If error is null, history will contain an array of message objects.
653
+ - `threadID`: A threadID corresponding to the target chat
654
+ - `amount`: The amount of messages to _request_
655
+ - `timestamp`: Used to described the time of the most recent message to load. If timestamp is `undefined`, facebook will load the most recent messages.
656
+ - `callback(error, history)`: If error is null, history will contain an array of message objects.
581
657
 
582
- __Example__
658
+ **Example**
583
659
 
584
660
  To load 50 messages at a time, we can use `undefined` as the timestamp to retrieve the most recent messages and use the timestamp of the earliest message to load the next 50.
585
661
 
586
662
  ```js
587
663
  var timestamp = undefined;
588
664
 
589
- function loadNextThreadHistory(api){
590
- api.getThreadHistory(threadID, 50, timestamp, (err, history) => {
591
- if(err) return console.error(err);
665
+ function loadNextThreadHistory(api) {
666
+ api.getThreadHistory(threadID, 50, timestamp, (err, history) => {
667
+ if (err) return console.error(err);
592
668
 
593
- /*
669
+ /*
594
670
  Since the timestamp is from a previous loaded message,
595
671
  that message will be included in this history so we can discard it unless it is the first load.
596
672
  */
597
- if(timestamp != undefined) history.pop();
673
+ if (timestamp != undefined) history.pop();
598
674
 
599
- /*
675
+ /*
600
676
  Handle message history
601
677
  */
602
678
 
603
- timestamp = history[0].timestamp;
604
- });
679
+ timestamp = history[0].timestamp;
680
+ });
605
681
  }
606
682
  ```
607
683
 
608
- ---------------------------------------
684
+ ---
609
685
 
610
686
  <a name="getThreadInfo"></a>
687
+
611
688
  ### api.getThreadInfo(threadID[, callback])
612
689
 
613
- Takes a threadID and a callback. Works for both single-user and group threads.
614
-
615
- __Arguments__
616
- * `threadID`: A threadID corresponding to the target thread.
617
- * `callback(err, info)`: If `err` is `null`, `info` will contain the following properties:
618
-
619
- | Key | Description |
620
- |----------|:-------------:|
621
- | threadID | ID of the thread |
622
- | participantIDs | Array of user IDs in the thread |
623
- | threadName | Name of the thread. Usually the name of the user. In group chats, this will be empty if the name of the group chat is unset. |
624
- | userInfo | An array contains info of members, which has the same structure as [`getUserInfo`](#getUserInfo), but add a key `id`, contain ID of member currently at. |
625
- | nicknames | Map of nicknames for members of the thread. If there are no nicknames set, this will be null. |
626
- | unreadCount | Number of unread messages |
627
- | messageCount | Number of messages |
628
- | imageSrc | URL to the group chat photo. Null if unset or a 1-1 thread. |
629
- | timestamp | Timestamp of last activity |
630
- | muteUntil | Timestamp at which the thread will no longer be muted. The timestamp will be -1 if the thread is muted indefinitely or null if the thread is not muted. |
631
- | isGroup | boolean, true if this thread is a group thread (more than 2 participants). |
632
- | isSubscribed | |
633
- | folder | The folder that the thread is in. Can be one of: <ul><li>'inbox'</li><li>'archive'</li></ul> |
634
- | isArchived | True if the thread is archived, false if not |
635
- | cannotReplyReason | If you cannot reply to this thread, this will be a string stating why. Otherwise it will be null. |
636
- | lastReadTimestamp | Timestamp of the last message that is marked as 'read' by the current user. |
637
- | emoji | Object with key 'emoji' whose value is the emoji unicode character. Null if unset. |
638
- | color | String form of the custom color in hexadecimal form. |
639
- | adminIDs | Array of user IDs of the admins of the thread. Empty array if unset. |
640
- | approvalMode | `true` or `false`, used to check if this group requires admin approval to add users |
641
- | approvalQueue | Array of object that has the following keys: <ul><li>`inviterID`: ID of the user invited the person to the group</li><li>`requesterID`: ID of the person waiting to be approved</li><li>`timestamp`: Request timestamp</li></ul> |
642
-
643
- ---------------------------------------
690
+ Takes a threadID and a callback. Works for both single-user and group threads.
691
+
692
+ **Arguments**
693
+
694
+ - `threadID`: A threadID corresponding to the target thread.
695
+ - `callback(err, info)`: If `err` is `null`, `info` will contain the following properties:
696
+
697
+ | Key | Description |
698
+ | ----------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
699
+ | threadID | ID of the thread |
700
+ | participantIDs | Array of user IDs in the thread |
701
+ | threadName | Name of the thread. Usually the name of the user. In group chats, this will be empty if the name of the group chat is unset. |
702
+ | userInfo | An array contains info of members, which has the same structure as [`getUserInfo`](#getUserInfo), but add a key `id`, contain ID of member currently at. |
703
+ | nicknames | Map of nicknames for members of the thread. If there are no nicknames set, this will be null. |
704
+ | unreadCount | Number of unread messages |
705
+ | messageCount | Number of messages |
706
+ | imageSrc | URL to the group chat photo. Null if unset or a 1-1 thread. |
707
+ | timestamp | Timestamp of last activity |
708
+ | muteUntil | Timestamp at which the thread will no longer be muted. The timestamp will be -1 if the thread is muted indefinitely or null if the thread is not muted. |
709
+ | isGroup | boolean, true if this thread is a group thread (more than 2 participants). |
710
+ | isSubscribed | |
711
+ | folder | The folder that the thread is in. Can be one of: <ul><li>'inbox'</li><li>'archive'</li></ul> |
712
+ | isArchived | True if the thread is archived, false if not |
713
+ | cannotReplyReason | If you cannot reply to this thread, this will be a string stating why. Otherwise it will be null. |
714
+ | lastReadTimestamp | Timestamp of the last message that is marked as 'read' by the current user. |
715
+ | emoji | Object with key 'emoji' whose value is the emoji unicode character. Null if unset. |
716
+ | color | String form of the custom color in hexadecimal form. |
717
+ | adminIDs | Array of user IDs of the admins of the thread. Empty array if unset. |
718
+ | approvalMode | `true` or `false`, used to check if this group requires admin approval to add users |
719
+ | approvalQueue | Array of object that has the following keys: <ul><li>`inviterID`: ID of the user invited the person to the group</li><li>`requesterID`: ID of the person waiting to be approved</li><li>`timestamp`: Request timestamp</li></ul> |
720
+
721
+ ---
644
722
 
645
723
  <a name="getThreadList"></a>
724
+
646
725
  ### api.getThreadList(limit, timestamp, tags, callback)
647
726
 
648
727
  Returns information about the user's threads.
649
728
 
650
- __Arguments__
729
+ **Arguments**
651
730
 
652
- * `limit`: Limit the number of threads to fetch.
653
- * `timestamp`: Request threads *before* this date. `null` means *now*
654
- * `tags`: An array describing which folder to fetch. It should be one of these:
655
- - `["INBOX"]` *(same as `[]`)*
731
+ - `limit`: Limit the number of threads to fetch.
732
+ - `timestamp`: Request threads _before_ this date. `null` means _now_
733
+ - `tags`: An array describing which folder to fetch. It should be one of these:
734
+ - `["INBOX"]` _(same as `[]`)_
656
735
  - `["ARCHIVED"]`
657
736
  - `["PENDING"]`
658
737
  - `["OTHER"]`
@@ -661,51 +740,52 @@ __Arguments__
661
740
  - `["PENDING", "unread"]`
662
741
  - `["OTHER", "unread"]`
663
742
 
664
- *if you find something new, let us know*
665
-
666
- * `callback(err, list)`: Callback called when the query is done (either with an error or with a proper result). `list` is an *array* with objects with the following properties:
667
-
668
- __Thread list__
669
-
670
- | Key | Description |
671
- |----------------------|-------------------------------------------------------------|
672
- | threadID | ID of the thread |
673
- | name | The name of the thread |
674
- | unreadCount | Amount of unread messages in thread |
675
- | messageCount | Amount of messages in thread |
676
- | imageSrc | Link to the thread's image or `null` |
677
- | emoji | The default emoji in thread (classic like is `null`) |
678
- | color | Thread's message color in `RRGGBB` (default blue is `null`) |
679
- | nicknames | An array of `{"userid": "1234", "nickname": "John Doe"}` |
680
- | muteUntil | Timestamp until the mute expires or `null` |
681
- | participants | An array of participants. See below |
682
- | adminIDs | An array of thread admin IDs |
683
- | folder | `INBOX`, `ARCHIVED`, `PENDING` or `OTHER` |
684
- | isGroup | `true` or `false` |
685
- | customizationEnabled | `false` in one-to-one conversations with `Page` or `ReducedMessagingActor` |
686
- | participantAddMode | currently `"ADD"` for groups and `null` otherwise |
687
- | reactionsMuteMode | `REACTIONS_NOT_MUTED` or `REACTIONS_MUTED` |
688
- | mentionsMuteMode | `MENTIONS_NOT_MUTED` or `MENTIONS_MUTED` |
689
- | isArchived | `true` or `false` |
690
- | isSubscribed | `true` or `false` |
691
- | timestamp | timestamp in miliseconds |
692
- | snippet | Snippet's text message |
693
- | snippetAttachments | Attachments in snippet |
694
- | snippetSender | ID of snippet sender |
695
- | lastMessageTimestamp | timestamp in milliseconds |
696
- | lastReadTimestamp | timestamp in milliseconds or `null` |
697
- | cannotReplyReason | `null`, `"RECIPIENTS_NOT_LOADABLE"` or `"BLOCKED"` |
743
+ _if you find something new, let us know_
744
+
745
+ - `callback(err, list)`: Callback called when the query is done (either with an error or with a proper result). `list` is an _array_ with objects with the following properties:
746
+
747
+ **Thread list**
748
+
749
+ | Key | Description |
750
+ | -------------------- | ----------------------------------------------------------------------------------- |
751
+ | threadID | ID of the thread |
752
+ | name | The name of the thread |
753
+ | unreadCount | Amount of unread messages in thread |
754
+ | messageCount | Amount of messages in thread |
755
+ | imageSrc | Link to the thread's image or `null` |
756
+ | emoji | The default emoji in thread (classic like is `null`) |
757
+ | color | Thread's message color in `RRGGBB` (default blue is `null`) |
758
+ | nicknames | An array of `{"userid": "1234", "nickname": "John Doe"}` |
759
+ | muteUntil | Timestamp until the mute expires or `null` |
760
+ | participants | An array of participants. See below |
761
+ | adminIDs | An array of thread admin IDs |
762
+ | folder | `INBOX`, `ARCHIVED`, `PENDING` or `OTHER` |
763
+ | isGroup | `true` or `false` |
764
+ | customizationEnabled | `false` in one-to-one conversations with `Page` or `ReducedMessagingActor` |
765
+ | participantAddMode | currently `"ADD"` for groups and `null` otherwise |
766
+ | reactionsMuteMode | `REACTIONS_NOT_MUTED` or `REACTIONS_MUTED` |
767
+ | mentionsMuteMode | `MENTIONS_NOT_MUTED` or `MENTIONS_MUTED` |
768
+ | isArchived | `true` or `false` |
769
+ | isSubscribed | `true` or `false` |
770
+ | timestamp | timestamp in miliseconds |
771
+ | snippet | Snippet's text message |
772
+ | snippetAttachments | Attachments in snippet |
773
+ | snippetSender | ID of snippet sender |
774
+ | lastMessageTimestamp | timestamp in milliseconds |
775
+ | lastReadTimestamp | timestamp in milliseconds or `null` |
776
+ | cannotReplyReason | `null`, `"RECIPIENTS_NOT_LOADABLE"` or `"BLOCKED"` |
698
777
  | approvalMode | `true` or `false`, used to check if this group requires admin approval to add users |
699
778
 
700
- __`participants` format__
779
+ **`participants` format**
701
780
 
702
781
  `accountType` is one of the following:
782
+
703
783
  - `"User"`
704
784
  - `"Page"`
705
785
  - `"UnavailableMessagingActor"`
706
786
  - `"ReducedMessagingActor"`
707
787
 
708
- (*there might be more*)
788
+ (_there might be more_)
709
789
 
710
790
  <table>
711
791
  <tr>
@@ -878,98 +958,106 @@ __`participants` format__
878
958
  </tr>
879
959
  </table>
880
960
 
961
+ In a case that some account type is not supported, we return just this _(but you can't rely on it)_ and log a warning to the console:
881
962
 
882
- In a case that some account type is not supported, we return just this *(but you can't rely on it)* and log a warning to the console:
963
+ | Key | Description |
964
+ | ----------- | --------------------- |
965
+ | accountType | type, can be anything |
966
+ | userID | ID of the account |
967
+ | name | Name of the account |
883
968
 
884
- | Key | Description |
885
- |--------------|-------------------------|
886
- | accountType | type, can be anything |
887
- | userID | ID of the account |
888
- | name | Name of the account |
889
-
890
-
891
- ---------------------------------------
969
+ ---
892
970
 
893
971
  <a name="getThreadPictures"></a>
972
+
894
973
  ### api.getThreadPictures(threadID, offset, limit, callback)
895
974
 
896
975
  Returns pictures sent in the thread.
897
976
 
898
- __Arguments__
977
+ **Arguments**
899
978
 
900
- * `threadID`: A threadID corresponding to the target chat
901
- * `offset`: Start index of picture to retrieve, where 0 is the most recent picture
902
- * `limit`: Number of pictures to get, incrementing from the offset index
903
- * `callback(err, arr)`: A callback called when the query is done (either with an error or with an confirmation object). `arr` is an array of objects with `uri`, `width`, and `height`.
979
+ - `threadID`: A threadID corresponding to the target chat
980
+ - `offset`: Start index of picture to retrieve, where 0 is the most recent picture
981
+ - `limit`: Number of pictures to get, incrementing from the offset index
982
+ - `callback(err, arr)`: A callback called when the query is done (either with an error or with an confirmation object). `arr` is an array of objects with `uri`, `width`, and `height`.
904
983
 
905
- ---------------------------------------
984
+ ---
906
985
 
907
986
  <a name="getUserID"></a>
987
+
908
988
  ### api.getUserID(name, callback)
909
989
 
910
990
  Given the full name or vanity name of a Facebook user, event, page, group or app, the call will perform a Facebook Graph search and return all corresponding IDs (order determined by Facebook).
911
991
 
912
- __Arguments__
992
+ **Arguments**
913
993
 
914
- * `name` - A string being the name of the item you're looking for.
915
- * `callback(err, obj)` - A callback called when the search is done (either with an error or with the resulting object). `obj` is an array which contains all of the items that facebook graph search found, ordered by "importance". Each item in the array has the following properties: `userID`,`photoUrl`,`indexRank`, `name`, `isVerified`, `profileUrl`, `category`, `score`, `type` (type is generally user, group, page, event or app).
994
+ - `name` - A string being the name of the item you're looking for.
995
+ - `callback(err, obj)` - A callback called when the search is done (either with an error or with the resulting object). `obj` is an array which contains all of the items that facebook graph search found, ordered by "importance". Each item in the array has the following properties: `userID`,`photoUrl`,`indexRank`, `name`, `isVerified`, `profileUrl`, `category`, `score`, `type` (type is generally user, group, page, event or app).
916
996
 
917
- __Example__
997
+ **Example**
918
998
 
919
999
  ```js
920
1000
  const fs = require("fs");
921
1001
  const login = require("fca-unofficial");
922
1002
 
923
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
924
- if(err) return console.error(err);
1003
+ login(
1004
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
1005
+ (err, api) => {
1006
+ if (err) return console.error(err);
925
1007
 
926
1008
  api.getUserID("Marc Zuckerbot", (err, data) => {
927
- if(err) return console.error(err);
1009
+ if (err) return console.error(err);
928
1010
 
929
- // Send the message to the best match (best by Facebook's criteria)
930
- var msg = "Hello!"
931
- var threadID = data[0].userID;
932
- api.sendMessage(msg, threadID);
1011
+ // Send the message to the best match (best by Facebook's criteria)
1012
+ var msg = "Hello!";
1013
+ var threadID = data[0].userID;
1014
+ api.sendMessage(msg, threadID);
933
1015
  });
934
- });
1016
+ }
1017
+ );
935
1018
  ```
936
1019
 
937
- ---------------------------------------
1020
+ ---
938
1021
 
939
1022
  <a name="getUserInfo"></a>
1023
+
940
1024
  ### api.getUserInfo(ids, callback)
941
1025
 
942
1026
  Will get some information about the given users.
943
1027
 
944
- __Arguments__
1028
+ **Arguments**
945
1029
 
946
- * `ids` - Either a string/number for one ID or an array of strings/numbers for a batched query.
947
- * `callback(err, obj)` - A callback called when the query is done (either with an error or with an confirmation object). `obj` is a mapping from userId to another object containing the following properties: `name`, `firstName`, `vanity` (user's chosen facebook handle, if any), `thumbSrc`, `profileUrl`, `gender`, `type` (type is generally user, group, page, event or app), `isFriend`, `isBirthday`, `searchTokens`, `alternateName`.
1030
+ - `ids` - Either a string/number for one ID or an array of strings/numbers for a batched query.
1031
+ - `callback(err, obj)` - A callback called when the query is done (either with an error or with an confirmation object). `obj` is a mapping from userId to another object containing the following properties: `name`, `firstName`, `vanity` (user's chosen facebook handle, if any), `thumbSrc`, `profileUrl`, `gender`, `type` (type is generally user, group, page, event or app), `isFriend`, `isBirthday`, `searchTokens`, `alternateName`.
948
1032
 
949
- __Example__
1033
+ **Example**
950
1034
 
951
1035
  ```js
952
1036
  const fs = require("fs");
953
1037
  const login = require("fca-unofficial");
954
1038
 
955
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
956
- if(err) return console.error(err);
1039
+ login(
1040
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
1041
+ (err, api) => {
1042
+ if (err) return console.error(err);
957
1043
 
958
1044
  api.getUserInfo([1, 2, 3, 4], (err, ret) => {
959
- if(err) return console.error(err);
1045
+ if (err) return console.error(err);
960
1046
 
961
- for(var prop in ret) {
962
- if(ret.hasOwnProperty(prop) && ret[prop].isBirthday) {
963
- api.sendMessage("Happy birthday :)", prop);
964
- }
1047
+ for (var prop in ret) {
1048
+ if (ret.hasOwnProperty(prop) && ret[prop].isBirthday) {
1049
+ api.sendMessage("Happy birthday :)", prop);
965
1050
  }
1051
+ }
966
1052
  });
967
- });
1053
+ }
1054
+ );
968
1055
  ```
969
1056
 
970
- ---------------------------------------
1057
+ ---
971
1058
 
972
1059
  <a name="threadColors"></a>
1060
+
973
1061
  ### api.threadColors
974
1062
 
975
1063
  A dictionary mapping names of all currently valid thread themes to their theme ID that are accepted by [`api.changeThreadColor`](#changeThreadColor). These themes, listed below, are the ones present in the palette UI used for selecting thread themes on the Messenger client.
@@ -992,37 +1080,41 @@ A dictionary mapping names of all currently valid thread themes to their theme I
992
1080
  - Candy: `205488546921017`
993
1081
  - ~~StarWars: `809305022860427`~~ (Facebook removed it.)
994
1082
 
995
- ---------------------------------------
1083
+ ---
996
1084
 
997
1085
  <a name="handleMessageRequest"></a>
1086
+
998
1087
  ### api.handleMessageRequest(threadID, accept[, callback])
999
1088
 
1000
1089
  Accept or ignore message request(s) with thread id `threadID`.
1001
1090
 
1002
- __Arguments__
1091
+ **Arguments**
1003
1092
 
1004
- * `threadID`: A threadID or array of threadIDs corresponding to the target thread(s). Can be numbers or strings.
1005
- * `accept`: Boolean indicating the new status to assign to the message request(s); true for inbox, false to others.
1006
- * `callback(err)`: A callback called when the query is done (with an error or with null).
1093
+ - `threadID`: A threadID or array of threadIDs corresponding to the target thread(s). Can be numbers or strings.
1094
+ - `accept`: Boolean indicating the new status to assign to the message request(s); true for inbox, false to others.
1095
+ - `callback(err)`: A callback called when the query is done (with an error or with null).
1007
1096
 
1008
- ---------------------------------------
1097
+ ---
1009
1098
 
1010
1099
  <a name="listen"></a>
1100
+
1011
1101
  ### api.listen([callback])
1102
+
1012
1103
  <a name="listenMqtt"></a>
1104
+
1013
1105
  ### api.listenMqtt([callback])
1014
1106
 
1015
1107
  Will call `callback` when a new message is received on this account.
1016
- By default this won't receive events (joining/leaving a chat, title change etc...) but it can be activated with `api.setOptions({listenEvents: true})`. This will by default ignore messages sent by the current account, you can enable listening to your own messages with `api.setOptions({selfListen: true})`. This returns an `EventEmitter` that contains function `stopListening` that will stop the `listen` loop and is guaranteed to prevent any future calls to the callback given to `listen`. An immediate call to `stopListening` when an error occurs will prevent the listen function to continue.
1108
+ By default this won't receive events (joining/leaving a chat, title change etc...) but it can be activated with `api.setOptions({listenEvents: true})`. This will by default ignore messages sent by the current account, you can enable listening to your own messages with `api.setOptions({selfListen: true})`. This returns an `EventEmitter` that contains function `stopListening` that will stop the `listen` loop and is guaranteed to prevent any future calls to the callback given to `listen`. An immediate call to `stopListening` when an error occurs will prevent the listen function to continue.
1017
1109
 
1018
1110
  If `callback` is not defined, or isn't a `Function`, you can listen to messages with event `message` and `error` from `EventEmitter` returned by this function.
1019
1111
 
1020
- __Arguments__
1112
+ **Arguments**
1021
1113
 
1022
1114
  - `callback(error, message)`: A callback called every time the logged-in account receives a new message.
1023
1115
 
1024
1116
  <a name="message"></a>
1025
- __Message__
1117
+ **Message**
1026
1118
 
1027
1119
  The message object will contain different fields based on its type (as determined by its `type` field). By default, the only type that will be listened for is `message`. If enabled through [setOptions](#setOptions), the message object may alternatively represent an event e.g. a read receipt. The available event types are as follows:
1028
1120
 
@@ -1298,22 +1390,22 @@ The message object will contain different fields based on its type (as determine
1298
1390
  </tr>
1299
1391
  </table>
1300
1392
 
1301
- __Attachments__
1393
+ **Attachments**
1302
1394
 
1303
1395
  Similar to how messages can vary based on their `type`, so too can the `attachments` within `"message"` events. Each attachment will consist of an object of one of the following types:
1304
1396
 
1305
- | Attachment Type | Fields |
1306
- | --------------- | ------ |
1307
- | `"sticker"` | `ID`, `url`, `packID`, `spriteUrl`, `spriteUrl2x`, `width`, `height`, `caption`, `description`, `frameCount`, `frameRate`, `framesPerRow`, `framesPerCol` |
1308
- | `"file"` | `ID`, `filename`, `url`, `isMalicious`, `contentType` |
1309
- | `"photo"` | `ID`, `filename`, `thumbnailUrl`, `previewUrl`, `previewWidth`, `previewHeight`, `largePreviewUrl`, `largePreviewWidth`, `largePreviewHeight` |
1310
- | `"animated_image"` | `ID`, `filename`, `previewUrl`, `previewWidth`, `previewHeight`, `url`, `width`, `height` |
1311
- | `"video"` | `ID`, `filename`, `previewUrl`, `previewWidth`, `previewHeight`, `url`, `width`, `height`, `duration`, `videoType` |
1312
- | `"audio"` | `ID`, `filename`, `audioType`, `duration`, `url`, `isVoiceMail` |
1313
- | `"location"` | `ID`, `latitude`, `longitude`, `image`, `width`, `height`, `url`, `address` |
1314
- | `"share"` | `ID`, `url`, `title`, `description`, `source`, `image`, `width`, `height`, `playable`, `duration`, `playableUrl`, `subattachments`, `properties` |
1397
+ | Attachment Type | Fields |
1398
+ | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
1399
+ | `"sticker"` | `ID`, `url`, `packID`, `spriteUrl`, `spriteUrl2x`, `width`, `height`, `caption`, `description`, `frameCount`, `frameRate`, `framesPerRow`, `framesPerCol` |
1400
+ | `"file"` | `ID`, `filename`, `url`, `isMalicious`, `contentType` |
1401
+ | `"photo"` | `ID`, `filename`, `thumbnailUrl`, `previewUrl`, `previewWidth`, `previewHeight`, `largePreviewUrl`, `largePreviewWidth`, `largePreviewHeight` |
1402
+ | `"animated_image"` | `ID`, `filename`, `previewUrl`, `previewWidth`, `previewHeight`, `url`, `width`, `height` |
1403
+ | `"video"` | `ID`, `filename`, `previewUrl`, `previewWidth`, `previewHeight`, `url`, `width`, `height`, `duration`, `videoType` |
1404
+ | `"audio"` | `ID`, `filename`, `audioType`, `duration`, `url`, `isVoiceMail` |
1405
+ | `"location"` | `ID`, `latitude`, `longitude`, `image`, `width`, `height`, `url`, `address` |
1406
+ | `"share"` | `ID`, `url`, `title`, `description`, `source`, `image`, `width`, `height`, `playable`, `duration`, `playableUrl`, `subattachments`, `properties` |
1315
1407
 
1316
- __Example__
1408
+ **Example**
1317
1409
 
1318
1410
  ```js
1319
1411
  const fs = require("fs");
@@ -1322,184 +1414,205 @@ const login = require("fca-unofficial");
1322
1414
  // Simple echo bot. He'll repeat anything that you say.
1323
1415
  // Will stop when you say '/stop'
1324
1416
 
1325
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
1326
- if(err) return console.error(err);
1417
+ login(
1418
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
1419
+ (err, api) => {
1420
+ if (err) return console.error(err);
1327
1421
 
1328
- api.setOptions({listenEvents: true});
1422
+ api.setOptions({ listenEvents: true });
1329
1423
 
1330
1424
  var listenEmitter = api.listen((err, event) => {
1331
- if(err) return console.error(err);
1332
-
1333
- switch (event.type) {
1334
- case "message":
1335
- if(event.body === '/stop') {
1336
- api.sendMessage("Goodbye...", event.threadID);
1337
- return listenEmitter.stopListening();
1338
- }
1339
- api.markAsRead(event.threadID, (err) => {
1340
- if(err) console.log(err);
1341
- });
1342
- api.sendMessage("TEST BOT: " + event.body, event.threadID);
1343
- break;
1344
- case "event":
1345
- console.log(event);
1346
- break;
1347
- }
1425
+ if (err) return console.error(err);
1426
+
1427
+ switch (event.type) {
1428
+ case "message":
1429
+ if (event.body === "/stop") {
1430
+ api.sendMessage("Goodbye...", event.threadID);
1431
+ return listenEmitter.stopListening();
1432
+ }
1433
+ api.markAsRead(event.threadID, err => {
1434
+ if (err) console.log(err);
1435
+ });
1436
+ api.sendMessage("TEST BOT: " + event.body, event.threadID);
1437
+ break;
1438
+ case "event":
1439
+ console.log(event);
1440
+ break;
1441
+ }
1348
1442
  });
1349
- });
1443
+ }
1444
+ );
1350
1445
  ```
1351
1446
 
1352
- ---------------------------------------
1447
+ ---
1353
1448
 
1354
1449
  <a name="logout"></a>
1450
+
1355
1451
  ### api.logout([callback])
1356
1452
 
1357
1453
  Logs out the current user.
1358
1454
 
1359
- __Arguments__
1455
+ **Arguments**
1360
1456
 
1361
- * `callback(err)`: A callback called when the query is done (either with an error or with null).
1457
+ - `callback(err)`: A callback called when the query is done (either with an error or with null).
1362
1458
 
1363
- ---------------------------------------
1459
+ ---
1364
1460
 
1365
1461
  <a name="markAsDelivered"></a>
1462
+
1366
1463
  ### api.markAsDelivered(threadID, messageID[, callback]])
1367
1464
 
1368
1465
  Given a threadID and a messageID will mark that message as delivered. If a message is marked as delivered that tells facebook servers that it was recieved.
1369
1466
 
1370
1467
  You can also mark new messages as delivered automatically. This is enabled by default. See [api.setOptions](#setOptions).
1371
1468
 
1372
- __Arguments__
1469
+ **Arguments**
1373
1470
 
1374
- * `threadID` - The id of the thread in which you want to mark the message as delivered.
1375
- * `messageID` - The id of the message want to mark as delivered.
1376
- * `callback(err)` - A callback called when the operation is done maybe with an object representing an error.
1471
+ - `threadID` - The id of the thread in which you want to mark the message as delivered.
1472
+ - `messageID` - The id of the message want to mark as delivered.
1473
+ - `callback(err)` - A callback called when the operation is done maybe with an object representing an error.
1377
1474
 
1378
- __Example__
1475
+ **Example**
1379
1476
 
1380
1477
  ```js
1381
1478
  const fs = require("fs");
1382
1479
  const login = require("facebook-chat-api");
1383
1480
 
1384
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
1385
- if(err) return console.error(err);
1481
+ login(
1482
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
1483
+ (err, api) => {
1484
+ if (err) return console.error(err);
1386
1485
 
1387
1486
  api.listen((err, message) => {
1388
- if(err) return console.error(err);
1487
+ if (err) return console.error(err);
1389
1488
 
1390
- // Marks messages as delivered immediately after they're received
1391
- api.markAsDelivered(message.threadID, message.messageID);
1489
+ // Marks messages as delivered immediately after they're received
1490
+ api.markAsDelivered(message.threadID, message.messageID);
1392
1491
  });
1393
- });
1492
+ }
1493
+ );
1394
1494
  ```
1395
1495
 
1396
- ---------------------------------------
1496
+ ---
1397
1497
 
1398
1498
  <a name="markAsRead"></a>
1499
+
1399
1500
  ### api.markAsRead(threadID, [read[, callback]])
1400
1501
 
1401
1502
  Given a threadID will mark all the unread messages in a thread as read. Facebook will take a couple of seconds to show that you've read the messages.
1402
1503
 
1403
- You can also mark new messages as read automatically. See [api.setOptions](#setOptions). But be careful, this will make your account getting banned, especially when receiving *HUGE* amount of messages.
1504
+ You can also mark new messages as read automatically. See [api.setOptions](#setOptions). But be careful, this will make your account getting banned, especially when receiving _HUGE_ amount of messages.
1404
1505
 
1405
- __Arguments__
1506
+ **Arguments**
1406
1507
 
1407
- * `threadID` - The id of the thread in which you want to mark the messages as read.
1408
- * `read` - An optional boolean where `true` means to mark the message as being "read" and `false` means to mark the message as being "unread".
1409
- * `callback(err)` - A callback called when the operation is done maybe with an object representing an error.
1508
+ - `threadID` - The id of the thread in which you want to mark the messages as read.
1509
+ - `read` - An optional boolean where `true` means to mark the message as being "read" and `false` means to mark the message as being "unread".
1510
+ - `callback(err)` - A callback called when the operation is done maybe with an object representing an error.
1410
1511
 
1411
- __Example__
1512
+ **Example**
1412
1513
 
1413
1514
  ```js
1414
1515
  const fs = require("fs");
1415
1516
  const login = require("fca-unofficial");
1416
1517
 
1417
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
1418
- if(err) return console.error(err);
1518
+ login(
1519
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
1520
+ (err, api) => {
1521
+ if (err) return console.error(err);
1419
1522
 
1420
1523
  api.listen((err, message) => {
1421
- if(err) return console.error(err);
1524
+ if (err) return console.error(err);
1422
1525
 
1423
- // Marks messages as read immediately after they're received
1424
- api.markAsRead(message.threadID);
1526
+ // Marks messages as read immediately after they're received
1527
+ api.markAsRead(message.threadID);
1425
1528
  });
1426
- });
1529
+ }
1530
+ );
1427
1531
  ```
1428
1532
 
1429
- ---------------------------------------
1533
+ ---
1430
1534
 
1431
1535
  <a name="markAsReadAll"></a>
1536
+
1432
1537
  ### api.markAsReadAll([callback])
1433
1538
 
1434
1539
  This function will mark all of messages in your inbox readed.
1435
1540
 
1436
- ---------------------------------------
1541
+ ---
1437
1542
 
1438
1543
  <a name="markAsSeen"></a>
1544
+
1439
1545
  ### api.markAsSeen([seenTimestamp][, callback])
1440
1546
 
1441
1547
  This function will mark your entire inbox as seen (don't be confused with read!).
1442
1548
 
1443
- ---------------------------------------
1549
+ ---
1444
1550
 
1445
1551
  <a name="muteThread"></a>
1552
+
1446
1553
  ### api.muteThread(threadID, muteSeconds[, callback])
1447
1554
 
1448
1555
  Mute a chat for a period of time, or unmute a chat.
1449
1556
 
1450
- __Arguments__
1557
+ **Arguments**
1451
1558
 
1452
- * `threadID` - The ID of the chat you want to mute.
1453
- * `muteSeconds` - Mute the chat for this amount of seconds. Use `0` to unmute a chat. Use '-1' to mute a chat indefinitely.
1454
- * `callback(err)` - A callback called when the operation is done maybe with an object representing an error.
1559
+ - `threadID` - The ID of the chat you want to mute.
1560
+ - `muteSeconds` - Mute the chat for this amount of seconds. Use `0` to unmute a chat. Use '-1' to mute a chat indefinitely.
1561
+ - `callback(err)` - A callback called when the operation is done maybe with an object representing an error.
1455
1562
 
1456
- __Example__
1563
+ **Example**
1457
1564
 
1458
1565
  ```js
1459
1566
  const fs = require("fs");
1460
1567
  const login = require("fca-unofficial");
1461
1568
 
1462
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
1463
- if(err) return console.error(err);
1569
+ login(
1570
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
1571
+ (err, api) => {
1572
+ if (err) return console.error(err);
1464
1573
 
1465
1574
  api.listen((err, message) => {
1466
- if(err) return console.error(err);
1575
+ if (err) return console.error(err);
1467
1576
 
1468
- // Mute all incoming chats for one minute
1469
- api.muteThread(message.threadID, 60);
1577
+ // Mute all incoming chats for one minute
1578
+ api.muteThread(message.threadID, 60);
1470
1579
  });
1471
- });
1580
+ }
1581
+ );
1472
1582
  ```
1473
1583
 
1474
- ---------------------------------------
1584
+ ---
1475
1585
 
1476
1586
  <a name="removeUserFromGroup"></a>
1587
+
1477
1588
  ### api.removeUserFromGroup(userID, threadID[, callback])
1478
1589
 
1479
1590
  Removes a user from a group chat.
1480
1591
 
1481
- __Arguments__
1592
+ **Arguments**
1482
1593
 
1483
- * `userID`: User ID.
1484
- * `threadID`: Group chat ID.
1485
- * `callback(err)`: A callback called when the query is done (either with an error or with no arguments).
1594
+ - `userID`: User ID.
1595
+ - `threadID`: Group chat ID.
1596
+ - `callback(err)`: A callback called when the query is done (either with an error or with no arguments).
1486
1597
 
1487
- ---------------------------------------
1598
+ ---
1488
1599
 
1489
1600
  <a name="resolvePhotoUrl"></a>
1601
+
1490
1602
  ### api.resolvePhotoUrl(photoID, callback)
1491
1603
 
1492
1604
  Resolves the URL to the full-size photo, given its ID. This function is useful for retrieving the full-size photo URL
1493
1605
  of image attachments in messages, returned by [`api.getThreadHistory`](#getThreadHistory).
1494
1606
 
1495
- __Arguments__
1607
+ **Arguments**
1496
1608
 
1497
- * `photoID`: Photo ID.
1498
- * `callback(err, url)`: A callback called when the query is done (either with an error or with the photo's URL). `url` is a string with the photo's URL.
1609
+ - `photoID`: Photo ID.
1610
+ - `callback(err, url)`: A callback called when the query is done (either with an error or with the photo's URL). `url` is a string with the photo's URL.
1499
1611
 
1500
- ---------------------------------------
1612
+ ---
1501
1613
 
1502
1614
  <a name="searchForThread"></a>
1615
+
1503
1616
  ### api.searchForThread(name, callback)
1504
1617
 
1505
1618
  > This part is outdated.
@@ -1507,179 +1620,196 @@ __Arguments__
1507
1620
 
1508
1621
  Takes a chat title (thread name) and returns matching results as a formatted threads array (ordered according to Facebook).
1509
1622
 
1510
- __Arguments__
1511
- * `name`: A messageID string or messageID string array
1512
- * `callback(err, obj)`: A callback called when the query is done (either with an error or a thread object). The object passed in the callback has the following shape: `threadID`, <del>`participants`</del>, `participantIDs`, `formerParticipants`, `name`, `nicknames`, `snippet`, `snippetHasAttachment`, `snippetAttachments`, `snippetSender`, `unreadCount`, `messageCount`, `imageSrc`, `timestamp`, `serverTimestamp`, `muteSettings`, `isCanonicalUser`, `isCanonical`, `canonicalFbid`, `isSubscribed`, `rootMessageThreadingID`, `folder`, `isArchived`, `recipientsLoadable`, `hasEmailParticipant`, `readOnly`, `canReply`, `composerEnabled`, `blockedParticipants`, `lastMessageID`
1623
+ **Arguments**
1513
1624
 
1514
- ---------------------------------------
1625
+ - `name`: A messageID string or messageID string array
1626
+ - `callback(err, obj)`: A callback called when the query is done (either with an error or a thread object). The object passed in the callback has the following shape: `threadID`, <del>`participants`</del>, `participantIDs`, `formerParticipants`, `name`, `nicknames`, `snippet`, `snippetHasAttachment`, `snippetAttachments`, `snippetSender`, `unreadCount`, `messageCount`, `imageSrc`, `timestamp`, `serverTimestamp`, `muteSettings`, `isCanonicalUser`, `isCanonical`, `canonicalFbid`, `isSubscribed`, `rootMessageThreadingID`, `folder`, `isArchived`, `recipientsLoadable`, `hasEmailParticipant`, `readOnly`, `canReply`, `composerEnabled`, `blockedParticipants`, `lastMessageID`
1627
+
1628
+ ---
1515
1629
 
1516
1630
  <a name="sendMessage"></a>
1517
- ### api.sendMessage(message, threadID[, callback][, messageID])
1631
+
1632
+ ### api.sendMessage(message, threadID[, callback][, messageid])
1518
1633
 
1519
1634
  Sends the given message to the threadID.
1520
1635
 
1521
- __Arguments__
1636
+ **Arguments**
1522
1637
 
1523
- * `message`: A string (for backward compatibility) or a message object as described below.
1524
- * `threadID`: A string, number, or array representing a thread. It happens to be someone's userID in the case of a one to one conversation or an array of userIDs when starting a new group chat.
1525
- * `callback(err, messageInfo)`: (Optional) A callback called when sending the message is done (either with an error or with an confirmation object). `messageInfo` contains the `threadID` where the message was sent and a `messageID`, as well as the `timestamp` of the message.
1526
- * `messageID`: (Optional) A string representing a message you want to reply.
1638
+ - `message`: A string (for backward compatibility) or a message object as described below.
1639
+ - `threadID`: A string, number, or array representing a thread. It happens to be someone's userID in the case of a one to one conversation or an array of userIDs when starting a new group chat.
1640
+ - `callback(err, messageInfo)`: (Optional) A callback called when sending the message is done (either with an error or with an confirmation object). `messageInfo` contains the `threadID` where the message was sent and a `messageID`, as well as the `timestamp` of the message.
1641
+ - `messageID`: (Optional) A string representing a message you want to reply.
1527
1642
 
1528
- __Message Object__:
1643
+ **Message Object**:
1529
1644
 
1530
1645
  Various types of message can be sent:
1531
- * *Regular:* set field `body` to the desired message as a string.
1532
- * *Sticker:* set a field `sticker` to the desired sticker ID.
1533
- * *File or image:* Set field `attachment` to a readable stream or an array of readable streams.
1534
- * *URL:* set a field `url` to the desired URL.
1535
- * *Emoji:* set field `emoji` to the desired emoji as a string and set field `emojiSize` with size of the emoji (`small`, `medium`, `large`)
1536
- * *Mentions:* set field `mentions` to an array of objects. Objects should have the `tag` field set to the text that should be highlighted in the mention. The object should have an `id` field, where the `id` is the user id of the person being mentioned. The instance of `tag` that is highlighted is determined through indexOf, an optional `fromIndex`
1537
- can be passed in to specify the start index to start searching for the `tag` text
1538
- in `body` (default=0). (See below for an example.)
1539
- * *Location:* set field `location` to an object with `latitude` and `longitude` fields. Optionally set field `current` of the `location` object to true to indicate the location is the user’s current location. Otherwise the location will be sent as a pinned location.
1646
+
1647
+ - _Regular:_ set field `body` to the desired message as a string.
1648
+ - _Sticker:_ set a field `sticker` to the desired sticker ID.
1649
+ - _File or image:_ Set field `attachment` to a readable stream or an array of readable streams.
1650
+ - _URL:_ set a field `url` to the desired URL.
1651
+ - _Emoji:_ set field `emoji` to the desired emoji as a string and set field `emojiSize` with size of the emoji (`small`, `medium`, `large`)
1652
+ - _Mentions:_ set field `mentions` to an array of objects. Objects should have the `tag` field set to the text that should be highlighted in the mention. The object should have an `id` field, where the `id` is the user id of the person being mentioned. The instance of `tag` that is highlighted is determined through indexOf, an optional `fromIndex`
1653
+ can be passed in to specify the start index to start searching for the `tag` text
1654
+ in `body` (default=0). (See below for an example.)
1655
+ - _Location:_ set field `location` to an object with `latitude` and `longitude` fields. Optionally set field `current` of the `location` object to true to indicate the location is the user’s current location. Otherwise the location will be sent as a pinned location.
1540
1656
 
1541
1657
  Note that a message can only be a regular message (which can be empty) and optionally one of the following: a sticker, an attachment or a url.
1542
1658
 
1543
- __Tip__: to find your own ID, you can look inside the cookies. The `userID` is under the name `c_user`.
1659
+ **Tip**: to find your own ID, you can look inside the cookies. The `userID` is under the name `c_user`.
1660
+
1661
+ **Example (Basic Message)**
1544
1662
 
1545
- __Example (Basic Message)__
1546
1663
  ```js
1547
1664
  const fs = require("fs");
1548
1665
  const login = require("fca-unofficial");
1549
1666
 
1550
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
1551
- if(err) return console.error(err);
1667
+ login(
1668
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
1669
+ (err, api) => {
1670
+ if (err) return console.error(err);
1552
1671
 
1553
1672
  var yourID = "000000000000000";
1554
- var msg = {body: "Hey!"};
1673
+ var msg = { body: "Hey!" };
1555
1674
  api.sendMessage(msg, yourID);
1556
- });
1675
+ }
1676
+ );
1557
1677
  ```
1558
1678
 
1559
- __Example (File upload)__
1679
+ **Example (File upload)**
1680
+
1560
1681
  ```js
1561
1682
  const fs = require("fs");
1562
1683
  const login = require("fca-unofficial");
1563
1684
 
1564
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
1565
- if(err) return console.error(err);
1685
+ login(
1686
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
1687
+ (err, api) => {
1688
+ if (err) return console.error(err);
1566
1689
 
1567
1690
  // This example uploads an image called image.jpg
1568
1691
  var yourID = "000000000000000";
1569
1692
  var msg = {
1570
- body: "Hey!",
1571
- attachment: fs.createReadStream(__dirname + '/image.jpg')
1572
- }
1693
+ body: "Hey!",
1694
+ attachment: fs.createReadStream(__dirname + "/image.jpg")
1695
+ };
1573
1696
  api.sendMessage(msg, yourID);
1574
- });
1697
+ }
1698
+ );
1575
1699
  ```
1576
1700
 
1577
- __Example (Mention)__
1701
+ **Example (Mention)**
1702
+
1578
1703
  ```js
1579
1704
  const login = require("fca-unofficial");
1580
1705
 
1581
- login({email: "EMAIL", password: "PASSWORD"}, (err, api) => {
1582
- if(err) return console.error(err);
1583
-
1584
- api.listen((err, message) => {
1585
- if (message && message.body) {
1586
- // Getting the actual sender name from ID involves calling
1587
- // `api.getThreadInfo` and `api.getUserInfo`
1588
- api.sendMessage({
1589
- body: 'Hello @Sender! @Sender!',
1590
- mentions: [{
1591
- tag: '@Sender',
1592
- id: message.senderID,
1593
- fromIndex: 9, // Highlight the second occurrence of @Sender
1594
- }],
1595
- }, message.threadID);
1596
- }
1597
- });
1706
+ login({ email: "EMAIL", password: "PASSWORD" }, (err, api) => {
1707
+ if (err) return console.error(err);
1708
+
1709
+ api.listen((err, message) => {
1710
+ if (message && message.body) {
1711
+ // Getting the actual sender name from ID involves calling
1712
+ // `api.getThreadInfo` and `api.getUserInfo`
1713
+ api.sendMessage(
1714
+ {
1715
+ body: "Hello @Sender! @Sender!",
1716
+ mentions: [
1717
+ {
1718
+ tag: "@Sender",
1719
+ id: message.senderID,
1720
+ fromIndex: 9 // Highlight the second occurrence of @Sender
1721
+ }
1722
+ ]
1723
+ },
1724
+ message.threadID
1725
+ );
1726
+ }
1727
+ });
1598
1728
  });
1599
1729
  ```
1600
1730
 
1601
- __Example (Location)__
1731
+ **Example (Location)**
1732
+
1602
1733
  ```js
1603
1734
  const login = require("fca-unofficial");
1604
- login({email: "EMAIL", password: "PASSWORD"}, (err, api) => {
1605
- if(err) return console.error(err);
1606
- var yourID = "000000000000000";
1607
- const msg = {
1608
- location: { latitude: 48.858093, longitude: 2.294694, current: true },
1609
- };
1610
- api.sendMessage(msg, yourID);
1735
+ login({ email: "EMAIL", password: "PASSWORD" }, (err, api) => {
1736
+ if (err) return console.error(err);
1737
+ var yourID = "000000000000000";
1738
+ const msg = {
1739
+ location: { latitude: 48.858093, longitude: 2.294694, current: true }
1740
+ };
1741
+ api.sendMessage(msg, yourID);
1611
1742
  });
1612
1743
  ```
1613
1744
 
1614
- ---------------------------------------
1745
+ ---
1615
1746
 
1616
1747
  <a name="sendTypingIndicator"></a>
1748
+
1617
1749
  ### api.sendTypingIndicator(threadID[, callback])
1618
1750
 
1619
1751
  Sends a "USERNAME is typing" indicator to other members of the thread indicated by `threadID`. This indication will disappear after 30 second or when the `end` function is called. The `end` function is returned by `api.sendTypingIndicator`.
1620
1752
 
1621
- __Arguments__
1753
+ **Arguments**
1622
1754
 
1623
- * `threadID`: Group chat ID.
1624
- * `callback(err)`: A callback called when the query is done (with an error or with null).
1755
+ - `threadID`: Group chat ID.
1756
+ - `callback(err)`: A callback called when the query is done (with an error or with null).
1625
1757
 
1626
- ---------------------------------------
1758
+ ---
1627
1759
 
1628
1760
  <a name="setMessageReaction"></a>
1761
+
1629
1762
  ### api.setMessageReaction(reaction, messageID[, callback[, forceCustomReaction]])
1630
1763
 
1631
1764
  Sets reaction on message
1632
1765
 
1633
- __Arguments__
1766
+ **Arguments**
1634
1767
 
1635
- * `reaction`: A string containing either an emoji, an emoji in unicode, or an emoji shortcut (see list of supported emojis below). The string can be left empty ("") in order to remove a reaction.
1636
- * `messageID`: A string representing the message ID.
1637
- * `callback(err)`: A callback called when sending the reaction is done.
1638
- * `forceCustomReaction`: Forcing the use of an emoji for setting reaction **(WARNING: NOT TESTED, YOU SHOULD NOT USE THIS AT ALL, UNLESS YOU'RE TESTING A NEW EMOJI)**
1768
+ - `reaction`: A string containing either an emoji, an emoji in unicode, or an emoji shortcut (see list of supported emojis below). The string can be left empty ("") in order to remove a reaction.
1769
+ - `messageID`: A string representing the message ID.
1770
+ - `callback(err)`: A callback called when sending the reaction is done.
1771
+ - `forceCustomReaction`: Forcing the use of an emoji for setting reaction **(WARNING: NOT TESTED, YOU SHOULD NOT USE THIS AT ALL, UNLESS YOU'RE TESTING A NEW EMOJI)**
1639
1772
 
1640
- __Supported Emojis__
1773
+ **Supported Emojis**
1641
1774
 
1642
- |Emoji|Text|Unicode|Shortcuts|
1643
- |---|---|---|---|
1644
- |😍|`😍`|`\uD83D\uDE0D`|`:love:`, `:heart_eyes:`|
1645
- |😆|`😆`|`\uD83D\uDE06`|`:haha:`, `:laughing:`|
1646
- |😮|`😮`|`\uD83D\uDE2E`|`:wow:`, `:open_mouth:`|
1647
- |😢|`😢`|`\uD83D\uDE22`|`:sad:`, `:cry:`|
1648
- |😠|`😠`|`\uD83D\uDE20`|`:angry:`|
1649
- |👍|`👍`|`\uD83D\uDC4D`|`:like:`, `:thumbsup:`|
1650
- |👎|`👎`|`\uD83D\uDC4E`|`:dislike:`, `:thumbsdown:`|
1651
- |❤|`❤`|`\u2764`|`:heart:`|
1652
- |💗|`💗`|`\uD83D\uDC97`|`:glowingheart:`|
1775
+ | Emoji | Text | Unicode | Shortcuts |
1776
+ | ----- | ---- | -------------- | --------------------------- |
1777
+ | 😍 | `😍` | `\uD83D\uDE0D` | `:love:`, `:heart_eyes:` |
1778
+ | 😆 | `😆` | `\uD83D\uDE06` | `:haha:`, `:laughing:` |
1779
+ | 😮 | `😮` | `\uD83D\uDE2E` | `:wow:`, `:open_mouth:` |
1780
+ | 😢 | `😢` | `\uD83D\uDE22` | `:sad:`, `:cry:` |
1781
+ | 😠 | `😠` | `\uD83D\uDE20` | `:angry:` |
1782
+ | 👍 | `👍` | `\uD83D\uDC4D` | `:like:`, `:thumbsup:` |
1783
+ | 👎 | `👎` | `\uD83D\uDC4E` | `:dislike:`, `:thumbsdown:` |
1784
+ | ❤ | `❤` | `\u2764` | `:heart:` |
1785
+ | 💗 | `💗` | `\uD83D\uDC97` | `:glowingheart:` |
1653
1786
 
1654
- ---------------------------------------
1787
+ ---
1655
1788
 
1656
1789
  <a name="setOptions"></a>
1790
+
1657
1791
  ### api.setOptions(options)
1658
1792
 
1659
1793
  Sets various configurable options for the api.
1660
1794
 
1661
- __Arguments__
1662
-
1663
- * `options` - An object containing the new values for the options that you want
1664
- to set. If the value for an option is unspecified, it is unchanged. The following options are possible.
1665
- - `pauseLog`: (Default `false`) Set this to `true` if you want to pause the npmlog output.
1666
- - `logLevel`: The desired logging level as determined by npmlog. Choose
1667
- from either `"silly"`, `"verbose"`, `"info"`, `"http"`, `"warn"`, `"error"`, or `"silent"`.
1668
- - `selfListen`: (Default `false`) Set this to `true` if you want your api
1669
- to receive messages from its own account. This is to be used with
1670
- caution, as it can result in loops (a simple echo bot will send messages
1671
- forever).
1672
- - `listenEvents`: (Default `false`) Will make [api.listen](#listen) also handle events (look at api.listen for more details).
1673
- - `pageID`: (Default empty) Makes [api.listen](#listen) only receive messages through the page specified by that ID. Also makes [api.sendMessage](#sendMessage) send from the page.
1674
- - `updatePresence`: (Default `false`) Will make [api.listen](#listen) also return `presence` ([api.listen](#presence) for more details).
1675
- - `forceLogin`: (Default `false`) Will automatically approve of any recent logins and continue with the login process.
1676
- - `userAgent`: (Default `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`) The desired simulated User Agent.
1677
- - `autoMarkDelivery`: (Default `true`) Will automatically mark new messages as delivered. See [api.markAsDelivered](#markAsDelivered).
1678
- - `autoMarkRead`: (Default `false`) Will automatically mark new messages as read/seen. See [api.markAsRead](#markAsRead).
1679
- - `proxy`: (Default empty) Set this to proxy server address to use proxy. Note: Only HTTP Proxies which support CONNECT method is supported.
1680
- - `online`: (Default `true`) Set account's online state.
1681
-
1682
- __Example__
1795
+ **Arguments**
1796
+
1797
+ - `options` - An object containing the new values for the options that you want
1798
+ to set. If the value for an option is unspecified, it is unchanged. The following options are possible.
1799
+ - `pauseLog`: (Default `false`) Set this to `true` if you want to pause the npmlog output.
1800
+ - `logLevel`: The desired logging level as determined by npmlog. Choose
1801
+ from either `"silly"`, `"verbose"`, `"info"`, `"http"`, `"warn"`, `"error"`, or `"silent"`.
1802
+ - `selfListen`: (Default `false`) Set this to `true` if you want your api
1803
+ to receive messages from its own account. This is to be used with
1804
+ caution, as it can result in loops (a simple echo bot will send messages
1805
+ forever).
1806
+ - `listenEvents`: (Default `false`) Will make [api.listen](#listen) also handle events (look at api.listen for more details).
1807
+ - `pageID`: (Default empty) Makes [api.listen](#listen) only receive messages through the page specified by that ID. Also makes [api.sendMessage](#sendMessage) send from the page.
1808
+ - `updatePresence`: (Default `false`) Will make [api.listen](#listen) also return `presence` ([api.listen](#presence) for more details).
1809
+ - `forceLogin`: (Default `false`) Will automatically approve of any recent logins and continue with the login process.
1810
+ - `userAgent`: (Default `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`) The desired simulated User Agent. - `autoMarkDelivery`: (Default `true`) Will automatically mark new messages as delivered. See [api.markAsDelivered](#markAsDelivered). - `autoMarkRead`: (Default `false`) Will automatically mark new messages as read/seen. See [api.markAsRead](#markAsRead). - `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.
1811
+
1812
+ **Example**
1683
1813
 
1684
1814
  ```js
1685
1815
  const fs = require("fs");
@@ -1687,52 +1817,57 @@ const login = require("fca-unofficial");
1687
1817
 
1688
1818
  // Simple echo bot. This will send messages forever.
1689
1819
 
1690
- login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
1691
- if(err) return console.error(err);
1820
+ login(
1821
+ { appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) },
1822
+ (err, api) => {
1823
+ if (err) return console.error(err);
1692
1824
 
1693
1825
  api.setOptions({
1694
- selfListen: true,
1695
- logLevel: "silent"
1826
+ selfListen: true,
1827
+ logLevel: "silent"
1696
1828
  });
1697
1829
 
1698
1830
  api.listen((err, message) => {
1699
- if(err) return console.error(err);
1831
+ if (err) return console.error(err);
1700
1832
 
1701
- // Ignore empty messages (photos etc.)
1702
- if (typeof message.body === "string") {
1703
- api.sendMessage(message.body, message.threadID);
1704
- }
1833
+ // Ignore empty messages (photos etc.)
1834
+ if (typeof message.body === "string") {
1835
+ api.sendMessage(message.body, message.threadID);
1836
+ }
1705
1837
  });
1706
- });
1838
+ }
1839
+ );
1707
1840
  ```
1708
1841
 
1709
- ---------------------------------------
1842
+ ---
1710
1843
 
1711
1844
  <a name="setTitle"></a>
1845
+
1712
1846
  ### api.setTitle(newTitle, threadID[, callback])
1713
1847
 
1714
1848
  Sets the title of the group chat with thread id `threadID` to `newTitle`.
1715
1849
 
1716
1850
  Note: This will not work if the thread id corresponds to a single-user chat or if the bot is not in the group chat.
1717
1851
 
1718
- __Arguments__
1852
+ **Arguments**
1719
1853
 
1720
- * `newTitle`: A string representing the new title.
1721
- * `threadID`: A string or number representing a thread. It happens to be someone's userID in the case of a one to one conversation.
1722
- * `callback(err, obj)` - A callback called when sending the message is done (either with an error or with an confirmation object). `obj` contains only the threadID where the message was sent.
1854
+ - `newTitle`: A string representing the new title.
1855
+ - `threadID`: A string or number representing a thread. It happens to be someone's userID in the case of a one to one conversation.
1856
+ - `callback(err, obj)` - A callback called when sending the message is done (either with an error or with an confirmation object). `obj` contains only the threadID where the message was sent.
1723
1857
 
1724
- ---------------------------------------
1858
+ ---
1725
1859
 
1726
1860
  <a name="unsendMessage"></a>
1861
+
1727
1862
  ### api.unsendMessage(messageID[, callback])
1728
1863
 
1729
1864
  Revokes a message from anyone that could see that message with `messageID`
1730
1865
 
1731
1866
  Note: This will only work if the message is sent by you and was sent less than 10 minutes ago.
1732
1867
 
1733
- __Arguments__
1868
+ **Arguments**
1734
1869
 
1735
- * `messageID`: Message ID you want to unsend.
1736
- * `callback(err)`: A callback called when the query is done (with an error or with null).
1870
+ - `messageID`: Message ID you want to unsend.
1871
+ - `callback(err)`: A callback called when the query is done (with an error or with null).
1737
1872
 
1738
- ---------------------------------------
1873
+ ---