Respondido

Como Identificar Feriados Blip


Reputação 6
Crachá

Boa tarde pessoal, tudo bem com vocês?


Estou com um problema, toda a vez que tem feriado os usuários ficam aguardando na fila do Blip Desk, porém não há ninguém para atende-los. Queria saber se tem alguma forma, ou script para detectar os feriados, isso resolveria meus problemas 🙂


Recentemente vi um script que a @Localiza_Imoveis criou porém não estou conseguindo implementar no meu bot, o retorno sempre vem como “true” mesmo dizendo que não é feriado no array:



Alguém conseguiria me ajudar?


Desde já obrigado a todos.

icon

Melhor resposta por Rodrigo_Valentim 29 April 2021, 23:03

Veja o original

5 comentários

Hey, Blipper!!


Há um tempo atrás eu criei essa solução para identificar o próximo dia útil que o bot enviaria mensagem. Ainda, para facilitar a manutenção eu utilizei a funcionalidade de recursos.


Espero que te ajude! 😉

Fala jovem, tudo bem?


Cara, atualmente, utilizo esse script, mas, logo vou criar uma api para poder consumir e então retirar esse JS gigantesco do meu bot.


Segue o que uso.


    function run(){
/* system date */
let data = new Date()
let isHoliday = new Boolean()

/* object with local date and time */
var currentDate = {
year : data.getFullYear(), /* The getFullYear() method returns the year (four digits for dates between year 1000 and 9999) of the specified date.*/
month : data.getMonth(), /* The getMonth() method returns the month (from 0 to 11) for the specified date, according to local time. */
day : data.getDate(), /* The getDate() method returns the day of the month (from 1 to 31) for the specified date. */
day_week : data.getDay(), /* The getDay() method returns the day of the week (from 0 to 6) for the specified date. */
hour : data.getHours(), /* The getHours() method returns the hour (from 0 to 23) of the specified date and time. */
minute : data.getMinutes() /* The getMinutes() method returns the minutes (from 0 to 59) of the specified date and time. */
};

/* configuration matrix with holidays */
/* info -> 0 = is not holiday | 1 = is a holiday */
let Holidays = [
['Months' , 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],
['January' , 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
];

/* Adjusting the current month of the year to the Holidays table format */
currentDate.month++

/* checks if the current date is a holiday */
if (Holidays[currentDate.month][currentDate.day] == 0){
isHoliday = false /* --> is not a Holiday */
}else{
isHoliday = true /* --> is a Holiday */
}
return isHoliday
}

Depois é só você exportar o valor do isHoliday para uma variável e usar esta como condicional.

Reputação 7
Crachá +1

Tá doido!

Esse tópico é pra salvar nos favoritos!


Obrigado demais @fadoaglauss e @Rodrigo_Valentim

:thuglifeblip:

Reputação 6
Crachá

Muito obrigado pela colaboração!!!

Reputação 6
Crachá

Seu script me ajudou aqui a resolver o problema!!!


Vocês são demais pessoal, muito obrigado!!!

Comente