alicezetion 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -1
  2. package/.cache/replit/nix/env.json +1 -1
  3. package/alice/addExternalModule.js +19 -0
  4. package/alice/{add.js → addUserToGroup.js} +16 -2
  5. package/alice/{admin.js → changeAdminStatus.js} +17 -3
  6. package/alice/{archive.js → changeArchivedStatus.js} +16 -2
  7. package/alice/changeBio.js +77 -0
  8. package/alice/changeBlockedStatus.js +47 -0
  9. package/alice/{gcimage.js → changeGroupImage.js} +16 -2
  10. package/alice/{nickname.js → changeNickname.js} +17 -2
  11. package/alice/changeThreadColor.js +71 -0
  12. package/alice/{emoji.js → changeThreadEmoji.js} +16 -2
  13. package/alice/createNewGroup.js +86 -0
  14. package/alice/{poll.js → createPoll.js} +18 -2
  15. package/alice/{deletemsg.js → deleteMessage.js} +15 -2
  16. package/alice/{deletegc.js → deleteThread.js} +15 -2
  17. package/alice/{forward.js → forwardAttachment.js} +16 -3
  18. package/alice/{id.js → getCurrentUserID.js} +1 -1
  19. package/alice/{friend.js → getFriendsList.js} +17 -3
  20. package/alice/{history.js → getThreadHistory.js} +19 -6
  21. package/alice/{gchistorydeprecated.js → getThreadHistoryDeprecated.js} +18 -1
  22. package/alice/{gcinfo.js → getThreadInfo.js} +49 -13
  23. package/alice/{gcinfodeprecated.js → getThreadInfoDeprecated.js} +17 -2
  24. package/alice/{gclist.js → getThreadList.js} +27 -9
  25. package/alice/{gclistdeprecated.js → getThreadListDeprecated.js} +1 -1
  26. package/alice/{gcimg.js → getThreadPictures.js} +15 -2
  27. package/alice/{userid.js → getUserID.js} +16 -2
  28. package/alice/{userinfo.js → getUserInfo.js} +18 -3
  29. package/alice/handleFriendRequest.js +61 -0
  30. package/alice/{msgrequest.js → handleMessageRequest.js} +16 -2
  31. package/alice/httpGet.js +52 -0
  32. package/alice/httpPost.js +52 -0
  33. package/alice/listenMqtt.js +363 -134
  34. package/alice/logout.js +18 -2
  35. package/alice/{delivered.js → markAsDelivered.js} +19 -2
  36. package/alice/markAsRead.js +80 -0
  37. package/alice/{seen.js → markAsReadAll.js} +16 -2
  38. package/alice/markAsSeen.js +59 -0
  39. package/alice/{mute.js → muteThread.js} +16 -2
  40. package/alice/{kick.js → removeUserFromGroup.js} +16 -2
  41. package/alice/{resolveimgurl.js → resolvePhotoUrl.js} +16 -2
  42. package/alice/{gcsearch.js → searchForThread.js} +16 -2
  43. package/alice/{chat.js → sendMessage.js} +78 -34
  44. package/alice/sendTypingIndicator.js +103 -0
  45. package/alice/{react.js → setMessageReaction.js} +39 -4
  46. package/alice/setPostReaction.js +76 -0
  47. package/alice/{title.js → setTitle.js} +16 -3
  48. package/alice/threadColors.js +57 -0
  49. package/alice/unfriend.js +52 -0
  50. package/alice/{unsend.js → unsendMessage.js} +16 -2
  51. package/index.js +324 -143
  52. package/package.json +27 -18
  53. package/utils.js +137 -61
  54. package/.cache/replit/modules.stamp +0 -0
  55. package/README.md +0 -40
  56. package/alice/block.js +0 -72
  57. package/alice/color.js +0 -53
  58. package/alice/gcolor.js +0 -22
  59. package/alice/listen.js +0 -553
  60. package/alice/read.js +0 -52
  61. package/alice/typeindicator.js +0 -77
  62. /package/alice/{emojiurl.js → getEmojiUrl.js} +0 -0
