Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mrepol742 committed Oct 29, 2023
1 parent 2f2d89f commit efcf238
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 46 deletions.
2 changes: 1 addition & 1 deletion data/groups.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/threadRegistry.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"6942091245864108":"100046351269353","5350108661763818":"100046351269353","5949341968502700":"100046351269353","2878479518898828":"100046351269353","5244333662266311":"100046351269353","4740250299437612":"100046351269353","4176244475726738":"100046351269353","4336522313142140":"100046351269353","6135835699850490":"100046351269353","4952740554847463":"100046351269353","4341511805878931":"100046351269353","7316872308385075":"100046351269353","5513474288704425":"100046351269353","5590956881021860":"61552097663445","5830912790266926":"61552097663445","5625571744167062":"61552097663445","6941633829222151":"100046351269353","4780024218775309":"100046351269353","5716906455022335":"61552097663445","6500248430016345":"100046351269353","2648198631946501":"100046351269353","5819745318103902":"100046351269353","6979602418738828":"100090310787624","100083636212708":"100090310787624","6690265194425701":"61552986357569","100071743848974":"61552986357569","5247235148671017":"100046351269353","7545716242111925":"61552986357569","100012473326813":"100090310787624","100001534820288":"100090310787624","7280019545349908":"100090310787624","100067569453633":"100090310787624","6826808117385638":"100094974786751","7337842006232100":"100094974786751","7187061687980690":"100094974786751","6355522137897384":"100094974786751","6592391314175900":"100094974786751","6532804480164271":"100094974786751","6912693882086217":"100094974786751","5737251886344292":"100094974786751","6192856430740953":"100094974786751","6497942856935606":"100094461741905","7814058252001681":"100094974786751","6544036575639733":"100094461741905","6993532987332635":"100094974786751","6631405486895419":"100094461741905","6122096641161833":"100094461741905","6991499640878197":"100094461741905","5520730428046386":"100094461741905","6686512711387774":"100094974786751","5414594278657634":"100094974786751","8469173389820065":"100094461741905","6922261051117174":"100094974786751","6435459373229282":"100094974786751","100091326055531":"100094461741905","9863235503746353":"100094461741905","5939225819460577":"100094974786751","6309082215796327":"100094461741905"}
{}
2 changes: 1 addition & 1 deletion data/users.json

Large diffs are not rendered by default.

96 changes: 55 additions & 41 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
const utils = require("./src/redfox/utils.js");
const redfox = require("./src/redfox");
const welcomejs = require("./src/welcome.js");
const cleanjs = require("./src/clean.js");
const { exec } = require("child_process");
const fs = require("fs");

Expand Down Expand Up @@ -130,7 +131,7 @@ utils.logged("server_cert loaded");
const server = https.createServer(options2, getRoutes());
*/
const PORT = 8080;
const HOST = "0.0.0.0";
const HOST = "127.0.0.1";

