first commit

This commit is contained in:
synt-xerror
2026-04-14 21:15:05 -03:00
commit eecef0be88
44 changed files with 1372 additions and 0 deletions

77
adivinhação/index.js Normal file
View File

@@ -0,0 +1,77 @@
/**
* plugins/adivinhacao/index.js
*
* Game state lives here — isolated in the plugin.
* Multiple groups can play simultaneously without conflict.
*/
import { CMD_PREFIX } from "../../config.js";
import { createPluginI18n } from "../../utils/pluginI18n.js";
const { t } = createPluginI18n(import.meta.url);
const RANGE = { min: 1, max: 100 };
const jogosAtivos = new Map();
const sorteio = () =>
Math.floor(Math.random() * (RANGE.max - RANGE.min + 1)) + RANGE.min;
export default async function ({ msg, api }) {
const chatId = api.chat.id;
// ── !adivinhação ─────────────────────────────────────────
if (msg.is(CMD_PREFIX + "adivinhação")) {
const sub = msg.args[1];
if (!sub) {
await api.send(
`${t("title")}\n\n` +
`\`${CMD_PREFIX}adivinhação começar\`${t("startCommand")}\n` +
`\`${CMD_PREFIX}adivinhação parar\`${t("stopCommand")}`
);
return;
}
if (sub === "começar") {
jogosAtivos.set(chatId, sorteio());
await api.send(t("started"));
api.log.info(t("gameLog.started"));
return;
}
if (sub === "parar") {
jogosAtivos.delete(chatId);
await api.send(t("stopped"));
api.log.info(t("gameLog.stopped"));
return;
}
await api.send(
`${t("invalidCommand", { sub })} \`${CMD_PREFIX}adivinhação começar\` ${t("or")} \`${CMD_PREFIX}adivinhação parar\`.`
);
return;
}
// ── Guesses during active game ────────────────────────────
const numero = jogosAtivos.get(chatId);
if (numero === undefined) return;
const tentativa = msg.body.trim();
if (!/^\d+$/.test(tentativa)) return;
const num = parseInt(tentativa, 10);
if (num < RANGE.min || num > RANGE.max) {
await msg.reply(t("range", { min: RANGE.min, max: RANGE.max }));
return;
}
if (num === numero) {
await msg.reply(
`${t("correct", { number: numero })} \`${CMD_PREFIX}adivinhação começar\` ${t("playAgain")}`
);
jogosAtivos.delete(chatId);
} else {
await api.send(num > numero ? t("lower") : t("higher"));
}
}

View File

@@ -0,0 +1,18 @@
{
"title": "🎲 Guessing Game",
"startCommand": "Start a new game",
"stopCommand": "Stop the current game",
"started": "Game started! Guess a number between 1 and 100.",
"stopped": "Game stopped.",
"invalidCommand": "Unknown subcommand: {{sub}}. Use",
"or": "or",
"range": "The number must be between {{min}} and {{max}}.",
"correct": "🎉 Correct! The number was {{number}}. Type",
"playAgain": "to play again.",
"higher": "📈 Higher!",
"lower": "📉 Lower!",
"gameLog": {
"started": "Guessing game started.",
"stopped": "Guessing game stopped."
}
}

View File

@@ -0,0 +1,18 @@
{
"title": "🎲 Juego de Adivinanza",
"startCommand": "Iniciar un nuevo juego",
"stopCommand": "Detener el juego actual",
"started": "¡Juego iniciado! Adivina un número entre 1 y 100.",
"stopped": "Juego detenido.",
"invalidCommand": "Subcomando desconocido: {{sub}}. Usa",
"or": "o",
"range": "El número debe estar entre {{min}} y {{max}}.",
"correct": "🎉 ¡Correcto! El número era {{number}}. Escribe",
"playAgain": "para jugar de nuevo.",
"higher": "📈 ¡Mayor!",
"lower": "📉 ¡Menor!",
"gameLog": {
"started": "Juego de adivinanza iniciado.",
"stopped": "Juego de adivinanza detenido."
}
}

View File

@@ -0,0 +1,18 @@
{
"title": "🎲 Jogo de Adivinhação",
"startCommand": "Iniciar um novo jogo",
"stopCommand": "Parar o jogo atual",
"started": "Jogo iniciado! Adivinhe um número entre 1 e 100.",
"stopped": "Jogo parado.",
"invalidCommand": "Subcomando desconhecido: {{sub}}. Use",
"or": "ou",
"range": "O número deve estar entre {{min}} e {{max}}.",
"correct": "🎉 Correto! O número era {{number}}. Digite",
"playAgain": "para jogar novamente.",
"higher": "📈 Maior!",
"lower": "📉 Menor!",
"gameLog": {
"started": "Jogo de adivinhação iniciado.",
"stopped": "Jogo de adivinhação parado."
}
}

View File

@@ -0,0 +1,7 @@
{
"name": "adivinhacao",
"version": "1.0.0",
"category": "games",
"service": false,
"dependencies": {}
}