@@ -1 +1 @@
1
- {"nonce":7770620907313939412,"last_updated":{"seconds":1677839037,"nanos":636961000}}
1
+ {"nonce":5508855737636226,"last_updated":{"seconds":1681031478,"nanos":519626000}}
@@ -1 +1 @@
1
- {"entries":{"replit.nix":{"env":{"AR":"ar","AS":"as","CC":"gcc","CONFIG_SHELL":"/nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin/bash","CXX":"g++","HOST_PATH":"/nix/store/dj805sw07vvpbxx39c8g67x8qddg0ikw-nodejs-18.12.1/bin:/nix/store/7rfpsb04f2r6a755bqmmj1i90x8p1b18-typescript-language-server-3.1.0/bin:/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/bin:/nix/store/hqc964yg79161afx85fvcmg1a6879k5i-jest-cli-23.6.0/bin:/nix/store/a7gvj343m05j2s32xcnwr35v31ynlypr-coreutils-9.1/bin:/nix/store/mydc6f4k2z73xlcz7ilif3v2lcaiqvza-findutils-4.9.0/bin:/nix/store/j9p3g8472iijd50vhdprx0nmk2fqn5gv-diffutils-3.8/bin:/nix/store/89zs7rms6x00xfq4dq6m7mjnhkr8a6r4-gnused-4.8/bin:/nix/store/86bp03jkmsl6f92w0yzg4s59g5mhxwmy-gnugrep-3.7/bin:/nix/store/hwcdqw4jrjnd37wxqgsd47hd0j8bnj09-gawk-5.1.1/bin:/nix/store/cfbhw8r8ags41vwqaz47r583d0p4h4a1-gnutar-1.34/bin:/nix/store/p3m1ndl1lapwrlh698bnb5lvvxh67378-gzip-1.12/bin:/nix/store/a8mhcagrsly7c7mpjrpsnaahk4aax056-bzip2-1.0.8-bin/bin:/nix/store/mblgz65m3zv9x548a3d5m96fj2pbwr09-gnumake-4.3/bin:/nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin:/nix/store/v7ljksji50mg3w61dykaa3n3y79n6nil-patch-2.7.6/bin:/nix/store/zlcnmqq14jz5x9439jf937mvayyl63da-xz-5.2.7-bin/bin:/nix/store/y6aj732zm9m87c82fpvf103a1xb22blp-file-5.43/bin","LD":"ld","LOCALE_ARCHIVE":"/usr/lib/locale/locale-archive","NIX_BINTOOLS":"/nix/store/1d6ian3r8kdzspw8hacjhl3xkp40g1lj-binutils-wrapper-2.39","NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu":"1","NIX_BUILD_CORES":"16","NIX_BUILD_TOP":"/tmp","NIX_CC":"/nix/store/dq0xwmsk1g0i2ayg6pb7y87na2knzylh-gcc-wrapper-11.3.0","NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu":"1","NIX_CFLAGS_COMPILE":" -frandom-seed=7ya8xlq922 -isystem /nix/store/dj805sw07vvpbxx39c8g67x8qddg0ikw-nodejs-18.12.1/include -isystem /nix/store/dj805sw07vvpbxx39c8g67x8qddg0ikw-nodejs-18.12.1/include","NIX_ENFORCE_NO_NATIVE":"1","NIX_HARDENING_ENABLE":"fortify stackprotector pic strictoverflow format relro bindnow","NIX_INDENT_MAKE":"1","NIX_LDFLAGS":"-rpath /nix/store/7ya8xlq922h1fx115xra9kl0d0pfk2ab-nix-shell/lib64 -rpath /nix/store/7ya8xlq922h1fx115xra9kl0d0pfk2ab-nix-shell/lib ","NIX_STORE":"/nix/store","NM":"nm","NODE_PATH":"/nix/store/dj805sw07vvpbxx39c8g67x8qddg0ikw-nodejs-18.12.1/lib/node_modules:/nix/store/7rfpsb04f2r6a755bqmmj1i90x8p1b18-typescript-language-server-3.1.0/lib/node_modules:/nix/store/hqc964yg79161afx85fvcmg1a6879k5i-jest-cli-23.6.0/lib/node_modules","OBJCOPY":"objcopy","OBJDUMP":"objdump","PATH":"/nix/store/bap4d0lpcrhpwmpb8ayjcgkmvfj62lnq-bash-interactive-5.1-p16/bin:/nix/store/pr5n59mb4jzmfx6kanwxly0l07p861fg-patchelf-0.15.0/bin:/nix/store/dq0xwmsk1g0i2ayg6pb7y87na2knzylh-gcc-wrapper-11.3.0/bin:/nix/store/1gf2flfqnpqbr1b4p4qz2f72y42bs56r-gcc-11.3.0/bin:/nix/store/57xv61c5zi8pphjbcwxxjlgc34p61ic9-glibc-2.35-163-bin/bin:/nix/store/a7gvj343m05j2s32xcnwr35v31ynlypr-coreutils-9.1/bin:/nix/store/1d6ian3r8kdzspw8hacjhl3xkp40g1lj-binutils-wrapper-2.39/bin:/nix/store/039g378vc3pc3dvi9dzdlrd0i4q93qwf-binutils-2.39/bin:/nix/store/dj805sw07vvpbxx39c8g67x8qddg0ikw-nodejs-18.12.1/bin:/nix/store/7rfpsb04f2r6a755bqmmj1i90x8p1b18-typescript-language-server-3.1.0/bin:/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/bin:/nix/store/hqc964yg79161afx85fvcmg1a6879k5i-jest-cli-23.6.0/bin:/nix/store/a7gvj343m05j2s32xcnwr35v31ynlypr-coreutils-9.1/bin:/nix/store/mydc6f4k2z73xlcz7ilif3v2lcaiqvza-findutils-4.9.0/bin:/nix/store/j9p3g8472iijd50vhdprx0nmk2fqn5gv-diffutils-3.8/bin:/nix/store/89zs7rms6x00xfq4dq6m7mjnhkr8a6r4-gnused-4.8/bin:/nix/store/86bp03jkmsl6f92w0yzg4s59g5mhxwmy-gnugrep-3.7/bin:/nix/store/hwcdqw4jrjnd37wxqgsd47hd0j8bnj09-gawk-5.1.1/bin:/nix/store/cfbhw8r8ags41vwqaz47r583d0p4h4a1-gnutar-1.34/bin:/nix/store/p3m1ndl1lapwrlh698bnb5lvvxh67378-gzip-1.12/bin:/nix/store/a8mhcagrsly7c7mpjrpsnaahk4aax056-bzip2-1.0.8-bin/bin:/nix/store/mblgz65m3zv9x548a3d5m96fj2pbwr09-gnumake-4.3/bin:/nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin:/nix/store/v7ljksji50mg3w61dykaa3n3y79n6nil-patch-2.7.6/bin:/nix/store/zlcnmqq14jz5x9439jf937mvayyl63da-xz-5.2.7-bin/bin:/nix/store/y6aj732zm9m87c82fpvf103a1xb22blp-file-5.43/bin","RANLIB":"ranlib","READELF":"readelf","SIZE":"size","SOURCE_DATE_EPOCH":"315532800","STRINGS":"strings","STRIP":"strip","XDG_DATA_DIRS":"/nix/store/pr5n59mb4jzmfx6kanwxly0l07p861fg-patchelf-0.15.0/share","_":"/nix/store/a7gvj343m05j2s32xcnwr35v31ynlypr-coreutils-9.1/bin/env","__ETC_PROFILE_SOURCED":"1","buildInputs":"/nix/store/dj805sw07vvpbxx39c8g67x8qddg0ikw-nodejs-18.12.1 /nix/store/7rfpsb04f2r6a755bqmmj1i90x8p1b18-typescript-language-server-3.1.0 /nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19 /nix/store/hqc964yg79161afx85fvcmg1a6879k5i-jest-cli-23.6.0","buildPhase":"echo \"------------------------------------------------------------\" \u003e\u003e$out\necho \" WARNING: the existence of this path is not guaranteed.\" \u003e\u003e$out\necho \" It is an internal implementation detail for pkgs.mkShell.\" \u003e\u003e$out\necho \"------------------------------------------------------------\" \u003e\u003e$out\necho \u003e\u003e $out\n# Record all build inputs as runtime dependencies\nexport \u003e\u003e $out\n","builder":"/nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin/bash","cmakeFlags":"","configureFlags":"","depsBuildBuild":"","depsBuildBuildPropagated":"","depsBuildTarget":"","depsBuildTargetPropagated":"","depsHostHost":"","depsHostHostPropagated":"","depsTargetTarget":"","depsTargetTargetPropagated":"","doCheck":"","doInstallCheck":"","mesonFlags":"","name":"nix-shell","nativeBuildInputs":"","out":"/nix/store/7ya8xlq922h1fx115xra9kl0d0pfk2ab-nix-shell","outputs":"out","patches":"","phases":"buildPhase","propagatedBuildInputs":"","propagatedNativeBuildInputs":"","shell":"/nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin/bash","shellHook":"","stdenv":"/nix/store/kmfaajdpyyyg319vfqni5jm9wkxjmf73-stdenv-linux","strictDeps":"","system":"x86_64-linux"},"dependencies":[{"path":"replit.nix","mod_time":"2023-01-20T17:24:06.730825035Z"}],"channel":"stable-22_11","channel_nix_path":"/nix/store/nw56f75dmj9iyb0gmkcqyl62i7800d82-nixpkgs-stable-22_11-22.11.tar.gz/nixpkgs-stable-22_11"}}}
1
+ {"entries":{"replit.nix":{"env":{"AR":"ar","AS":"as","CC":"gcc","CONFIG_SHELL":"/nix/store/dpjnjrqbgbm8a5wvi1hya01vd8wyvsq4-bash-4.4-p23/bin/bash","CXX":"g++","HOST_PATH":"/nix/store/bwxril521b35zlf4x2g32hll64rzfhck-nodejs-16.7.0/bin:/nix/store/1570w56jrkvr90w9x158vyb5vahnk18v-coreutils-8.32/bin:/nix/store/ihxk2vlm0vi7c4j3gpm084kbxvz6v585-findutils-4.8.0/bin:/nix/store/kjx1mv85c5cgsrr4bwar22j7hbwj834m-diffutils-3.7/bin:/nix/store/gm2w08wwsa3vd500d8vq879s2lv65ldh-gnused-4.8/bin:/nix/store/v0slhpb2y3xa7gmv4q6gblkdk7n0f09j-gnugrep-3.6/bin:/nix/store/2wn093wbc6ps4brcsppxjd14vxvaa8a2-gawk-5.1.0/bin:/nix/store/5bxrjkyvqmzn1p897652y3lwa9fxagpw-gnutar-1.34/bin:/nix/store/liva1jnjdskrn57s42kfawr2zz66szzm-gzip-1.10/bin:/nix/store/ih2zkh2mbrx2c766ryk2i9hhlkly7snr-bzip2-1.0.6.0.2-bin/bin:/nix/store/pvkiiw0mp1yx0b21b7k105yywccychgh-gnumake-4.3/bin:/nix/store/dpjnjrqbgbm8a5wvi1hya01vd8wyvsq4-bash-4.4-p23/bin:/nix/store/aicl3kwfnaizk45aygm8bviqv7lk0a16-patch-2.7.6/bin:/nix/store/7jk6k46f56rszzc1bxi8mdrvcw53pym4-xz-5.2.5-bin/bin","LD":"ld","LOCALE_ARCHIVE":"/usr/lib/locale/locale-archive","NIX_BINTOOLS":"/nix/store/29bjq5hw1qglybp1a5f3ij9gxc2fyf94-binutils-wrapper-2.35.1","NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu":"1","NIX_BUILD_CORES":"8","NIX_BUILD_TOP":"/tmp","NIX_CC":"/nix/store/4xs1xyj8728yvh9y5v6ji819kwgfy2fv-gcc-wrapper-10.3.0","NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu":"1","NIX_CFLAGS_COMPILE":" -frandom-seed=wn4q3px71j -isystem /nix/store/bwxril521b35zlf4x2g32hll64rzfhck-nodejs-16.7.0/include -isystem /nix/store/bwxril521b35zlf4x2g32hll64rzfhck-nodejs-16.7.0/include","NIX_ENFORCE_NO_NATIVE":"1","NIX_HARDENING_ENABLE":"fortify stackprotector pic strictoverflow format relro bindnow","NIX_INDENT_MAKE":"1","NIX_LDFLAGS":"-rpath /nix/store/wn4q3px71j98mf9lcy14i6xlgmfhk75m-nix-shell/lib64 -rpath /nix/store/wn4q3px71j98mf9lcy14i6xlgmfhk75m-nix-shell/lib ","NIX_STORE":"/nix/store","NM":"nm","NODE_PATH":"/nix/store/bwxril521b35zlf4x2g32hll64rzfhck-nodejs-16.7.0/lib/node_modules","OBJCOPY":"objcopy","OBJDUMP":"objdump","PATH":"/nix/store/w07a7k61dw5gnsyxj3kgcq3shr76jax8-bash-interactive-4.4-p23/bin:/nix/store/435paza0j48aa9vgvf6r2l12nrg4ld11-patchelf-0.12/bin:/nix/store/4xs1xyj8728yvh9y5v6ji819kwgfy2fv-gcc-wrapper-10.3.0/bin:/nix/store/dlni53myj53kx20pi4yhm7p68lw17b07-gcc-10.3.0/bin:/nix/store/6z35qvn00xrjvaznv9kfy8xddbbdz4gl-glibc-2.33-47-bin/bin:/nix/store/1570w56jrkvr90w9x158vyb5vahnk18v-coreutils-8.32/bin:/nix/store/29bjq5hw1qglybp1a5f3ij9gxc2fyf94-binutils-wrapper-2.35.1/bin:/nix/store/v8imx1nvyz0hgvx9cbcmh6gp4ngw3ffj-binutils-2.35.1/bin:/nix/store/bwxril521b35zlf4x2g32hll64rzfhck-nodejs-16.7.0/bin:/nix/store/1570w56jrkvr90w9x158vyb5vahnk18v-coreutils-8.32/bin:/nix/store/ihxk2vlm0vi7c4j3gpm084kbxvz6v585-findutils-4.8.0/bin:/nix/store/kjx1mv85c5cgsrr4bwar22j7hbwj834m-diffutils-3.7/bin:/nix/store/gm2w08wwsa3vd500d8vq879s2lv65ldh-gnused-4.8/bin:/nix/store/v0slhpb2y3xa7gmv4q6gblkdk7n0f09j-gnugrep-3.6/bin:/nix/store/2wn093wbc6ps4brcsppxjd14vxvaa8a2-gawk-5.1.0/bin:/nix/store/5bxrjkyvqmzn1p897652y3lwa9fxagpw-gnutar-1.34/bin:/nix/store/liva1jnjdskrn57s42kfawr2zz66szzm-gzip-1.10/bin:/nix/store/ih2zkh2mbrx2c766ryk2i9hhlkly7snr-bzip2-1.0.6.0.2-bin/bin:/nix/store/pvkiiw0mp1yx0b21b7k105yywccychgh-gnumake-4.3/bin:/nix/store/dpjnjrqbgbm8a5wvi1hya01vd8wyvsq4-bash-4.4-p23/bin:/nix/store/aicl3kwfnaizk45aygm8bviqv7lk0a16-patch-2.7.6/bin:/nix/store/7jk6k46f56rszzc1bxi8mdrvcw53pym4-xz-5.2.5-bin/bin","RANLIB":"ranlib","READELF":"readelf","SIZE":"size","SOURCE_DATE_EPOCH":"315532800","STRINGS":"strings","STRIP":"strip","XDG_DATA_DIRS":"/nix/store/435paza0j48aa9vgvf6r2l12nrg4ld11-patchelf-0.12/share","_":"/nix/store/1570w56jrkvr90w9x158vyb5vahnk18v-coreutils-8.32/bin/env","__ETC_PROFILE_SOURCED":"1","buildInputs":"/nix/store/bwxril521b35zlf4x2g32hll64rzfhck-nodejs-16.7.0","builder":"/nix/store/dpjnjrqbgbm8a5wvi1hya01vd8wyvsq4-bash-4.4-p23/bin/bash","configureFlags":"","depsBuildBuild":"","depsBuildBuildPropagated":"","depsBuildTarget":"","depsBuildTargetPropagated":"","depsHostHost":"","depsHostHostPropagated":"","depsTargetTarget":"","depsTargetTargetPropagated":"","doCheck":"","doInstallCheck":"","name":"nix-shell","nativeBuildInputs":"","nobuildPhase":"echo\necho \"This derivation is not meant to be built, aborting\";\necho\nexit 1\n","out":"/nix/store/wn4q3px71j98mf9lcy14i6xlgmfhk75m-nix-shell","outputs":"out","patches":"","phases":"nobuildPhase","propagatedBuildInputs":"","propagatedNativeBuildInputs":"","shell":"/nix/store/dpjnjrqbgbm8a5wvi1hya01vd8wyvsq4-bash-4.4-p23/bin/bash","shellHook":"","stdenv":"/nix/store/r4bl79l2bdjawmr2rhhqvci56qh0fkvv-stdenv-linux","strictDeps":"","system":"x86_64-linux"},"dependencies":[{"path":"replit.nix","mod_time":"2023-04-09T09:10:15.439682411Z"}],"channel":"","channel_nix_path":""}}}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+
5
+ module.exports = function(defaultFuncs, api, ctx) {
6
+ return function addExternalModule(moduleObj) {
7
+ if (utils.getType(moduleObj) == "Object") {
8
+ for (let apiName in moduleObj) {
9
+ if (utils.getType(moduleObj[apiName]) == "Function") {
10
+ api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
11
+ } else {
12
+ throw new Error(`Item "${apiName}" in moduleObj must be a function, not ${utils.getType(moduleObj[apiName])}!`);
13
+ }
14
+ }
15
+ } else {
16
+ throw new Error(`moduleObj must be an object, not ${utils.getType(moduleObj)}!`);
17
+ }
18
+ };
19
+ };
@@ -3,8 +3,15 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function(defaultFuncs, bot, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function addUserToGroup(userID, threadID, callback) {
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
+ var returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
+
8
15
  if (
9
16
  !callback &&
10
17
  (utils.getType(threadID) === "Function" ||
@@ -14,7 +21,12 @@ module.exports = function(defaultFuncs, bot, ctx) {
14
21
  }
15
22
 
16
23
  if (!callback) {
17
- callback = function() {};
24
+ callback = function(err) {
25
+ if (err) {
26
+ return rejectFunc(err);
27
+ }
28
+ resolveFunc();
29
+ };
18
30
  }
19
31
 
20
32
  if (
@@ -95,5 +107,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
95
107
  log.error("addUserToGroup", err);
96
108
  return callback(err);
97
109
  });
110
+
111
+ return returnPromise;
98
112
  };
99
113
  };
@@ -3,7 +3,7 @@
3
3
  const utils = require("../utils");
4
4
  const log = require("npmlog");
5
5
 
6
- module.exports = function(defaultFuncs, bot, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function changeAdminStatus(threadID, adminIDs, adminStatus, callback) {
8
8
  if (utils.getType(threadID) !== "String") {
9
9
  throw {error: "changeAdminStatus: threadID must be a string"};
@@ -21,8 +21,20 @@ module.exports = function(defaultFuncs, bot, ctx) {
21
21
  throw {error: "changeAdminStatus: adminStatus must be a string"};
22
22
  }
23
23
 
24
+ var resolveFunc = function(){};
25
+ var rejectFunc = function(){};
26
+ var returnPromise = new Promise(function (resolve, reject) {
27
+ resolveFunc = resolve;
28
+ rejectFunc = reject;
29
+ });
30
+
24
31
  if (!callback) {
25
- callback = () => {};
32
+ callback = function (err) {
33
+ if (err) {
34
+ return rejectFunc(err);
35
+ }
36
+ resolveFunc();
37
+ };
26
38
  }
27
39
 
28
40
  if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
@@ -35,7 +47,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
35
47
 
36
48
  let i = 0;
37
49
  for (let u of adminIDs) {
38
- form[`admin_ids[${i++}]`] = u
50
+ form[`admin_ids[${i++}]`] = u;
39
51
  }
40
52
  form["add"] = adminStatus;
41
53
 
@@ -60,6 +72,8 @@ module.exports = function(defaultFuncs, bot, ctx) {
60
72
  log.error("changeAdminStatus", err);
61
73
  return callback(err);
62
74
  });
75
+
76
+ return returnPromise;
63
77
  };
64
78
  };
65
79
 
@@ -3,10 +3,22 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function(defaultFuncs, bot, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function changeArchivedStatus(threadOrThreads, archive, callback) {
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
+ var returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
+
8
15
  if (!callback) {
9
- callback = function() {};
16
+ callback = function(err) {
17
+ if (err) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc();
21
+ };
10
22
  }
11
23
 
12
24
  var form = {};
@@ -37,5 +49,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
37
49
  log.error("changeArchivedStatus", err);
38
50
  return callback(err);
39
51
  });
52
+
53
+ return returnPromise;
40
54
  };
