Skip to content

Commit

Permalink
feat: Added disable private chats
Browse files Browse the repository at this point in the history
  • Loading branch information
Zastinian committed Nov 30, 2024
1 parent c40afc2 commit 2be5567
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hedystia.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ module.exports = async (hedystia, m) => {
cont = status;
}
}
const privateStatus = globalThis.db.config.select("private", { id: "private" })[0].value;
if (privateStatus) {
if (!isGroup) {
return hedystia.sendMessage(m.chat, { text: lang.owner.private }, { quoted: m });
}
}
if (!cont) {
return;
}
Expand Down
Empty file added src/commands/owner/private.js
Empty file.
75 changes: 75 additions & 0 deletions src/db/migrations/2024-11-29T13-45-23.456Z.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
const readline = require("readline");

function getPrivateStatus() {
return new Promise((resolve) => {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
const askPrivate = async () => {
console.log("");
rl.question(
"\x1b[93mTell me if you want to disable private chats (true/false)\x1b[94m\n⤳\x1b[0m ",
(input) => {
const value = input.toLowerCase().trim();
if (
value === "true" ||
value === "on" ||
lang === "encendido" ||
value === "enabled" ||
value === "false" ||
value === "off" ||
value === "apagado" ||
value === "desactivado" ||
value === "disabled"
) {
let l;
switch (value) {
case "true":
l = true;
break;
case "on":
l = true;
break;
case "enabled":
l = true;
break;
case "false":
l = false;
break;
case "off":
l = false;
break;
case "apagado":
l = false;
break;
case "desactivado":
l = false;
break;
case "disabled":
l = false;
break;
}
resolve(l);
rl.close();
} else {
console.log("");
console.log("\x1b[91mERROR: \x1b[92mThe private status provided is not correct\x1b[0m");
setTimeout(() => {
console.log("");
askPrivate();
});
}
},
);
};
askPrivate();
});
}

module.exports = async (config) => {
config.deleteTableIfExists("private");
config.createTable("private", ["id", "value"]);
const p = await getPrivateStatus();
config.insert("private", { id: "private", value: p });
};

0 comments on commit 2be5567

Please sign in to comment.