Organize este código: fs.writeFileSync(schedulePath_img, JSON.stringify(schedule, null,…
- User
Organize este código:
codefs.writeFileSync(schedulePath_img, JSON.stringify(schedule, null, 2)); client.sendMessage(sender, { text: `Imagem programada para o grupo ${groupId} com intervalo ${interval}.` });}
function parseIntervalToMs(interval) { const match = interval.trim().match(/(\d+)([hms])/); if (!match) throw new Error("Formato de intervalo inválido. Use 'h', 'm' ou 's'."); const value = parseInt(match[1]); const unit = match[2];
codeswitch (unit) { case 'h': return value * 60 * 60 * 1000; case 'm': return value * 60 * 1000; case 's': return value * 1000; default: throw new Error("Unidade de tempo inválida. Use 'h', 'm' ou 's'."); }}
function checkAndSendImages() { const schedule = JSON.parse(fs.readFileSync(schedulePath_img, 'utf8')); const now = Date.now(); for (const groupId in schedule) { const { interval, image, nextSendTime } = schedule[groupId]; if (now >= nextSendTime) { client.sendMessage(groupId, { image: { url: image.url } }); schedule[groupId].nextSendTime = now + parseIntervalToMs(interval); } } fs.writeFileSync(schedulePath_img, JSON.stringify(schedule, null, 2)); }
function removeGroupFromImageSchedule(groupId) { const scheduleFilePath = './armor/cache/schedule_images.json' try { let scheduleData = fs.readFileSync(scheduleFilePath, 'utf-8'); let schedule = JSON.parse(scheduleData); if (schedule[groupId]) { delete schedule[groupId]; fs.writeFileSync(scheduleFilePath, JSON.stringify(schedule, null, 2), 'utf-8'); console.log(
Grupo ${groupId} removido da lista de respostas programadas com imagem.); } else { console.log(Grupo ${groupId} não encontrado na lista de respostas programadas com imagem.); } } catch (error) { console.error('Erro ao remover o grupo da lista de respostas programadas com imagem:', error); - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.