41
55
  };
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ return function changeBio(bio, publish, callback) {
8
+ var resolveFunc = function () { };
9
+ var rejectFunc = function () { };
10
+ var returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
+
15
+ if (!callback) {
16
+ if (utils.getType(publish) == "Function" || utils.getType(publish) == "AsyncFunction") {
17
+ callback = publish;
18
+ } else {
19
+ callback = function (err) {
20
+ if (err) {
21
+ return rejectFunc(err);
22
+ }
23
+ resolveFunc();
24
+ };
25
+ }
26
+ }
27
+
28
+ if (utils.getType(publish) != "Boolean") {
29
+ publish = false;
30
+ }
31
+
32
+ if (utils.getType(bio) != "String") {
33
+ bio = "";
34
+ publish = false;
35
+ }
36
+
37
+ var form = {
38
+ fb_api_caller_class: "RelayModern",
39
+ fb_api_req_friendly_name: "ProfileCometSetBioMutation",
40
+ // This doc_is is valid as of May 23, 2020
41
+ doc_id: "2725043627607610",
42
+ variables: JSON.stringify({
43
+ input: {
44
+ bio: bio,
45
+ publish_bio_feed_story: publish,
46
+ actor_id: ctx.userID,
47
+ client_mutation_id: Math.round(Math.random() * 1024).toString()
48
+ },
49
+ hasProfileTileViewID: false,
50
+ profileTileViewID: null,
51
+ scale: 1
52
+ }),
53
+ av: ctx.userID
54
+ };
55
+
56
+ defaultFuncs
57
+ .post(
58
+ "https://www.facebook.com/api/graphql/",
59
+ ctx.jar,
60
+ form
61
+ )
62
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
63
+ .then(function (resData) {
64
+ if (resData.errors) {
65
+ throw resData;
66
+ }
67
+
68
+ return callback();
69
+ })
70
+ .catch(function (err) {
71
+ log.error("changeBio", err);
72
+ return callback(err);
73
+ });
74
+
75
+ return returnPromise;
76
+ };
77
+ };
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ return function changeBlockedStatus(userID, block, callback) {
8
+ var resolveFunc = function () { };
9
+ var rejectFunc = function () { };
10
+ var returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
+
15
+ if (!callback) {
16
+ callback = function (err) {
17
+ if (err) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc();
21
+ };
22
+ }
23
+
24
+ defaultFuncs
25
+ .post(
26
+ `https://www.facebook.com/messaging/${block ? "" : "un"}block_messages/`,
27
+ ctx.jar,
28
+ {
29
+ fbid: userID
30
+ }
31
+ )
32
+ .then(utils.saveCookies(ctx.jar))
33
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
34
+ .then(function (resData) {
35
+ if (resData.error) {
36
+ throw resData;
37
+ }
38
+
39
+ return callback();
40
+ })
41
+ .catch(function (err) {
42
+ log.error("changeBlockedStatus", err);
43
+ return callback(err);
44
+ });
45
+ return returnPromise;
46
+ };
47
+ };
@@ -4,7 +4,7 @@ var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
  var bluebird = require("bluebird");
