Skip to content

Commit

Permalink
fix: bater ponto de almoco
Browse files Browse the repository at this point in the history
  • Loading branch information
dodopok committed Mar 3, 2021
1 parent 4443792 commit bbf9662
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ REST_PORT=8090
PORT=8079
TELEGRAM_CHAT_ID=ID DA SUA CONVERSA COM O BOT
TELEGRAM_BOT_KEY=CHAVE DO TELEGRAM
CRON_RULE=0 9,12,13,18 * * 1-5

LATITUDE=0
LONGITUDE=0
16 changes: 16 additions & 0 deletions bot.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
// const parser = require('cron-parser');
const TelegramBot = require('node-telegram-bot-api');
const token = process.env.TELEGRAM_BOT_KEY;
const bot = new TelegramBot(token, { polling: true });

// const interval = parser.parseExpression(process.env.CRON_RULE);

// const date = require('date-fns');

bot.on('message', (msg) => {
bot.sendMessage(process.env.TELEGRAM_CHAT_ID, "Ainda tô aqui!");

// if (msg.text == '/nextrun') {
// // let next_run = date.format(
// // interval.next()._date,
// // "'Dia' dd 'de' MMMM', às ' HH:mm'h'"
// // );

// console.log(interval.next()._date);

// // bot.sendMessage(process.env.TELEGRAM_CHAT_ID, next_run);
// }
});

module.exports = {
Expand Down
77 changes: 77 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"dependencies": {
"async-exit-hook": "^2.0.1",
"cron-parser": "^3.2.0",
"date-fns": "^2.18.0",
"dotenv": "^8.2.0",
"node-cron": "^2.0.3",
"node-fetch": "^2.6.1",
Expand Down
2 changes: 1 addition & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exitHook(callback => {
// cron as 09 e as 18, de segunda a sexta
// TODO: lidar com feriados e dias exclusivos (férias)

task = cron.schedule('0 9,18 * * 1-5', () => {
task = cron.schedule(process.env.CRON_RULE, () => {
clock.clockit();
}, {
scheduled: true,
Expand Down

0 comments on commit bbf9662

Please sign in to comment.