gpt-4o-mini-2024-07-18· OpenAI
WildChat-4.8M (AI2)
Organize este código: const sorteios = fs.readdirSync("./sorteios"); const agora = new…
- User
Organize este código:
const sorteios = fs.readdirSync("./sorteios"); const agora = new Date(); sorteios.forEach((arquivo) => { const caminhoArquivo = `./sorteios/${arquivo}`; const sorteio = JSON.parse(fs.readFileSync(caminhoArquivo, "utf8")); // Verifica se 'horario' está definido if (!sorteio.horario) {// console.error(
O arquivo ${arquivo} não possui a propriedade 'horario'.); return; // Sai da iteração atual se 'horario' não estiver definido }const [hora, minutos, periodo] = sorteio.horario.split(/[: ]/); const horaSorteio = new Date(); horaSorteio.setHours(periodo.toUpperCase() === "PM" ? parseInt(hora) % 12 + 12 : parseInt(hora)); horaSorteio.setMinutes(parseInt(minutos)); horaSorteio.setSeconds(0); horaSorteio.setMilliseconds(0); if (agora >= horaSorteio) { let ganhadores = []; let participantes = [...sorteio.participantes]; for (let i = 0; i < (sorteio.numGanhadores === "all" ? participantes.length : sorteio.numGanhadores); i++) { if (participantes.length > 0) { const index = Math.floor(Math.random() * participantes.length); ganhadores.push(participantes[index]); participantes.splice(index, 1); } } let mensagemGanhadores = `🚀 **Sorteio Encerrado!**\n🏆 Ganhadores:\n`; ganhadores.forEach(ganhador => { mensagemGanhadores += `@${ganhador.split('@')[0]}\n`; }); client.sendMessage(sorteio.groupId, { text: mensagemGanhadores, mentions: ganhadores }); client.groupSettingUpdate(sorteio.groupId, 'not_announcement').catch(e => { console.log("Erro ao abrir o grupo:", e); }); fs.unlinkSync(caminhoArquivo); } });}
// Intervalo para monitorar sorteios a cada minuto
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.