6
6
 
7
- module.exports = function(defaultFuncs, bot, ctx) {
7
+ module.exports = function(defaultFuncs, api, ctx) {
8
8
  function handleUpload(image, callback) {
9
9
  var uploads = [];
10
10
 
@@ -52,8 +52,20 @@ module.exports = function(defaultFuncs, bot, ctx) {
52
52
  throw { error: "please pass a threadID as a second argument." };
53
53
  }
54
54
 
55
+ var resolveFunc = function(){};
56
+ var rejectFunc = function(){};
57
+ var returnPromise = new Promise(function (resolve, reject) {
58
+ resolveFunc = resolve;
59
+ rejectFunc = reject;
60
+ });
61
+
55
62
  if (!callback) {
56
- callback = function() {};
63
+ callback = function(err) {
64
+ if (err) {
65
+ return rejectFunc(err);
66
+ }
67
+ resolveFunc();
68
+ };
57
69
  }
58
70
 
59
71
  var messageAndOTID = utils.generateOfflineThreadingID();
@@ -111,5 +123,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
111
123
  return callback(err);
112
124
  });
113
125
  });
126
+
127
+ return returnPromise;
114
128
  };
115
129
  };
@@ -3,9 +3,22 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function(defaultFuncs, bot, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function changeNickname(nickname, threadID, participantID, callback) {
8
- callback = callback || function() {};
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
+ var returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
+ if (!callback) {
15
+ callback = function (err) {
16
+ if (err) {
17
+ return rejectFunc(err);
18
+ }
19
+ resolveFunc();
20
+ };
21
+ }
9
22
 
10
23
  var form = {
11
24
  nickname: nickname,
@@ -40,5 +53,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
40
53
  log.error("changeNickname", err);
41
54
  return callback(err);
42
55
  });
56
+
57
+ return returnPromise;
43
58
  };
