[repo] reorganization using plugins instead of built-in commands, [plugin] new game: forca, [dev] changes on log format, [config] removed botMsg, [plugin] on stickers, you can create just one sending an image or replying to one, [setup] exec permissions and comand to install Chrome

This commit is contained in:
synt-xerror
2026-03-23 21:25:09 -03:00
parent f9911f6cf3
commit c75b6249c1
44 changed files with 1589 additions and 786 deletions

View File

@@ -6,8 +6,6 @@ export const c = {
blue: "\x1b[34m", magenta: "\x1b[35m",
};
export const SEP = `${c.gray}${"─".repeat(52)}${c.reset}`;
export const now = () =>
new Date().toLocaleString("pt-BR", { dateStyle: "short", timeStyle: "medium" });
@@ -26,9 +24,9 @@ export const formatContext = (chatName, isGroup) =>
? `${c.bold}${chatName}${c.reset} ${c.dim}(grupo)${c.reset}`
: `${c.bold}${chatName}${c.reset} ${c.dim}(privado)${c.reset}`;
export const formatBody = (body, isCommand) =>
export const formatBody = (body) =>
body?.trim()
? `${isCommand ? c.yellow : c.green}"${body.length > 200 ? body.slice(0, 200) + "..." : body}"${c.reset}`
? `${c.green}"${body.length > 200 ? body.slice(0, 200) + "..." : body}"${c.reset}`
: `${c.dim}<mídia>${c.reset}`;
export const formatReply = (quotedName, quotedNumber, quotedPreview) =>

View File

@@ -1,5 +1,5 @@
import {
c, SEP, now,
c, now,
formatType, formatContext, formatBody, formatReply,
} from "./formatter.js";
@@ -8,7 +8,7 @@ import {
* Cada método lida apenas com saída — sem lógica de negócio ou I/O externo.
*/
export const logger = {
info: (...a) => console.log(`${SEP}\n${c.gray}[${now()}]${c.reset} ${c.cyan}INFO ${c.reset}`, ...a),
info: (...a) => console.log(`${c.gray}[${now()}]${c.reset} ${c.cyan}INFO ${c.reset}`, ...a),
success: (...a) => console.log(`${c.gray}[${now()}]${c.reset} ${c.green}OK ${c.reset}`, ...a),
warn: (...a) => console.log(`${c.gray}[${now()}]${c.reset} ${c.yellow}WARN ${c.reset}`, ...a),
error: (...a) => console.log(`${c.gray}[${now()}]${c.reset} ${c.red}ERROR ${c.reset}`, ...a),
@@ -18,23 +18,10 @@ export const logger = {
* @param {import("./messageContext.js").MessageContext} ctx
*/
msg(ctx) {
const { chatName, isGroup, senderName, senderNumber, type, body, isCommand, quoted } = ctx;
const typeLabel = formatType(type);
const context = formatContext(chatName, isGroup);
const bodyText = formatBody(body, isCommand);
const replyLine = quoted
? formatReply(quoted.name, quoted.number, quoted.preview)
: "";
console.log(
`${SEP}\n` +
`${c.gray}[${now()}]${c.reset} ${c.cyan}MSG ${c.reset}${context}\n` +
`${c.gray} De: ${c.reset}${c.white}${senderName}${c.reset} ${c.dim}+${senderNumber}${c.reset}\n` +
`${c.gray} Tipo: ${c.reset}${typeLabel}${isCommand ? ` ${c.yellow}(bot)${c.reset}` : ""}\n` +
`${c.gray} Text: ${c.reset}${bodyText}` +
replyLine
);
const { chatName, isGroup, senderName, senderNumber, type, body, quoted } = ctx;
const context = isGroup ? `${chatName} (grupo)` : chatName;
const reply = quoted ? ` → Responde ${quoted.name} +${quoted.number}: "${quoted.preview}"` : "";
console.log(`\n${c.gray}[${now()}]${c.reset} ${c.cyan}MSG${c.reset} ${context} ${c.gray}— De:${c.reset} ${c.white}${senderName}${c.reset} ${c.dim}+${senderNumber}${c.reset} ${c.gray}— Tipo:${c.reset} ${type}${c.green}"${body}"${c.reset}${c.gray}${reply}${c.reset}`);
},
cmd: (cmd, extra = "") =>

View File

@@ -28,7 +28,6 @@ export async function getNumber(msg) {
* @property {string} senderNumber
* @property {string} type
* @property {string} body
* @property {boolean} isCommand
* @property {{ name: string, number: string, preview: string } | null} quoted
*/
export async function buildMessageContext(msg, chat, botPrefix) {
@@ -47,7 +46,6 @@ export async function buildMessageContext(msg, chat, botPrefix) {
senderNumber: number,
type: msg?.type || "text",
body: msg.body,
isCommand: !!msg.body?.trimStart().startsWith(botPrefix),
quoted,
};
}