stfca 1.0.20 → 1.0.21
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.
- package/index.js +12 -0
- package/package.json +1 -1
- package/src/OldMessage.js +34 -10
- package/src/sendMessage.js +15 -4
- package/utils.js +6 -1
package/index.js
CHANGED
|
@@ -4,6 +4,8 @@ var utils = require("./utils");
|
|
|
4
4
|
var cheerio = require("cheerio");
|
|
5
5
|
var log = require("npmlog");
|
|
6
6
|
var { checkForFCAUpdate } = require("./checkUpdate");
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
7
9
|
/*var { getThemeColors } = require("../../func/utils/log.js");
|
|
8
10
|
var logger = require("../../func/utils/log.js");
|
|
9
11
|
var { cra, cv, cb, co } = getThemeColors();*/
|
|
@@ -188,6 +190,16 @@ function buildAPI(globalOptions, html, jar) {
|
|
|
188
190
|
reqCallbacks: {},
|
|
189
191
|
threadTypes: {} // Store thread type (dm/group) for each thread
|
|
190
192
|
};
|
|
193
|
+
let config = { enableTypingIndicator: false, typingDuration: 4000 };
|
|
194
|
+
try {
|
|
195
|
+
const configPath = path.join(__dirname, 'config.json');
|
|
196
|
+
if (fs.existsSync(configPath)) {
|
|
197
|
+
config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
198
|
+
}
|
|
199
|
+
} catch (e) {
|
|
200
|
+
console.log('Error loading config.json:', e);
|
|
201
|
+
}
|
|
202
|
+
ctx.config = config;
|
|
191
203
|
var api = {
|
|
192
204
|
setOptions: setOptions.bind(null, globalOptions),
|
|
193
205
|
getAppState: () => utils.getAppState(jar),
|
package/package.json
CHANGED
package/src/OldMessage.js
CHANGED
|
@@ -311,19 +311,43 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
|
311
311
|
};
|
|
312
312
|
// console.log(form)
|
|
313
313
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
314
|
+
if (isSingleUser && ctx.config.enableTypingIndicator) {
|
|
315
|
+
const stopTyping = api.sendTypingIndicator(threadID, () => {}, false);
|
|
316
|
+
const originalCallback = callback;
|
|
317
|
+
callback = (err, data) => {
|
|
318
|
+
stopTyping(() => {});
|
|
319
|
+
originalCallback(err, data);
|
|
320
|
+
};
|
|
321
|
+
setTimeout(() => {
|
|
322
|
+
handleLocation(msg, form, callback, () =>
|
|
323
|
+
handleSticker(msg, form, callback, () =>
|
|
324
|
+
handleAttachment(msg, form, callback, () =>
|
|
325
|
+
handleUrl(msg, form, callback, () =>
|
|
326
|
+
handleEmoji(msg, form, callback, () =>
|
|
327
|
+
handleMention(msg, form, callback, () =>
|
|
328
|
+
sendContent(form, threadID, isSingleUser, messageAndOTID, callback)
|
|
329
|
+
)
|
|
330
|
+
)
|
|
331
|
+
)
|
|
332
|
+
)
|
|
333
|
+
)
|
|
334
|
+
);
|
|
335
|
+
}, ctx.config.typingDuration);
|
|
336
|
+
} else {
|
|
337
|
+
handleLocation(msg, form, callback, () =>
|
|
338
|
+
handleSticker(msg, form, callback, () =>
|
|
339
|
+
handleAttachment(msg, form, callback, () =>
|
|
340
|
+
handleUrl(msg, form, callback, () =>
|
|
341
|
+
handleEmoji(msg, form, callback, () =>
|
|
342
|
+
handleMention(msg, form, callback, () =>
|
|
343
|
+
sendContent(form, threadID, isSingleUser, messageAndOTID, callback)
|
|
344
|
+
)
|
|
345
|
+
)
|
|
321
346
|
)
|
|
322
347
|
)
|
|
323
348
|
)
|
|
324
|
-
)
|
|
325
|
-
|
|
326
|
-
);
|
|
349
|
+
);
|
|
350
|
+
}
|
|
327
351
|
return returnPromise;
|
|
328
352
|
};
|
|
329
353
|
};
|
package/src/sendMessage.js
CHANGED
|
@@ -234,10 +234,21 @@ module.exports = (defaultFuncs, api, ctx) => {
|
|
|
234
234
|
form["profile_xmd[" + i + "][type]"] = "p";
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
if (isSingleUser && ctx.config.enableTypingIndicator) {
|
|
238
|
+
const stopTyping = api.sendTypingIndicator(threadID, () => {}, false);
|
|
239
|
+
await utils.delay(ctx.config.typingDuration);
|
|
240
|
+
const result = await sendContent(form, threadID, isSingleUser, messageAndOTID);
|
|
241
|
+
stopTyping(() => {});
|
|
242
|
+
if (callback && typeof callback === "function") {
|
|
243
|
+
callback(null, result);
|
|
244
|
+
}
|
|
245
|
+
return result;
|
|
246
|
+
} else {
|
|
247
|
+
const result = await sendContent(form, threadID, isSingleUser, messageAndOTID);
|
|
248
|
+
if (callback && typeof callback === "function") {
|
|
249
|
+
callback(null, result);
|
|
250
|
+
}
|
|
251
|
+
return result;
|
|
240
252
|
}
|
|
241
|
-
return result;
|
|
242
253
|
};
|
|
243
254
|
};
|
package/utils.js
CHANGED
|
@@ -2878,6 +2878,10 @@ function cleanHTML(text) {
|
|
|
2878
2878
|
return text;
|
|
2879
2879
|
}
|
|
2880
2880
|
|
|
2881
|
+
function delay(ms) {
|
|
2882
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
2883
|
+
}
|
|
2884
|
+
|
|
2881
2885
|
module.exports = {
|
|
2882
2886
|
cleanHTML,
|
|
2883
2887
|
isReadableStream: isReadableStream,
|
|
@@ -2926,5 +2930,6 @@ module.exports = {
|
|
|
2926
2930
|
getJazoest,
|
|
2927
2931
|
getEventTime,
|
|
2928
2932
|
getSessionID,
|
|
2929
|
-
getFormData
|
|
2933
|
+
getFormData,
|
|
2934
|
+
delay
|
|
2930
2935
|
};
|