44
59
  };
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
+ return function changeThreadColor(color, threadID, callback) {
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
+ var returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
+
15
+ if (!callback) {
16
+ callback = function(err) {
17
+ if (err) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc(err);
21
+ };
22
+ }
23
+
24
+ var validatedColor = color !== null ? color.toLowerCase() : color; // API only accepts lowercase letters in hex string
25
+ var colorList = Object.keys(api.threadColors).map(function(name) {
26
+ return api.threadColors[name];
27
+ });
28
+ if (!colorList.includes(validatedColor)) {
29
+ throw {
30
+ error:
31
+ "The color you are trying to use is not a valid thread color. Use api.threadColors to find acceptable values."
32
+ };
33
+ }
34
+
35
+ var form = {
36
+ dpr: 1,
37
+ queries: JSON.stringify({
38
+ o0: {
39
+ //This doc_id is valid as of January 31, 2020
40
+ doc_id: "1727493033983591",
41
+ query_params: {
42
+ data: {
43
+ actor_id: ctx.userID,
44
+ client_mutation_id: "0",
45
+ source: "SETTINGS",
46
+ theme_id: validatedColor,
47
+ thread_id: threadID
48
+ }
49
+ }
50
+ }
51
+ })
52
+ };
53
+
54
+ defaultFuncs
55
+ .post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
56
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
57
+ .then(function(resData) {
58
+ if (resData[resData.length - 1].error_results > 0) {
59
+ throw resData[0].o0.errors;
60
+ }
61
+
62
+ return callback();
63
+ })
64
+ .catch(function(err) {
65
+ log.error("changeThreadColor", err);
66
+ return callback(err);
67
+ });
68
+
69
+ return returnPromise;
70
+ };
71
+ };
@@ -3,10 +3,22 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function(defaultFuncs, bot, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function changeThreadEmoji(emoji, threadID, callback) {
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
+ var returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
+
8
15
  if (!callback) {
9
- callback = function() {};
16
+ callback = function(err) {
17
+ if (err) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc();
21
+ };
10
22
  }
11
23
  var form = {
12
24
  emoji_choice: emoji,
@@ -37,5 +49,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
37
49
  log.error("changeThreadEmoji", err);
38
50
  return callback(err);
39
51
  });
52
+
53
+ return returnPromise;
40
54
  };
