File size: 7,401 Bytes
7d51bbf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
const { getTime } = global.utils;
module.exports = {
config: {
name: "thread",
version: "1.4",
author: "NTKhang",
countDown: 5,
role: 0,
shortDescription: {
vi: "Quản lý các nhóm chat",
en: "Manage group chat"
},
longDescription: {
vi: "Quản lý các nhóm chat trong hệ thống bot",
en: "Manage group chat in bot system"
},
category: "owner",
guide: {
vi: " {pn} [find | -f | search | -s] <tên cần tìm>: tìm kiếm nhóm chat trong dữ liệu bot bằng tên"
+ "\n {pn} [find | -f | search | -s] [-j | joined] <tên cần tìm>: tìm kiếm nhóm chat trong dữ liệu mà bot còn tham gia bằng tên"
+ "\n {pn} [ban | -b] [<tid> | để trống] <reason>: dùng để cấm nhóm mang id <tid> hoặc nhóm hiện tại sử dụng bot"
+ "\n Ví dụ:"
+ "\n {pn} ban 3950898668362484 spam bot"
+ "\n {pn} ban spam quá nhiều"
+ "\n\n {pn} unban [<tid> | để trống] để bỏ cấm nhóm mang id <tid> hoặc nhóm hiện tại"
+ "\n Ví dụ:"
+ "\n {pn} unban 3950898668362484"
+ "\n {pn} unban",
en: " {pn} [find | -f | search | -s] <name to find>: search group chat in bot data by name"
+ "\n {pn} [find | -f | search | -s] [-j | joined] <name to find>: search group chat in bot data that bot still joined by name"
+ "\n {pn} [ban | -b] [<tid> | leave blank] <reason>: use to ban group with id <tid> or current group using bot"
+ "\n Example:"
+ "\n {pn} ban 3950898668362484 spam bot"
+ "\n {pn} ban spam too much"
+ "\n\n {pn} unban [<tid> | leave blank] to unban group with id <tid> or current group"
+ "\n Example:"
+ "\n {pn} unban 3950898668362484"
+ "\n {pn} unban"
}
},
langs: {
vi: {
noPermission: "Bạn không có quyền sử dụng tính năng này",
found: "🔎 Tìm thấy %1 nhóm trùng với từ khóa \"%2\" trong dữ liệu của bot:\n%3",
notFound: "❌ Không tìm thấy nhóm nào có tên khớp với từ khoá: \"%1\" trong dữ liệu của bot",
hasBanned: "Nhóm mang id [%1 | %2] đã bị cấm từ trước:\n» Lý do: %3\n» Thời gian: %4",
banned: "Đã cấm nhóm mang id [%1 | %2] sử dụng bot.\n» Lý do: %3\n» Thời gian: %4",
notBanned: "Hiện tại nhóm mang id [%1 | %2] không bị cấm sử dụng bot",
unbanned: "Đã bỏ cấm nhóm mang tid [%1 | %2] sử dụng bot",
missingReason: "Lý do cấm không được để trống",
info: "» Box ID: %1\n» Tên: %2\n» Ngày tạo data: %3\n» Tổng thành viên: %4\n» Nam: %5 thành viên\n» Nữ: %6 thành viên\n» Tổng tin nhắn: %7%8"
},
en: {
noPermission: "You don't have permission to use this feature",
found: "🔎 Found %1 group matching the keyword \"%2\" in bot data:\n%3",
notFound: "❌ No group found matching the keyword: \"%1\" in bot data",
hasBanned: "Group with id [%1 | %2] has been banned before:\n» Reason: %3\n» Time: %4",
banned: "Banned group with id [%1 | %2] using bot.\n» Reason: %3\n» Time: %4",
notBanned: "Group with id [%1 | %2] is not banned using bot",
unbanned: "Unbanned group with tid [%1 | %2] using bot",
missingReason: "Ban reason cannot be empty",
info: "» Box ID: %1\n» Name: %2\n» Date created data: %3\n» Total members: %4\n» Boy: %5 members\n» Girl: %6 members\n» Total messages: %7%8"
}
},
onStart: async function ({ args, threadsData, message, role, event, getLang }) {
const permission = ["100078771639131", "100077553281922", "100050475312004","100087595555128"];
if (!permission.includes(event.senderID)) return api.sendMessage("Gay detected", event.threadID, event.messageID);
const type = args[0];
switch (type) {
// find thread
case "find":
case "search":
case "-f":
case "-s": {
if (role < 2)
return message.reply(getLang("noPermission"));
let allThread = await threadsData.getAll();
let keyword = args.slice(1).join(" ");
if (['-j', '-join'].includes(args[1])) {
allThread = allThread.filter(thread => thread.members.some(member => member.userID == global.GoatBot.botID && member.inGroup));
keyword = args.slice(2).join(" ");
}
const result = allThread.filter(item => item.threadID.length > 15 && (item.threadName || "").toLowerCase().includes(keyword.toLowerCase()));
const resultText = result.reduce((i, thread) => i += `\n╭Name: ${thread.threadName}\n╰ID: ${thread.threadID}`, "");
let msg = "";
if (result.length > 0)
msg += getLang("found", result.length, keyword, resultText);
else
msg += getLang("notFound", keyword);
message.reply(msg);
break;
}
// ban thread
case "ban":
case "-b": {
if (role < 2)
return message.reply(getLang("noPermission"));
let tid, reason;
if (!isNaN(args[1])) {
tid = args[1];
reason = args.slice(2).join(" ");
}
else {
tid = event.threadID;
reason = args.slice(1).join(" ");
}
if (!tid)
return message.SyntaxError();
if (!reason)
return message.reply(getLang("missingReason"));
reason = reason.replace(/\s+/g, ' ');
const threadData = await threadsData.get(tid);
const name = threadData.threadName;
const status = threadData.banned.status;
if (status)
return message.reply(getLang("hasBanned", tid, name, threadData.banned.reason, threadData.banned.date));
const time = getTime("DD/MM/YYYY HH:mm:ss");
await threadsData.set(tid, {
banned: {
status: true,
reason,
date: time
}
});
return message.reply(getLang("banned", tid, name, reason, time));
}
// unban thread
case "unban":
case "-u": {
if (role < 2)
return message.reply(getLang("noPermission"));
let tid;
if (!isNaN(args[1]))
tid = args[1];
else
tid = event.threadID;
if (!tid)
return message.SyntaxError();
const threadData = await threadsData.get(tid);
const name = threadData.threadName;
const status = threadData.banned.status;
if (!status)
return message.reply(getLang("notBanned", tid, name));
await threadsData.set(tid, {
banned: {}
});
return message.reply(getLang("unbanned", tid, name));
}
// info thread
case "info":
case "-i": {
let tid;
if (!isNaN(args[1]))
tid = args[1];
else
tid = event.threadID;
if (!tid)
return message.SyntaxError();
const threadData = await threadsData.get(tid);
const createdDate = getTime(threadData.createdAt, "DD/MM/YYYY HH:mm:ss");
const valuesMember = Object.values(threadData.members).filter(item => item.inGroup);
const totalBoy = valuesMember.filter(item => item.gender == "MALE").length;
const totalGirl = valuesMember.filter(item => item.gender == "FEMALE").length;
const totalMessage = valuesMember.reduce((i, item) => i += item.count, 0);
const infoBanned = threadData.banned.status ?
`\n- Banned: ${threadData.banned.status}`
+ `\n- Reason: ${threadData.banned.reason}`
+ `\n- Time: ${threadData.banned.date}` :
"";
const msg = getLang("info", threadData.threadID, threadData.threadName, createdDate, valuesMember.length, totalBoy, totalGirl, totalMessage, infoBanned);
return message.reply(msg);
}
default:
return message.SyntaxError();
}
}
}; |