const server1 = http.createServer(getRoutes()).listen(PORT, () => {
utils.logged("server_running http://localhost:" + PORT);
Expand Down Expand Up @@ -500,6 +501,11 @@ function redfox_fb(fca_state, login, cb) {
}
}

if (threadRegistry[event.threadID] === undefined && api.getCurrentUserID() != rootAccess) {
threadRegistry[event.threadID] = api.getCurrentUserID();
utils.logged("group_register " + api.getCurrentUserID());
}

if (!(threadRegistry[event.threadID] === undefined) && threadRegistry[event.threadID] != api.getCurrentUserID()) {
return;
}
Expand Down Expand Up @@ -646,14 +652,6 @@ function redfox_fb(fca_state, login, cb) {
return;
}

if (threadRegistry[event.threadID] === undefined && api.getCurrentUserID() != rootAccess) {
threadRegistry[event.threadID] = api.getCurrentUserID();
utils.logged("group_register " + api.getCurrentUserID());
if (!(threadRegistry[event.threadID] === undefined) && threadRegistry[event.threadID] != api.getCurrentUserID()) {
return;
}
}

if (settings.preference.isDebugEnabled && !accounts.includes(event.senderID)) {
if (event.type == "message" || event.type == "message_reply") {
if (isGoingToFast1(event, threadMaintenance, 30)) {
Expand Down Expand Up @@ -2748,7 +2746,7 @@ async function ai(api, event) {
let com = stderr.replace(/\s+/g, "");
if (com == "") {
traceroute["/" + aa] = stdout;
let urll = "http:/50.253.118.57:8080/" + aa;
let urll = "http://50.253.118.57:8080/" + aa;
let message = {
body: "The result is located on our site at " + urll,
url: urll,
Expand Down Expand Up @@ -4740,6 +4738,22 @@ async function ai(api, event) {
fontIgnore(api, event, id);
}
}
} else if (query.startsWith("cleandata")) {
if (isMyId(event.senderID)) {
synchronized(groups) {
let a = await cleanjs.do(groups);
if (a != null) {
groups = a;
}
}
synchronized(users) {
let a1 = await cleanjs.do(users);
if (a1 != null) {
users = a1;
}
}
sendMessage(api, event, "Cleaning done.");
}
} else if (query.startsWith("addadmin")) {
if (isMyId(event.senderID)) {
let data = input.split(" ");
Expand Down Expand Up @@ -4961,7 +4975,7 @@ async function ai(api, event) {
sendMessage(api, event, "Unfortunately this is a personal chat and not a group chat.");
}
});
} else if (query.startsWith("_ginfo")) {
} else if (query.startsWith("ginfo")) {
if (isGoingToFast(api, event)) {
return;
}
Expand Down Expand Up @@ -5021,7 +5035,7 @@ async function ai(api, event) {
color: a.color,
};

let urll = "http:/50.253.118.57:8080/" + event.threadID;
let urll = "http://50.253.118.57:8080/" + event.threadID;
let message = {
body: "This group information can be see at " + urll,
url: urll,
Expand Down Expand Up @@ -5097,19 +5111,7 @@ async function ai(api, event) {
}
let cdd = {};
let data = input.split(" ");
if (data.length < 2 || functionRegistry[event.threadID] === undefined) {
getUserProfile(event.senderID, async function (name) {
let aa = "";
if (name.firstName != undefined) {
aa = name.firstName;
} else {
aa = "there";
}
cdd["body"] = help.replace("%USER%", aa);
sendMessage(api, event, cdd);
functionRegistry[event.threadID] = 1;
});
} else if (data[1] == "next") {
if (data[1] == "next") {
getUserProfile(event.senderID, async function (name) {
let aa = "";
if (name.firstName != undefined) {
Expand All @@ -5121,47 +5123,47 @@ async function ai(api, event) {
switch (functionRegistry[event.threadID]) {
default:
case 0:
cdd["body"] = help.replace("%USER%", aa);
cdd["body"] = help.replaceAll("%USER%", aa);
sendMessage(api, event, cdd);
functionRegistry[event.threadID] = 1;
break;
case 1:
cdd["body"] = help1.replace("%USER%", aa);
cdd["body"] = help1.replaceAll("%USER%", aa);
sendMessage(api, event, cdd);
functionRegistry[event.threadID] = 2;
break;
case 2:
cdd["body"] = help2.replace("%USER%", aa);
cdd["body"] = help2.replaceAll("%USER%", aa);
sendMessage(api, event, cdd);
functionRegistry[event.threadID] = 3;
break;
case 3:
cdd["body"] = help3.replace("%USER%", aa);
cdd["body"] = help3.replaceAll("%USER%", aa);
sendMessage(api, event, cdd);
functionRegistry[event.threadID] = 4;
break;
case 4:
cdd["body"] = help4.replace("%USER%", aa);
cdd["body"] = help4.replaceAll("%USER%", aa);
sendMessage(api, event, cdd);
functionRegistry[event.threadID] = 5;
break;
case 5:
cdd["body"] = help5.replace("%USER%", aa);
cdd["body"] = help5.replaceAll("%USER%", aa);
sendMessage(api, event, cdd);
functionRegistry[event.threadID] = 6;
break;
case 6:
cdd["body"] = help6.replace("%USER%", aa);
cdd["body"] = help6.replaceAll("%USER%", aa);
sendMessage(api, event, cdd);
functionRegistry[event.threadID] = 7;
break;
case 7:
cdd["body"] = help7.replace("%USER%", aa);
cdd["body"] = help7.replaceAll("%USER%", aa);
sendMessage(api, event, cdd);
functionRegistry[event.threadID] = 8;
break;
case 8:
cdd["body"] = help8.replace("%USER%", aa);
cdd["body"] = help8.replaceAll("%USER%", aa);
sendMessage(api, event, cdd);
functionRegistry[event.threadID] = 0;
break;
Expand All @@ -5175,7 +5177,7 @@ async function ai(api, event) {
} else {
aa = "there";
}
cdd["body"] = helpadmin.replace("%USER%", aa);
cdd["body"] = helpadmin.replaceAll("%USER%", aa);
sendMessage(api, event, cdd);
});
} else if (data[1] == "root") {
Expand All @@ -5186,7 +5188,7 @@ async function ai(api, event) {
} else {
aa = "there";
}
cdd["body"] = helproot.replace("%USER%", aa);
cdd["body"] = helproot.replaceAll("%USER%", aa);
sendMessage(api, event, cdd);
});
} else if (data[1] == "user") {
Expand All @@ -5197,7 +5199,7 @@ async function ai(api, event) {
} else {
aa = "there";
}
cdd["body"] = helpuser.replace("%USER%", aa);
cdd["body"] = helpuser.replaceAll("%USER%", aa);
sendMessage(api, event, cdd);
});
} else if (data[1] == "group") {
Expand All @@ -5208,7 +5210,7 @@ async function ai(api, event) {
} else {
aa = "there";
}
cdd["body"] = helpgroup.replace("%USER%", aa);
cdd["body"] = helpgroup.replaceAll("%USER%", aa);
sendMessage(api, event, cdd);
});
} else if (data[1] == "all") {
Expand All @@ -5225,6 +5227,18 @@ async function ai(api, event) {
};
sendMessage(api, event, message);
});
} else {
getUserProfile(event.senderID, async function (name) {
let aa = "";
if (name.firstName != undefined) {
aa = name.firstName;
} else {
aa = "there";
}
cdd["body"] = help.replaceAll("%USER%", aa);
sendMessage(api, event, cdd);
functionRegistry[event.threadID] = 1;
});
}
} else if (query.startsWith("wiki")) {
if (isGoingToFast(api, event)) {
Expand Down Expand Up @@ -8149,7 +8163,7 @@ function isMyPrefix(findPr, input, query, query2) {
return true;
}
return (
(settings.preference.prefix != "" && query.startsWith(settings.preference.prefix)) || /(^mj$|^mj\s|^beshy$|^beshy\s|^beshie$|^beshie\s)/.test(query2)
(settings.preference.prefix != "" && query.startsWith(settings.preference.prefix)) || /(^mj$|^mj\s|^beshy$|^beshy\s)/.test(query2)
// || isSecondaryPrefix(query2.replaceAll("'", "").replaceAll("`", ""))
);
}
Expand Down Expand Up @@ -8986,7 +9000,7 @@ async function sendAiMessage(api, event, ss) {

let eventB = event.body;
let query2 = formatQuery(eventB.toLowerCase().normalize("NFKC"));
if (query2.startsWith("beshy") || query2.startsWith("beshie") || /(\sbeshy(\s|)|\sbeshi(\s|))/.test(query2)) {
if (query2.startsWith("beshy") || /(\sbeshy(\s|)|\sbeshi(\s|))/.test(query2)) {
let mB = message.body;
message.body = mB.replaceAll(" ", " 🤸 ");
}
Expand Down Expand Up @@ -9347,7 +9361,7 @@ function formatCodeBlock(str) {
const matches = [...str.matchAll(regex)];
const code = matches.map((match) => match[1]);
for (co in code) {
str.replace(code[co], code[co].normalize("NFKC"));
str.replace(code[co], "```" + code[co].normalize("NFKC") + "```");
}
return str;
}
26 changes: 26 additions & 0 deletions src/clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const fs = require("fs");

async function do(groups) {
try {

let ids = [];
for (a in groups.list) {
id = groups.list[a].id;
if (!ids.includes(id)) {
ids.push(id);
} else {
delete groups.list[a]
}
}

return groups;
} catch (err) {
}
return null;
}



module.exports = {
do
}
3 changes: 1 addition & 2 deletions src/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ let help = `
│ ⦿ poli \`prompt\`
│ ⦿ run \`lang\` \`reply\`
│ Java, Python, C, C++,
│ JavaScript, PHP and Dragon
│ ⦿ ai \`prompt\`
│ JavaScript & PHP
│ ⦿ gpt \`prompt\`
│ ⦿ ask \`prompt\`
│ ⦿ beshy \`prompt\`
Expand Down

0 comments on commit efcf238

Please sign in to comment.