41
55
  };
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
+ return function createNewGroup(participantIDs, groupTitle, callback) {
8
+ if (utils.getType(groupTitle) == "Function") {
9
+ callback = groupTitle;
10
+ groupTitle = null;
11
+ }
12
+
13
+ if (utils.getType(participantIDs) !== "Array") {
14
+ throw { error: "createNewGroup: participantIDs should be an array." };
15
+ }
16
+
17
+ if (participantIDs.length < 2) {
18
+ throw { error: "createNewGroup: participantIDs should have at least 2 IDs." };
19
+ }
20
+
21
+ var resolveFunc = function(){};
22
+ var rejectFunc = function(){};
23
+ var returnPromise = new Promise(function (resolve, reject) {
24
+ resolveFunc = resolve;
25
+ rejectFunc = reject;
26
+ });
27
+
28
+ if (!callback) {
29
+ callback = function (err, threadID) {
30
+ if (err) {
31
+ return rejectFunc(err);
32
+ }
33
+ resolveFunc(threadID);
34
+ };
35
+ }
36
+
37
+ var pids = [];
38
+ for (var n in participantIDs) {
39
+ pids.push({
40
+ fbid: participantIDs[n]
41
+ });
42
+ }
43
+ pids.push({fbid: ctx.userID});
44
+
45
+ var form = {
46
+ fb_api_caller_class: "RelayModern",
47
+ fb_api_req_friendly_name: "MessengerGroupCreateMutation",
48
+ av: ctx.userID,
49
+ //This doc_id is valid as of January 11th, 2020
50
+ doc_id: "577041672419534",
51
+ variables: JSON.stringify({
52
+ input: {
53
+ entry_point: "jewel_new_group",
54
+ actor_id: ctx.userID,
55
+ participants: pids,
56
+ client_mutation_id: Math.round(Math.random() * 1024).toString(),
57
+ thread_settings: {
58
+ name: groupTitle,
59
+ joinable_mode: "PRIVATE",
60
+ thread_image_fbid: null
61
+ }
62
+ }
63
+ })
64
+ };
65
+
66
+ defaultFuncs
67
+ .post(
68
+ "https://www.facebook.com/api/graphql/",
69
+ ctx.jar,
70
+ form
71
+ )
72
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
73
+ .then(function(resData) {
74
+ if (resData.errors) {
75
+ throw resData;
76
+ }
77
+ return callback(null, resData.data.messenger_group_thread_create.thread.thread_key.thread_fbid);
78
+ })
79
+ .catch(function(err) {
80
+ log.error("createNewGroup", err);
81
+ return callback(err);
82
+ });
83
+
84
+ return returnPromise;
85
+ };
86
+ };
@@ -3,13 +3,26 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function(defaultFuncs, bot, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function createPoll(title, threadID, options, callback) {
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
+ var returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
+
8
15
  if (!callback) {
9
16
  if (utils.getType(options) == "Function") {
10
17
  callback = options;
18
+ options = null;
11
19
  } else {
12
- callback = function() {};
20
+ callback = function(err) {
21
+ if (err) {
22
+ return rejectFunc(err);
23
+ }
24
+ resolveFunc();
25
+ };
13
26
  }
14
27
  }
15
28
  if (!options) {
@@ -24,6 +37,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
24
37
  // Set fields for options (and whether they are selected initially by the posting user)
25
38
  var ind = 0;
26
39
  for (var opt in options) {
40
+ // eslint-disable-next-line no-prototype-builtins
27
41
  if (options.hasOwnProperty(opt)) {
28
42
  form["option_text_array[" + ind + "]"] = opt;
29
43
  form["option_is_selected_array[" + ind + "]"] = options[opt]
@@ -51,5 +65,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
51
65
  log.error("createPoll", err);
52
66
  return callback(err);
53
67
  });
68
+
69
+ return returnPromise;
54
70
  };
55
71
  };
@@ -3,10 +3,21 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function(defaultFuncs, bot, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function deleteMessage(messageOrMessages, callback) {
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
+ var returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
8
14
  if (!callback) {
9
- callback = function() {};
15
+ callback = function(err) {
16
+ if (err) {
17
+ return rejectFunc(err);
18
+ }
19
+ resolveFunc();
20
+ };
10
21
  }
11
22
 
12
23
  var form = {
@@ -39,5 +50,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
39
50
  log.error("deleteMessage", err);
40
51
  return callback(err);
41
52
  });
53
+
54
+ return returnPromise;
42
55
  };
43
56
  };
@@ -3,10 +3,21 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function(defaultFuncs, bot, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function deleteThread(threadOrThreads, callback) {
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
+ var returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
8
14
  if (!callback) {
9
- callback = function() {};
15
+ callback = function(err) {
16
+ if (err) {
17
+ return rejectFunc(err);
18
+ }
19
+ resolveFunc();
20
+ };
10
21
  }
11
22
 
12
23
  var form = {
@@ -39,5 +50,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
39
50
  log.error("deleteThread", err);
40
51
  return callback(err);
41
52
  });
53
+
54
+ return returnPromise;
42
55
  };
43
56
  };