From 20b36c2665e86f15a8e9c9d44d613526c4e21bd3 Mon Sep 17 00:00:00 2001 From: Melvin Jones Repol Date: Wed, 3 Jan 2024 23:57:08 +0800 Subject: [PATCH] Initial Commit --- .gitignore | 4 +- data/.accountPreferences.json.swp | Bin 16384 -> 0 bytes data/accountPreferences.json | 579 +++++++++++---------- data/threadPreferences.json | 806 ++---------------------------- index.js | 248 +++++---- src/cmd.js | 7 +- 6 files changed, 451 insertions(+), 1193 deletions(-) delete mode 100644 data/.accountPreferences.json.swp diff --git a/.gitignore b/.gitignore index 36f1488e..b034d8a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ /node_modules/* /cache/* /data/cookies/* -/build/* -/data/functionRegistry.json -/data/threadRegistry.json \ No newline at end of file +/build/* \ No newline at end of file diff --git a/data/.accountPreferences.json.swp b/data/.accountPreferences.json.swp deleted file mode 100644 index 247a7023ebcfa9568f241004dd5fff2dd741c0e3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI2TWl0n7{?DHa#2LY7!yq_<0Tl~-MQ@CDjF}v2$WC}2nBU>cK2*M?C#8V<}9{g z5ir49c+f~pL_@@=!9*T>FyV!WJP{v^mngo8A<+bl@xd64LH}oV+nwER)A~eG&uM<0 zcFs5F@;~3X&g9jtYd7?`X_X*cN62UHVYd3$lAIX=x`FkP1izqyka_sen{KDj*e*3d{iocx^s;7WKHIS(kmy>%5NZ zKh1EUd4GRL{QTzsndWtVGl7Y8nz!XeDj*e*3P=T{0#X5~fK)&#AQg}bNCl({8}pbR#G6j%a&zLt=4;0$;ZjDUV{AGjS5 zaBe9fAA|S7E8rl=gY}>fWWjRq=QV_U3r>O~U^f^9HdqMGUQNge@CJAcEC!dBpbX$N zI0{|^Bd*0FHnI;3;5%8^8ka>q0^< zfKR}2a16W%La-g&4{iku!NsePA9xSE0655jd%+6u+X6y<0B6CwU>xiK{lEfugGFE- z_~}YQz5pk|TVO9JfpuUNSO9*+LCja+6nGs}!K1(hJ>YM&^Vi@b@D4Zx4uBlk1|9&y z7gm9`(9;Y`#DkjB+f$;Ih}}cPUB%K&({NNxvo*^w5xFP6Ki-IrO@gO=79vK`R8@5x zBWvqMR-dQxt5ooSI%&|wC^qB)r?SVB@hVMUT_!D3xKF7MZZ0xGLQWW?R}Uil*DH*>0u` z)p%RUlu1cirB$lb^EvY=KC*#vq7mal(>f0}(6HRcD&8&@j&(8NV>QnoTI(0R0_A~d z(#}L8Rw?y+5pqE!59>`Yi8BcNisy@*JMK?pyou3bmn2I;SYZ9Zkk=(iwu|{(G<-*r zUHnw|UKSpz>6UAl2A-M0QC;11;G~wV|8E?%y}!kc*3C=RcIS)jX6ioDLEHMmbPk#| zvWDZhs$q3?(7GQnUvv`T??ebMg3>m?+M10tvW{zKl~zN|?Ge^=bdAJXBz|=rVKrSh zTB=M~PZ|BQrt7qu$sx9VG@r(Ulit^Dh{XgVJbQeywUm%WoQ7ih+VNyd^2DE_k(6Q1 zYrUC_nvQ>Z9gOC!<-?>!1e3`xQqw~oAFk)qUXbVqaEee&7&|5l(AhIew7~K~P==9W zS-N9dj$ylZ*bf&pX6b5)+NwjfqG`ESDet;kLCY7J3CoW1P_b4}qH@X~7#JDs^LIbq z7X*c!Yu3_@gM*umhbsBUR4jdjB}U+skv3Dj9_E9TW|dQ_r5VYmyFDfDrJ8G> zl&ZGbM_#pF;nZhAJz6u$3dp5n9>%PYr+Kg9@v&T$MnZT+OJ-R^>x++mb2Y3>DqPf5 zQIiH$I@(&3DY}|OwQY?m=Hj}ZXkd4%l`q;FoW1UI6Ep)`k%5hoYW=W53 z_@@#L(~yZ_c7Os5~ttu?S5p~WDDsrs@mf{Uy~(Pd-L-9yCw ze>?WYY3!xN{y)>)^j*N-{!?%i><3k_4QSvha31^mFTqK07*xS}uo~P6ZU%o~Pyapm z4u~^=)8IHb1bna+^n#nf@7Ujqz5f|-0z40%0AlaI3M>N`QN}aiZSX3128@6Wzyc}| z^|%qpAQg}bNCl(n+a diff --git a/data/accountPreferences.json b/data/accountPreferences.json index 5a335643..ba3d0484 100644 --- a/data/accountPreferences.json +++ b/data/accountPreferences.json @@ -1,305 +1,300 @@ { - "default": { - "stop": false, - "events": true, - "forceLogin": true, - "autoMarkRead": false, - "online": true, - "selfListen": true, - "typingIndicator": false, - "autoMarkDelivery": false, - "maintenance": false, - "tokens": { - "gpt": { - "prompt_tokens": 4598, - "completion_tokens": 1223, - "total_tokens": 5821 - }, - "davinci": { - "prompt_tokens": 0, - "completion_tokens": 0, - "total_tokens": 0 - }, - "dell": 0 - }, - "owner": "100058594941918", - "unsend": true + "default": { + "stop": false, + "events": true, + "forceLogin": true, + "autoMarkRead": false, + "online": true, + "selfListen": true, + "typingIndicator": false, + "autoMarkDelivery": false, + "maintenance": false, + "tokens": { + "gpt": { + "prompt_tokens": 4598, + "completion_tokens": 1223, + "total_tokens": 5821 + }, + "davinci": { + "prompt_tokens": 0, + "completion_tokens": 0, + "total_tokens": 0 + }, + "dell": 0 }, - "shared": { - "root": "100071743848974", - "delay": false, - "frequency_penalty": "0", - "temperature": "0.5", - "max_tokens": "2048", - "presence_penalty": "0", - "probability_mass": "1", - "simultaneousExec": true, - "text_complextion": "text-davinci-003", - "primary_text_complextion": "gpt-3.5-turbo-16k-0613", - "max_image": "12", - "apikey": { - "ai": "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", - "facebook": "6628568379%7Cc1e620fa708a1d5696fb991c1bde5662" - }, - "cors": [ - "https://mrepol742.github.io", - "http://0.0.0.0:8000" - ], - "restart": [], - "pin": {} + "owner": "100058594941918" + }, + "shared": { + "root": "100071743848974", + "delay": false, + "frequency_penalty": "0", + "temperature": "0.5", + "max_tokens": "2048", + "presence_penalty": "0", + "probability_mass": "1", + "simultaneousExec": true, + "text_complextion": "text-davinci-003", + "primary_text_complextion": "gpt-3.5-turbo-16k-0613", + "max_image": "12", + "apikey": { + "ai": "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", + "facebook": "6628568379%7Cc1e620fa708a1d5696fb991c1bde5662" }, - "100071743848974": { - "stop": false, - "events": true, - "forceLogin": true, - "autoMarkRead": false, - "online": true, - "selfListen": true, - "typingIndicator": false, - "autoMarkDelivery": false, - "maintenance": false, - "tokens": { - "gpt": { - "prompt_tokens": 4598, - "completion_tokens": 1223, - "total_tokens": 5821 - }, - "davinci": { - "prompt_tokens": 0, - "completion_tokens": 0, - "total_tokens": 0 - }, - "dell": 0 - }, - "owner": "100071743848974", - "unsend": true + "cors": [ + "https://mrepol742.github.io", + "http://0.0.0.0:8000" + ], + "restart": [], + "pin": {} + }, + "100071743848974": { + "stop": false, + "events": true, + "forceLogin": true, + "autoMarkRead": false, + "online": true, + "selfListen": true, + "typingIndicator": false, + "autoMarkDelivery": false, + "maintenance": false, + "tokens": { + "gpt": { + "prompt_tokens": 4598, + "completion_tokens": 1223, + "total_tokens": 5821 + }, + "davinci": { + "prompt_tokens": 0, + "completion_tokens": 0, + "total_tokens": 0 + }, + "dell": 0 }, - "100044343889036": { - "stop": false, - "events": true, - "forceLogin": true, - "autoMarkRead": false, - "online": true, - "selfListen": true, - "typingIndicator": false, - "autoMarkDelivery": false, - "maintenance": false, - "tokens": { - "gpt": { - "prompt_tokens": 0, - "completion_tokens": 0, - "total_tokens": 0 - }, - "davinci": { - "prompt_tokens": 0, - "completion_tokens": 0, - "total_tokens": 0 - }, - "dell": 0 - }, - "owner": "100092581786728" + "owner": "100071743848974" + }, + "100044343889036": { + "stop": false, + "events": true, + "forceLogin": true, + "autoMarkRead": false, + "online": true, + "selfListen": true, + "typingIndicator": false, + "autoMarkDelivery": false, + "maintenance": false, + "tokens": { + "gpt": { + "prompt_tokens": 0, + "completion_tokens": 0, + "total_tokens": 0 + }, + "davinci": { + "prompt_tokens": 0, + "completion_tokens": 0, + "total_tokens": 0 + }, + "dell": 0 }, - "100046351269353": { - "stop": false, - "events": true, - "forceLogin": true, - "autoMarkRead": false, - "online": true, - "selfListen": true, - "typingIndicator": false, - "autoMarkDelivery": false, - "maintenance": false, - "tokens": { - "gpt": { - "prompt_tokens": 2795, - "completion_tokens": 761, - "total_tokens": 3556 - }, - "davinci": { - "prompt_tokens": 0, - "completion_tokens": 0, - "total_tokens": 0 - }, - "dell": 0 - }, - "owner": "100088347234178" + "owner": "100092581786728" + }, + "100046351269353": { + "stop": false, + "events": true, + "forceLogin": true, + "autoMarkRead": false, + "online": true, + "selfListen": true, + "typingIndicator": false, + "autoMarkDelivery": false, + "maintenance": false, + "tokens": { + "gpt": { + "prompt_tokens": 2795, + "completion_tokens": 761, + "total_tokens": 3556 + }, + "davinci": { + "prompt_tokens": 0, + "completion_tokens": 0, + "total_tokens": 0 + }, + "dell": 0 }, - "61553801171635": { - "stop": false, - "events": true, - "forceLogin": true, - "autoMarkRead": false, - "online": true, - "selfListen": true, - "typingIndicator": false, - "autoMarkDelivery": false, - "maintenance": false, - "tokens": { - "gpt": { - "prompt_tokens": 377, - "completion_tokens": 18, - "total_tokens": 395 - }, - "davinci": { - "prompt_tokens": 0, - "completion_tokens": 0, - "total_tokens": 0 - }, - "dell": 0 - }, - "owner": "100088347234178" + "owner": "100088347234178" + }, + "61553801171635": { + "stop": false, + "events": true, + "forceLogin": true, + "autoMarkRead": false, + "online": true, + "selfListen": true, + "typingIndicator": false, + "autoMarkDelivery": false, + "maintenance": false, + "tokens": { + "gpt": { + "prompt_tokens": 377, + "completion_tokens": 18, + "total_tokens": 395 + }, + "davinci": { + "prompt_tokens": 0, + "completion_tokens": 0, + "total_tokens": 0 + }, + "dell": 0 }, - "100094974786751": { - "stop": false, - "events": true, - "forceLogin": true, - "autoMarkRead": false, - "online": true, - "selfListen": true, - "typingIndicator": false, - "autoMarkDelivery": false, - "maintenance": false, - "tokens": { - "gpt": { - "prompt_tokens": 760, - "completion_tokens": 242, - "total_tokens": 1002 - }, - "davinci": { - "prompt_tokens": 0, - "completion_tokens": 0, - "total_tokens": 0 - }, - "dell": 0 - }, - "owner": "100088347234178" + "owner": "100088347234178" + }, + "100094974786751": { + "stop": false, + "events": true, + "forceLogin": true, + "autoMarkRead": false, + "online": true, + "selfListen": true, + "typingIndicator": false, + "autoMarkDelivery": false, + "maintenance": false, + "tokens": { + "gpt": { + "prompt_tokens": 760, + "completion_tokens": 242, + "total_tokens": 1002 + }, + "davinci": { + "prompt_tokens": 0, + "completion_tokens": 0, + "total_tokens": 0 + }, + "dell": 0 }, - "61553500994391": { - "stop": false, - "events": true, - "forceLogin": true, - "autoMarkRead": false, - "online": true, - "selfListen": true, - "typingIndicator": false, - "autoMarkDelivery": false, - "maintenance": false, - "tokens": { - "gpt": { - "prompt_tokens": 4598, - "completion_tokens": 1223, - "total_tokens": 5821 - }, - "davinci": { - "prompt_tokens": 0, - "completion_tokens": 0, - "total_tokens": 0 - }, - "dell": 0 - }, - "owner": "100039660703227" + "owner": "100088347234178" + }, + "61553500994391": { + "stop": false, + "events": true, + "forceLogin": true, + "autoMarkRead": false, + "online": true, + "selfListen": true, + "typingIndicator": false, + "autoMarkDelivery": false, + "maintenance": false, + "tokens": { + "gpt": { + "prompt_tokens": 4598, + "completion_tokens": 1223, + "total_tokens": 5821 + }, + "davinci": { + "prompt_tokens": 0, + "completion_tokens": 0, + "total_tokens": 0 + }, + "dell": 0 }, - "100093516094229": { - "stop": false, - "events": true, - "forceLogin": true, - "autoMarkRead": false, - "online": true, - "selfListen": true, - "typingIndicator": false, - "autoMarkDelivery": false, - "maintenance": false, - "tokens": { - "gpt": { - "prompt_tokens": 2671, - "completion_tokens": 893, - "total_tokens": 3564 - }, - "davinci": { - "prompt_tokens": 0, - "completion_tokens": 0, - "total_tokens": 0 - }, - "dell": 0 - }, - "owner": "100039660703227" + "owner": "100039660703227" + }, + "100093516094229": { + "stop": false, + "events": true, + "forceLogin": true, + "autoMarkRead": false, + "online": true, + "selfListen": true, + "typingIndicator": false, + "autoMarkDelivery": false, + "maintenance": false, + "tokens": { + "gpt": { + "prompt_tokens": 2671, + "completion_tokens": 893, + "total_tokens": 3564 + }, + "davinci": { + "prompt_tokens": 0, + "completion_tokens": 0, + "total_tokens": 0 + }, + "dell": 0 }, - "61552097663445": { - "stop": false, - "events": true, - "forceLogin": true, - "autoMarkRead": false, - "online": true, - "selfListen": true, - "typingIndicator": false, - "autoMarkDelivery": false, - "maintenance": false, - "tokens": { - "gpt": { - "prompt_tokens": 4598, - "completion_tokens": 1223, - "total_tokens": 5821 - }, - "davinci": { - "prompt_tokens": 0, - "completion_tokens": 0, - "total_tokens": 0 - }, - "dell": 0 - }, - "owner": "100058594941918", - "unsend": true + "owner": "100039660703227" + }, + "61552097663445": { + "stop": false, + "events": true, + "forceLogin": true, + "autoMarkRead": false, + "online": true, + "selfListen": true, + "typingIndicator": false, + "autoMarkDelivery": false, + "maintenance": false, + "tokens": { + "gpt": { + "prompt_tokens": 4598, + "completion_tokens": 1223, + "total_tokens": 5821 + }, + "davinci": { + "prompt_tokens": 0, + "completion_tokens": 0, + "total_tokens": 0 + }, + "dell": 0 }, - "61552734637916": { - "stop": false, - "events": true, - "forceLogin": true, - "autoMarkRead": false, - "online": true, - "selfListen": true, - "typingIndicator": false, - "autoMarkDelivery": false, - "maintenance": false, - "tokens": { - "gpt": { - "prompt_tokens": 4598, - "completion_tokens": 1223, - "total_tokens": 5821 - }, - "davinci": { - "prompt_tokens": 0, - "completion_tokens": 0, - "total_tokens": 0 - }, - "dell": 0 - }, - "owner": "100071743848974", - "unsend": true + "owner": "100058594941918" + }, + "61552734637916": { + "stop": false, + "events": true, + "forceLogin": true, + "autoMarkRead": false, + "online": true, + "selfListen": true, + "typingIndicator": false, + "autoMarkDelivery": false, + "maintenance": false, + "tokens": { + "gpt": { + "prompt_tokens": 4598, + "completion_tokens": 1223, + "total_tokens": 5821 + }, + "davinci": { + "prompt_tokens": 0, + "completion_tokens": 0, + "total_tokens": 0 + }, + "dell": 0 }, - "61550665358657": { - "stop": false, - "events": true, - "forceLogin": true, - "autoMarkRead": false, - "online": true, - "selfListen": true, - "typingIndicator": false, - "autoMarkDelivery": false, - "maintenance": false, - "tokens": { - "gpt": { - "prompt_tokens": 4598, - "completion_tokens": 1223, - "total_tokens": 5821 - }, - "davinci": { - "prompt_tokens": 0, - "completion_tokens": 0, - "total_tokens": 0 - }, - "dell": 0 - }, - "owner": "100058594941918", - "unsend": true - } + "owner": "100071743848974" + }, + "61550665358657": { + "stop": false, + "events": true, + "forceLogin": true, + "autoMarkRead": false, + "online": true, + "selfListen": true, + "typingIndicator": false, + "autoMarkDelivery": false, + "maintenance": false, + "tokens": { + "gpt": { + "prompt_tokens": 4598, + "completion_tokens": 1223, + "total_tokens": 5821 + }, + "davinci": { + "prompt_tokens": 0, + "completion_tokens": 0, + "total_tokens": 0 + }, + "dell": 0 + }, + "owner": "100058594941918" + } } \ No newline at end of file diff --git a/data/threadPreferences.json b/data/threadPreferences.json index 37263ac9..2243ee48 100644 --- a/data/threadPreferences.json +++ b/data/threadPreferences.json @@ -1,772 +1,38 @@ { - "default": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "2583856894982516": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "100071743848974", - "cmd": 2 - }, - "undefined": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100068620749509": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "9492786270746965": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "7382627011811112": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100052600903504": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100045819710001": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6892455817496558": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100016610761672": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "5737251886344292": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "7056759551011487": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "5423496241090201": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6988644451156922": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "7635291589846117": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "5976601362468709": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "24546568141608847": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "9340074936018059": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6051933531590435": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6547170845327224": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6654978497923612": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6115847185128764": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6561269570663182": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100087636143319": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "24656864413928695": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "9525562160848307": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6915158371873085": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6592573364196802": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "23998651043067607": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "10065484710159274": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100010717127140": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6034691379901917": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "5758514107520570": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "7316872308385075": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100093099606387": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6135835699850490": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "4952740554847463": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "5513474288704425": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100003989161118": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100088347234178": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "7083808724963237": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "7235614196494866": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "5949341968502700": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "4341511805878931": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100089896085964": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "7088239677916004": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "4780024218775309": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6916910508416322": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100069414780710": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6881004655325049": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "5575074482532460": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "4176244475726738": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100008917684078": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6666753816771194": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100090280604771": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100071918311154": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6894400947294774": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6633644036694813": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100093514248512": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100081554860536": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6941633829222151": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100073284881540": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100031086977581": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100037143353251": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100091144982538": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6074674555914192": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100011389484397": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100091380468145": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "4473542532764802": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "4740250299437612": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100071743848974": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "61553500994391": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100066251260470": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100081513648206": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "7279095845453124": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6286580484730503": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6932035100188064": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6590703737651032": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100058594941918": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100078295104831": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6369083263167595": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100038446933054": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100074545202820": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100081567131027": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6979602418738828": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "7280019545349908": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "2878479518898828": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100084508669874": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "5625571744167062": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100094780861981": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "24968278662770981": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "5247235148671017": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100093516094229": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "24259480750363041": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "7101842086597659": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "24466590362988093": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6443993275620604": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6856585374421040": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100027279883548": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6829220470530240": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6964079173629431": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100095604100900": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "100087639040089": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "7582386855121092": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "61552090258421": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6214415628607748": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "5317413565003899": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "61554782822811": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "6555563907889074": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - }, - "7299213156776160": { - "leave": false, - "unsend": true, - "nsfw": true, - "lock": "", - "cmd": 2 - } + "default": { + "leave": false, + "unsend": true, + "nsfw": true, + "cmd": 1 + }, + "undefined": { + "leave": false, + "unsend": true, + "nsfw": true, + "cmd": 1 + }, + "2583856894982516": { + "leave": false, + "unsend": false, + "nsfw": true, + "cmd": 4 + }, + "6892455817496558": { + "leave": false, + "unsend": true, + "nsfw": true, + "cmd": 1 + }, + "9525562160848307": { + "leave": false, + "unsend": true, + "nsfw": true, + "cmd": 1 + }, + "9492786270746965": { + "leave": false, + "unsend": true, + "nsfw": true, + "cmd": 1 + } } \ No newline at end of file diff --git a/index.js b/index.js index fc7930b4..0a4b8366 100644 --- a/index.js +++ b/index.js @@ -49,7 +49,7 @@ for (folder in folder_dir) { writeFolder(__dirname + folder_dir[folder]); } -let data_json = ["functionRegistry", "groups", "pin", "accountPreferences", "threadPreferences", "threadRegistry", "users"]; +let data_json = ["groups", "pin", "accountPreferences", "threadPreferences", "users"]; for (file in data_json) { writeFile(__dirname + "/data/" + data_json[file] + ".json", "{}"); } @@ -61,8 +61,6 @@ let settings = JSON.parse(fs.readFileSync(__dirname + "/data/accountPreferences. let settingsThread = JSON.parse(fs.readFileSync(__dirname + "/data/threadPreferences.json", "utf8")); let users = JSON.parse(fs.readFileSync(__dirname + "/data/users.json", "utf8")); let groups = JSON.parse(fs.readFileSync(__dirname + "/data/groups.json", "utf8")); -let threadRegistry = JSON.parse(fs.readFileSync(__dirname + "/data/threadRegistry.json")); -let functionRegistry = JSON.parse(fs.readFileSync(__dirname + "/data/functionRegistry.json")); let asciifonts = JSON.parse(fs.readFileSync(__dirname + "/data/ascii.json")); let dyk = JSON.parse(fs.readFileSync(__dirname + "/data/dyk.json")); let wyr = JSON.parse(fs.readFileSync(__dirname + "/data/wyr.json")); @@ -111,7 +109,6 @@ let blockedCall = []; let isCalled = true; let commandCalls = 0; -let listenStatus = 0; let crashes = 0; const pictographic = /\p{Extended_Pictographic}/gu; @@ -226,6 +223,13 @@ process.on("beforeExit", (code) => { utils.logged("process_before_exit " + code); }); +process.on("exit", (code) => { + console.log(""); + saveState(); + utils.logged("save_state "); + utils.logged("fca_status offline"); +}); + /* * INITIALIZE LOGIN */ @@ -315,19 +319,16 @@ utils.logged("task_clear global initiated"); */ function redfox_fb(fca_state, login, cb) { - redfox(fca_state, (err, api) => { + new redfox(fca_state, (err, api) => { if (err) { if (err.error && err.error == "Not logged in") { utils.logged("api_not_signin " + login); } - if (isMyId(login)) { - listenStatus = 1; - } utils.logged("api_login_error " + login); accounts = accounts.filter((item) => item !== login); - for (tR in threadRegistry) { - if (threadRegistry[tR] == login) { - delete threadRegistry[tR]; + for (threads in settingsThread) { + if (settingsThread[threads].lock == login) { + delete settingsThread[threads]; } } unlinkIfExists(__dirname + "/data/cookies/" + login + ".bin"); @@ -339,25 +340,6 @@ function redfox_fb(fca_state, login, cb) { return; } - process.on("exit", (code) => { - if (accounts.includes(api.getCurrentUserID())) { - console.log(""); - fs.writeFileSync(__dirname + "/data/cookies/" + login + ".bin", getAppState(api), "utf8"); - utils.logged("login_state " + login + " saved"); - saveState(); - utils.logged("save_state " + login); - utils.logged("fca_status " + login + " offline"); - /* - server.close(); - TODO: must be do on the last part of exit - server1.close(); - utils.logged("server_status offline"); - utils.logged("process_exit goodbye :( " + code); - utils.logged("project_orion offline"); - */ - } - }); - task( function () { fs.writeFileSync(__dirname + "/data/cookies/" + login + ".bin", getAppState(api), "utf8"); @@ -430,15 +412,12 @@ function redfox_fb(fca_state, login, cb) { api.eventListener(async (err, event) => { if (err) { - if (isMyId(login)) { - listenStatus = 1; - } // TODO: review prevent deleting of account if the api connection utils.logged("api_listen_error " + login); accounts = accounts.filter((item) => item !== login); - for (tR in threadRegistry) { - if (threadRegistry[tR] == login) { - delete threadRegistry[tR]; + for (threads in settingsThread) { + if (settingsThread[threads].lock == login) { + delete settingsThread[threads]; } } @@ -464,12 +443,12 @@ function redfox_fb(fca_state, login, cb) { settingsThread[event.threadID] = settingsThread.default; } - if (!threadRegistry[event.threadID] && !isMyId(api.getCurrentUserID())) { - threadRegistry[event.threadID] = api.getCurrentUserID(); + if (!settingsThread[event.threadID].lock && !isMyId(api.getCurrentUserID())) { + settingsThread[event.threadID].lock = api.getCurrentUserID(); utils.logged("group_register " + api.getCurrentUserID()); } - if (threadRegistry[event.threadID] && threadRegistry[event.threadID] != api.getCurrentUserID()) { + if (settingsThread[event.threadID].lock && settingsThread[event.threadID].lock != api.getCurrentUserID()) { return; } @@ -537,7 +516,7 @@ function redfox_fb(fca_state, login, cb) { } else if (testCommand(api, query, "unblock--thread", event.senderID, "owner")) { let data = input.split(" "); if (data.length < 3) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: unblockthread uid" + "\n " + example[Math.floor(Math.random() * example.length)] + " unblockthread 5000050005"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: unblock --thread uid" + "\n " + example[Math.floor(Math.random() * example.length)] + " unblock --thread 5000050005"); } else { unblockGroup(api, event, getDataFromQuery(data)); } @@ -584,16 +563,22 @@ function redfox_fb(fca_state, login, cb) { let query = query2; if (testCommand(api, query, "stop", event.senderID, "owner", true)) { + if (!settings[login].stop) { sendMessage(api, event, "Program stopped its state."); settings[login].stop = true; - return; + } else { + sendMessage(api, event, "Program is already been stopped."); + } } else if (testCommand(api, query, "destroy", event.senderID, "root", true)) { sendMessage(api, event, "Program destroyed its state."); return; } else if (testCommand(api, query, "resume", event.senderID, "owner", true)) { + if (settings[login].stop) { sendMessage(api, event, "Program resumed its state."); settings[login].stop = false; - return; + } else { + sendMessage(api, event, "Program is already been resumed."); + } } else if (testCommand(api, query, "restart", event.senderID, "root", true)) { saveState(); let rs = []; @@ -610,7 +595,9 @@ function redfox_fb(fca_state, login, cb) { return; } - if (settings[login].maintenance && !accounts.includes(event.senderID)) { + if (settings[login].maintenance && + (settings[login].owner != event.senderID && !users.admin.includes(event.senderID) && + settings.shared.root != api.getCurrentUserID())) { if (event.type == "message" || event.type == "message_reply") { if (isGoingToFast1(event, threadMaintenance, 30)) { return; @@ -703,8 +690,9 @@ function redfox_fb(fca_state, login, cb) { } d = msgs[event.messageID][0]; - if (!settings[login].unsend || users.admin.includes(event.senderID) || - settings[login].owner == event.senderID) { + if (!settingsThread[event.threadID].unsend || users.admin.includes(event.senderID) || + settings[login].owner == event.senderID || + settings.shared.root == event.senderID) { break; } @@ -751,7 +739,7 @@ function redfox_fb(fca_state, login, cb) { let file = fs.createWriteStream(filename); let fileurl = d.attachment_url.replace("https://l.facebook.com/l.php?u=", ""); let decodeurl = decodeURIComponent(fileurl); - let fileRequest = https.get(decodeurl, function (fileResponse) { + https.get(decodeurl, function (fileResponse) { fileResponse.pipe(file); file.on("finish", function () { api.getUserInfo(event.senderID, (err, data) => { @@ -890,7 +878,7 @@ function redfox_fb(fca_state, login, cb) { let time1 = utils.getTimestamp(); let filename = __dirname + "/cache/unsend_video_" + time1 + ".mp4"; let file = fs.createWriteStream(filename); - let gifRequest = https.get(d.attachment, function (gifResponse) { + https.get(d.attachment, function (gifResponse) { gifResponse.pipe(file); file.on("finish", function () { api.getUserInfo(event.senderID, (err, data) => { @@ -934,7 +922,7 @@ function redfox_fb(fca_state, login, cb) { let time2 = utils.getTimestamp(); let filename = __dirname + "/cache/unsend_audio_" + time2 + ".mp3"; let file = fs.createWriteStream(filename); - let gifRequest = https.get(d.attachment, function (gifResponse) { + https.get(d.attachment, function (gifResponse) { gifResponse.pipe(file); file.on("finish", function () { api.getUserInfo(event.senderID, (err, data) => { @@ -1239,9 +1227,9 @@ function redfox_fb(fca_state, login, cb) { if (accounts.includes(id)) { groups.active.pop(event.threadID); utils.logged("event_log_unsubsribe " + event.threadID + " ROOT " + api.getCurrentUserID()); - for (tR in threadRegistry) { - if (threadRegistry[tR] == api.getCurrentUserID()) { - delete threadRegistry[tR]; + for (threads in settingsThread) { + if (settingsThread[threads].lock == api.getCurrentUserID()) { + delete settingsThread[threads]; } } return; @@ -1258,7 +1246,7 @@ function redfox_fb(fca_state, login, cb) { sendMessage(api, event, "It's so sad to see another user of Facebook fades away."); utils.logged("event_log_unsubsribe " + event.threadID + " " + id); } else { - if (settings[login].leave && !accounts.includes(id) && !users.admin.includes(id) && settings[login].owner != event.senderID) { + if (settingsThread[event.threadID].leave && !accounts.includes(id) && !users.admin.includes(id) && settings[login].owner != event.senderID) { api.addUserToGroup(id, event.threadID, (err) => { if (err) return utils.logged(err); api.getThreadInfo(event.threadID, (err, gc) => { @@ -1479,7 +1467,7 @@ async function ai22(api, event, query, query2) { if (Array.isArray(appsss)) { let login = getUserIdFromAppState(appsss); if (login) { - let login = appsss[item].value; + const login = appsss[item].value; settings[login] = settings.default; let dirp = __dirname + "/cache/add_instance_" + utils.getTimestamp() + ".jpg"; if (accounts.includes(login)) { @@ -1500,7 +1488,7 @@ async function ai22(api, event, query, query2) { unLink(dirp); }); } else { - utils.logged("adding_root " + login); + utils.logged("adding_account " + login); sendMessage(api, event, "Login initiated for user id " + login + "."); redfox_fb( { @@ -1539,21 +1527,31 @@ async function ai22(api, event, query, query2) { if (users.blocked.includes(login)) { users.blocked = users.blocked.filter((item) => item !== login); + utils.logged("rem_block_user " + login); + sendMessageOnly(api, event, "You've been unblocked!"); } if (users.bot.includes(login)) { users.bot = users.bot.filter((item) => item !== login); + utils.logged("rem_block_bot " + login); + sendMessageOnly(api, event, "You've been unblocked!"); } if (users.admin.includes(event.senderID)) { users.admin = users.admin.filter((item) => item !== event.senderID); + utils.logged("rem_sender_admin " + login); + sendMessage(api, event, "Your admin previliges has been revoke!"); } if (users.admin.includes(login)) { users.admin = users.admin.filter((item) => item !== login); + utils.logged("rem_login_adminn " + login); + sendMessageOnly(api, event, "Your admin previliges has been revoke!"); } settings[login].owner = event.senderID; + + utils.logged("set_owner " + login + " to " + event.senderID); saveState(); } @@ -1819,7 +1817,7 @@ async function ai(api, event) { } let data = input.split(" "); if (data.length < 3) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: search --dnt text" + "\n " + example[Math.floor(Math.random() * example.length)] + " searchincog Who is Melvin Jones Repol"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: search --dnt text" + "\n " + example[Math.floor(Math.random() * example.length)] + " search --dnt project orion"); } else { let query = getDataFromQuery(data); getResponseData("https://api.duckduckgo.com/?q=" + query + "&format=json&pretty=1").then((response) => { @@ -2293,9 +2291,9 @@ async function ai(api, event) { let login = api.getCurrentUserID(); api.removeUserFromGroup(login, event.threadID, (err) => { if (err) return utils.logged(err); - for (tR in threadRegistry) { - if (threadRegistry[tR] == login) { - delete threadRegistry[tR]; + for (threads in settingsThread) { + if (settingsThread[threads].lock == login) { + delete settingsThread[threads]; } } }); @@ -2303,14 +2301,14 @@ async function ai(api, event) { api.logout((err) => { if (err) utils.logged(err); }); - } else if (testCommand(api, query, "maintenance--on", event.senderID, "root", true)) { + } else if (testCommand(api, query, "maintenance--on", event.senderID, "owner", true)) { if (settings[login].maintenance) { sendMessage(api, event, "It's already enabled."); } else { settings[login].maintenance = true; sendMessage(api, event, "Maintenance status has been enabled."); } - } else if (testCommand(api, query, "maintenance--off", event.senderID, "root", true)) { + } else if (testCommand(api, query, "maintenance--off", event.senderID, "owner", true)) { if (settings[login].maintenance) { settings[login].maintenance = false; sendMessage(api, event, "Maintenance status has been disabled."); @@ -2428,12 +2426,12 @@ async function ai(api, event) { return; } let data = input.split(" "); - if (data.length < 2) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: sayjap text" + "\n " + example[Math.floor(Math.random() * example.length)] + " sayjap I am melvin jones repol"); + if (data.length < 3) { + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: say --jap text" + "\n " + example[Math.floor(Math.random() * example.length)] + " say --jap project orion is cool"); } else { try { - data.shift(); - let text = data.join(" ").substring(0, 150) + "..."; + let query = getDataFromQuery(data); + let text = query.substring(0, 150) + "..."; let responses = "https://texttospeech.responsivevoice.org/v1/text:synthesize?text=" + encodeURIComponent(text) + "&lang=ja&engine=g1&rate=0.5&key=9zqZlnIm&gender=female&pitch=0.5&volume=1"; let time = utils.getTimestamp(); var file = fs.createWriteStream(__dirname + "/cache/ttsjap_" + time + ".mp3"); @@ -2481,7 +2479,7 @@ async function ai(api, event) { } let data = input.split(" "); if (data.length < 3) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: aes --encrypt text" + "\n " + example[Math.floor(Math.random() * example.length)] + " encrypt Hello World"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: aes --encrypt text" + "\n " + example[Math.floor(Math.random() * example.length)] + " aes --encrypt Hello World"); } else { const key = crypto.randomBytes(32); const iv = crypto.randomBytes(16); @@ -2544,7 +2542,7 @@ async function ai(api, event) { } let data = input.split(" "); if (data.length < 3) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: rascii text" + "\n " + example[Math.floor(Math.random() * example.length)] + " ascii hello world"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: ascii --random text" + "\n " + example[Math.floor(Math.random() * example.length)] + " ascii --random hello world"); } else { let font = asciifonts[Math.floor(Math.random() * asciifonts.length)]; exec("cd src/ascii && figlet -f " + font + " " + getDataFromQuery(data), function (err, stdout, stderr) { @@ -2825,7 +2823,7 @@ async function ai(api, event) { } let data = input.split(" "); if (data.length < 3) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: video --lyric text" + "\n " + example[Math.floor(Math.random() * example.length)] + " videolyric In The End by Linkin Park"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: video --lyric text" + "\n " + example[Math.floor(Math.random() * example.length)] + " video --lyric hello world"); } else { if (!threadIdMV[event.threadID] || threadIdMV[event.threadID] == true) { let qsearch = getDataFromQuery(data); @@ -2933,7 +2931,7 @@ async function ai(api, event) { } let data = input.split(" "); if (data.length < 3) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: music --lyric text" + "\n " + example[Math.floor(Math.random() * example.length)] + " musiclyric In The End by Linkin Park"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: music --lyric text" + "\n " + example[Math.floor(Math.random() * example.length)] + " music --lyric hello world"); } else { if (!threadIdMV[event.threadID] || threadIdMV[event.threadID] == true) { let qsearch = getDataFromQuery(data); @@ -3071,7 +3069,7 @@ async function ai(api, event) { } let data = input.split(" "); if (data.length < 3) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: binary --encode text" + "\n " + example[Math.floor(Math.random() * example.length)] + " encodeBinary fundamentals in engineering"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: binary --encode text" + "\n " + example[Math.floor(Math.random() * example.length)] + " binary --encode hello world"); } else { let Input = getDataFromQuery(data); let output = ""; @@ -3087,7 +3085,7 @@ async function ai(api, event) { } let data = input.split(" "); if (data.length < 3) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: binary --decode text" + "\n " + example[Math.floor(Math.random() * example.length)] + " decodeBinary 01100001 01100010 01100011"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: binary --decode text" + "\n " + example[Math.floor(Math.random() * example.length)] + " binary --decode 0110100001101001"); } else { let binary = getDataFromQuery(data); const binaryString = binary.split(" "); @@ -3104,7 +3102,7 @@ async function ai(api, event) { } let data = input.split(" "); if (data.length < 3) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: base64 --encode text" + "\n " + example[Math.floor(Math.random() * example.length)] + " base64 --encode fundamentals in engineering"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: base64 --encode text" + "\n " + example[Math.floor(Math.random() * example.length)] + " base64 --encode hello world"); } else { let buff = Buffer.from(getDataFromQuery(data)); let base64data = buff.toString("base64"); @@ -3115,8 +3113,8 @@ async function ai(api, event) { return; } let data = input.split(" "); - if (data.length < 2) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: base64 --decode text" + "\n " + example[Math.floor(Math.random() * example.length)] + " base64 --decode ZnVuZGFtZW50YWxzIGluIGVuZ2luZWVyaW5n"); + if (data.length < 3) { + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: base64 --decode text" + "\n " + example[Math.floor(Math.random() * example.length)] + " base64 --decode aGVsbG8gd29ybGQ"); } else { let buff = Buffer.from(getDataFromQuery(data), "base64"); let base642text = buff.toString("ascii"); @@ -3128,7 +3126,7 @@ async function ai(api, event) { } let data = input.split(" "); if (data.length < 2) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: reverseText text" + "\n " + example[Math.floor(Math.random() * example.length)] + " reversetext fundamentals in engineering"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: reverseText text" + "\n " + example[Math.floor(Math.random() * example.length)] + " reverseText hello world"); } else { data.shift(); let splitString = data.join(" ").split(""); @@ -3876,7 +3874,7 @@ async function ai(api, event) { } let data = input.split(" "); if (data.length < 3) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: thread --emoji emoji" + "\n " + example[Math.floor(Math.random() * example.length)] + " gemoji šŸ˜‚"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: thread --emoji emoji" + "\n " + example[Math.floor(Math.random() * example.length)] + " thread --emoji šŸ˜‚"); } else { let d = getDataFromQuery(data); if (!pictographic.test(d)) { @@ -4001,7 +3999,7 @@ async function ai(api, event) { } else if (testCommand(api, query2, "cors--add", event.senderID, "root")) { let data = input.split(" "); if (data.length < 3) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: cors -add url" + "\n " + example[Math.floor(Math.random() * example.length)] + " addCORS https://mrepol742.github.io"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: cors --add url" + "\n " + example[Math.floor(Math.random() * example.length)] + " cors --add https://mrepol742.github.io"); } else { let cors = getDataFromQuery(data); if (settings.shared.cors.includes(cors)) { @@ -4013,10 +4011,10 @@ async function ai(api, event) { sendMessage(api, event, cors + " authorized!"); } } - } else if (testCommand(api, query2, "cors--del", event.senderID, "root")) { + } else if (testCommand(api, query2, "cors--rem", event.senderID, "root")) { let data = input.split(" "); if (data.length < 3) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: cors --del url" + "\n " + example[Math.floor(Math.random() * example.length)] + " remCORS https://mrepol742.github.io"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: cors --rem url" + "\n " + example[Math.floor(Math.random() * example.length)] + " cors --rem https://mrepol742.github.io"); } else { let cors = getDataFromQuery(data); if (settings.shared.cors.includes(cors)) { @@ -4031,7 +4029,7 @@ async function ai(api, event) { } else if (testCommand(api, query2, "changeBio", event.senderID, "root")) { let data = input.split(" "); if (data.length < 2) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: changeBio text" + "\n " + example[Math.floor(Math.random() * example.length)] + " changebio Hello There"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: changeBio text" + "\n " + example[Math.floor(Math.random() * example.length)] + " changebio hello world"); } else { data.shift(); let num = data.join(" "); @@ -4043,7 +4041,7 @@ async function ai(api, event) { } else if (testCommand(api, query2, "handleFriendRequest", event.senderID, "root")) { let data = input.split(" "); if (data.length < 2) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: handleFriendRequest uid" + "\n " + example[Math.floor(Math.random() * example.length)] + " acceptfriendrequest 0000000000000"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: handleFriendRequest uid" + "\n " + example[Math.floor(Math.random() * example.length)] + " handleFriendRequest 0000000000000"); } else { data.shift(); let num = data.join(" "); @@ -4059,7 +4057,7 @@ async function ai(api, event) { } else if (testCommand(api, query2, "maxTokens", event.senderID, "root")) { let data = input.split(" "); if (data.length < 2) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: setMaxTokens int" + "\n " + example[Math.floor(Math.random() * example.length)] + " setMaxTokens 1000."); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: maxTokens int" + "\n " + example[Math.floor(Math.random() * example.length)] + " maxTokens 1000"); } else { data.shift(); let num = data.join(" "); @@ -4075,7 +4073,7 @@ async function ai(api, event) { } else if (testCommand(api, query2, "temperature", event.senderID, "root")) { let data = input.split(" "); if (data.length < 2) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: setTemperature int" + "\n " + example[Math.floor(Math.random() * example.length)] + " setTemperature 0."); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: temperature int" + "\n " + example[Math.floor(Math.random() * example.length)] + " temperature 0"); } else { data.shift(); let num = data.join(" "); @@ -4234,11 +4232,10 @@ async function ai(api, event) { } }); } - } else if (testCommand(api, query2, "owner--set", event.senderID, "root", true)) { } else if (testCommand(api, query2, "penalty--frequency", event.senderID, "root")) { let data = input.split(" "); if (data.length < 2) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: penalty --frequency int" + "\n " + example[Math.floor(Math.random() * example.length)] + " penalty --frequency 1."); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: penalty --frequency int" + "\n " + example[Math.floor(Math.random() * example.length)] + " penalty --frequency 1"); } else { let num = getDataFromQuery(data); if (num > 2) { @@ -4253,7 +4250,7 @@ async function ai(api, event) { } else if (testCommand(api, query2, "penalty--presence", event.senderID, "root")) { let data = input.split(" "); if (data.length < 2) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: penalty --presence int" + "\n " + example[Math.floor(Math.random() * example.length)] + " penalty --presence 1."); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: penalty --presence int" + "\n " + example[Math.floor(Math.random() * example.length)] + " penalty --presence 1"); } else { let num = getDataFromQuery(data); if (num > 2) { @@ -4268,7 +4265,7 @@ async function ai(api, event) { } else if (testCommand(api, query2, "textComplextion", event.senderID, "root")) { let data = input.split(" "); if (data.length < 2) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: presencePenalty int" + "\n " + example[Math.floor(Math.random() * example.length)] + " setPresencePenalty 1."); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: textComplextion type" + "\n " + example[Math.floor(Math.random() * example.length)] + " textComplextion text-davinci-003"); } else { data.shift(); let num = data.join(" "); @@ -4278,7 +4275,7 @@ async function ai(api, event) { } else if (testCommand(api, query2, "maxImage", event.senderID, "root")) { let data = input.split(" "); if (data.length < 2) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: presencePenalty int" + "\n " + example[Math.floor(Math.random() * example.length)] + " setPresencePenalty 1."); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: maxImage int" + "\n " + example[Math.floor(Math.random() * example.length)] + " maxImage 12"); } else { data.shift(); let num = data.join(" "); @@ -4294,7 +4291,7 @@ async function ai(api, event) { } else if (testCommand(api, query2, "probabilityMass", event.senderID, "root")) { let data = input.split(" "); if (data.length < 2) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: setProbabilityMass int" + "\n " + example[Math.floor(Math.random() * example.length)] + " setProbabilityMass 0.1."); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: probabilityMass int" + "\n " + example[Math.floor(Math.random() * example.length)] + " probabilityMass 0.1"); } else { data.shift(); let num = data.join(" "); @@ -4310,7 +4307,7 @@ async function ai(api, event) { } else if (testCommand(api, query2, "add--user", event.senderID)) { let data = input.split(" "); if (data.length < 3) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: add --user uid" + "\n " + example[Math.floor(Math.random() * example.length)] + " addUser 100024563636366"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: add --user uid" + "\n " + example[Math.floor(Math.random() * example.length)] + " add --user 100024563636366"); } else { let pref = getDataFromQuery(data); if (pref.split("").length >= 15) { @@ -4331,10 +4328,10 @@ async function ai(api, event) { } }); } else { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: addUser uid" + "\n " + example[Math.floor(Math.random() * example.length)] + " addUser 100024563636366"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: add --user uid" + "\n " + example[Math.floor(Math.random() * example.length)] + " add --user 100024563636366"); } } else { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: addUser uid" + "\n " + example[Math.floor(Math.random() * example.length)] + " addUser 100024563636366"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: add --user uid" + "\n " + example[Math.floor(Math.random() * example.length)] + " add --user 100024563636366"); } } } else if (testCommand(api, query2, "thread--theme", event.senderID)) { @@ -4359,7 +4356,7 @@ async function ai(api, event) { } }); } else { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: threadColor theme" + "\n " + example[Math.floor(Math.random() * example.length)] + " gcolor DefaultBlue"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: thread --theme type" + "\n " + example[Math.floor(Math.random() * example.length)] + " thread --theme type"); } } } else if (testCommand(api, query2, "remove--user", event.senderID, "owner")) { @@ -4468,7 +4465,7 @@ async function ai(api, event) { } else if (testCommand(api, query2, "block--thread--tid", event.senderID, "owner")) { let data = input.split(" "); if (data.length < 2) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: block --thread --tid tid" + "\n " + example[Math.floor(Math.random() * example.length)] + " block --thread --tid 5000050005"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: block --thread --tid groupid" + "\n " + example[Math.floor(Math.random() * example.length)] + " block --thread --tid 5000050005"); } else { blockGroup(api, event, getDataFromQuery(data, [0, 2])); } @@ -4505,7 +4502,7 @@ async function ai(api, event) { } unblockUser(api, event, id); } - } else if (testCommand(api, query2, "setKey", event.senderID, "owner")) { + } else if (testCommand(api, query2, "setKey", event.senderID, "admin")) { let data = input.split(" "); if (data.length < 2 && !data[1].includes(":")) { sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: setKey name:key instead."); @@ -4643,29 +4640,29 @@ async function ai(api, event) { remAdmin(api, event, id); } } else if (testCommand(api, query, "unsend--on", event.senderID, "owner", true)) { - if (settings[login].unsend) { + if (settingsThread[event.threadID].unsend) { sendMessage(api, event, "It's already enabled."); } else { - settings[login].unsend = true; + settingsThread[event.threadID].unsend = true; sendMessage(api, event, "Resending of unsend messages and attachments are now enabled."); } } else if (testCommand(api, query, "unsend--off", event.senderID, "owner", true)) { - if (settings[login].unsend) { - settings[login].unsend = false; + if (settingsThread[event.threadID].unsend) { + settingsThread[event.threadID].unsend = false; sendMessage(api, event, "Resending of unsend messages and attachments is been disabled."); } else { sendMessage(api, event, "It's already disabled."); } } else if (testCommand(api, query, "leave--on", event.senderID, "owner", true)) { - if (settings[login].leave) { + if (settingsThread[event.threadID].leave) { sendMessage(api, event, "It's already enabled."); } else { - settings[login].leave = true; + settingsThread[event.threadID].leave = true; sendMessage(api, event, "Readding of user who left is now enabled."); } } else if (testCommand(api, query, "leave--off", event.senderID, "owner", true)) { - if (settings[login].leave) { - settings[login].leave = false; + if (settingsThread[event.threadID].leave) { + settingsThread[event.threadID].leave = false; sendMessage(api, event, "Readding of user who left is been disabled."); } else { sendMessage(api, event, "It's already disabled."); @@ -4685,15 +4682,15 @@ async function ai(api, event) { sendMessage(api, event, "It's already disabled."); } } else if (testCommand(api, query, "nsfw--on", event.senderID, "owner", true)) { - if (settings[login].nsfw) { + if (settingsThread[event.threadID].nsfw) { sendMessage(api, event, "It's already enabled."); } else { - settings[login].nsfw = true; + settingsThread[event.threadID].nsfw = true; sendMessage(api, event, "Not Safe For Work are now enabled."); } } else if (testCommand(api, query, "nsfw--off", event.senderID, "owner", true)) { - if (settings[login].nsfw) { - settings[login].nsfw = false; + if (settingsThread[event.threadID].nsfw) { + settingsThread[event.threadID].nsfw = false; sendMessage(api, event, "Not Safe For Work is been disabled."); } else { sendMessage(api, event, "It's already disabled."); @@ -4863,20 +4860,24 @@ async function ai(api, event) { } let data = input.split(" "); if (data[1] == "next") { - if (cmdPage["help" + (functionRegistry[event.threadID] + 1)]) { - sendMessage(api, event, formatGen(cmdPage["help" + functionRegistry[event.threadID]])); - functionRegistry[event.threadID] = functionRegistry[event.threadID] + 1; + if (cmdPage["help" + (settingsThread[event.threadID].cmd++)]) { + sendMessage(api, event, formatGen(cmdPage["help" + (settingsThread[event.threadID].cmd++)])); + settingsThread[event.threadID].cmd++; } else { sendMessage(api, event, formatGen(cmdPage["help1"])); - functionRegistry[event.threadID] = 1; + settingsThread[event.threadID].cmd = 1; } + } else if (data[1] == "admin") { + sendMessage(api, event, formatGen(cmdPage["admin"])); } else if (data[1] == "owner") { sendMessage(api, event, formatGen(cmdPage["owner"])); } else if (data[1] == "root") { sendMessage(api, event, formatGen(cmdPage["root"])); + } else if (data.length >= 2) { + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: cmd option \n Options: \n next, admin, owner, root" + "\n " + example[Math.floor(Math.random() * example.length)] + " cmd next"); } else { sendMessage(api, event, formatGen(cmdPage["help1"])); - functionRegistry[event.threadID] = 1; + settingsThread[event.threadID].cmd = 1; } } else if (testCommand(api, query2, "wiki", event.senderID)) { if (isGoingToFast(api, event)) { @@ -5056,19 +5057,19 @@ async function ai(api, event) { sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: ship @mention @mention" + "\n " + example[Math.floor(Math.random() * example.length)] + " ship @Edogawa Conan @Ran Mouri"); } } - } else if (testCommand(api, query2, "whoWouldWin", event.senderID)) { + } else if (testCommand(api, query2, "1v1", event.senderID)) { if (isGoingToFast(api, event)) { return; } let data = input.split(" "); if (data.length < 2) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: www @mention @mention" + "\n " + example[Math.floor(Math.random() * example.length)] + " www @Edogawa Conan @Ran Mouri"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: 1v1 @mention @mention" + "\n " + example[Math.floor(Math.random() * example.length)] + " 1v1 @Edogawa Conan @Ran Mouri"); } else { if (input.split("@").length - 1 >= 2) { let id1 = Object.keys(event.mentions)[0]; let id2 = Object.keys(event.mentions)[1]; if (!id1 || !id2) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: www @mention @mention" + "\n " + example[Math.floor(Math.random() * example.length)] + " www @Edogawa Conan @Ran Mouri"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: 1v1 @mention @mention" + "\n " + example[Math.floor(Math.random() * example.length)] + " 1v1 @Edogawa Conan @Ran Mouri"); return; } if (isMyId(id1)) { @@ -5303,7 +5304,7 @@ async function ai(api, event) { attachment: fs.createReadStream(__dirname + "/src/web/barrier.jpg"), }; sendMessage(api, event, message); - } else if (testCommand(api, query, "didYouKnow", event.senderID, "user", true)) { + } else if (testCommand(api, query, "dyk", event.senderID, "user", true)) { if (isGoingToFast(api, event)) { return; } @@ -5603,15 +5604,14 @@ async function ai(api, event) { return; } let data = input.split(" "); - if (data.length < 2) { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: time --timezone tmz" + "\n " + example[Math.floor(Math.random() * example.length)] + " time Asia/Manila"); + if (data.length < 3) { + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: time --timezone tmz" + "\n " + example[Math.floor(Math.random() * example.length)] + " time --timezone Asia/Manila"); } else { - data.shift(); - let body = data.join(" "); + let body = getDataFromQuery(data); if (isValidTimeZone(body)) { sendMessage(api, event, "It's " + getCurrentDateAndTime(body)); } else { - sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: time --timezone tmz" + "\n " + example[Math.floor(Math.random() * example.length)] + " time Asia/Manila"); + sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: time --timezone tmz" + "\n " + example[Math.floor(Math.random() * example.length)] + " time --timezone Asia/Manila"); } } } else if (testCommand(api, query, "time", event.senderID, "user", true)) { @@ -6422,7 +6422,7 @@ function isItBotOrNot(api, event) { .replace(/\p{Diacritic}/gu, "") .toLowerCase() ) && - !settings[login].nsfw && + !settingsThread[event.threadID].nsfw && !users.admin.includes(id) && settings[login].owner != event.senderID) || (input.trim().length > 5 && event.attachments.length != 0 && eventTypes.includes(event.attachments[0].type)) @@ -7831,10 +7831,8 @@ function findPrefix(event, id) { function saveState() { fs.writeFileSync(__dirname + "/data/users.json", JSON.stringify(users), "utf8"); fs.writeFileSync(__dirname + "/data/groups.json", JSON.stringify(groups), "utf8"); - fs.writeFileSync(__dirname + "/data/accountPreferences.json", JSON.stringify(settings, null, 4), "utf8"); - fs.writeFileSync(__dirname + "/data/threadPreferences.json", JSON.stringify(settingsThread, null, 4), "utf8"); - fs.writeFileSync(__dirname + "/data/threadRegistry.json", JSON.stringify(threadRegistry), "utf8"); - fs.writeFileSync(__dirname + "/data/functionRegistry.json", JSON.stringify(functionRegistry), "utf8"); + fs.writeFileSync(__dirname + "/data/accountPreferences.json", JSON.stringify(settings, null, 2), "utf8"); + fs.writeFileSync(__dirname + "/data/threadPreferences.json", JSON.stringify(settingsThread, null, 2), "utf8"); } function getIdFromUrl(url) { diff --git a/src/cmd.js b/src/cmd.js index c030a71e..cd35f132 100644 --- a/src/cmd.js +++ b/src/cmd.js @@ -24,7 +24,7 @@ function gen() { let query = commands[cmd].replace("testCommand(", "").replace(")", ""); query = query.replaceAll('"', "").replaceAll("--", " --").split(", "); - query[2] = " " + query[2]; + query[2] = query[2]; let permission = query[4]; if (["root", "owner"].includes(permission)) { @@ -53,10 +53,11 @@ function gen() { } function formatGen(gen) { - let strs = "usage: command