Organize este código: function processOpenCommand(openTime, groupId) {…
- User
Organize este código:
function processOpenCommand(openTime, groupId) { scheduleOpenOperation(groupId, openTime); }
function checkScheduledOperations() { const schedule = loadData(); const now = moment();
for (const groupId in schedule) { const { fechar, abrir } = schedule[groupId]; if (fechar && now.isSameOrAfter(moment(fechar.nextDate, 'DD/MM/YYYY').set({ hour: fechar.time.split(':')[0], minute: fechar.time.split(':')[1] }))) { client.groupSettingUpdate(groupId, 'announcement'); delay(500); // client.sendMessage(groupId, { text: `*Grupo fechado com sucesso 🔒*` }); const nextTime = calculateNextTime(fechar.time); fechar.nextDate = nextTime.nextDate; fechar.timeRemaining = nextTime.timeRemaining; saveData(schedule); } if (abrir && now.isSameOrAfter(moment(abrir.nextDate, 'DD/MM/YYYY').set({ hour: abrir.time.split(':')[0], minute: abrir.time.split(':')[1] }))) { client.groupSettingUpdate(groupId, 'not_announcement'); delay(500); // client.sendMessage(groupId, { text: `*Grupo aberto com sucesso 🔓*` }); const nextTime = calculateNextTime(abrir.time); abrir.nextDate = nextTime.nextDate; abrir.timeRemaining = nextTime.timeRemaining; saveData(schedule); } }}
function deleteGroupOperation(groupId) { const data = loadData(); if (data[groupId]) { delete data[groupId]; saveData(data); client.sendMessage(from, { text:
*Registro deste grupo foi apagado com sucesso!*}); } else { console.log(Não há registro para esse grupo!); } }// Função para verificar as operações agendadas de forma periódica setInterval(checkScheduledOperations, 60 * 1000);
// [**** SORTEIO POR REAÇÕES *****]
// [***** FUNÇÃO PARA ENVIA UMA MSG X PARA TODOS OS GRUPOS****]
const schedule = require('node-schedule');
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.