added Count Dracula

This commit is contained in:
Avi 2020-12-10 00:15:45 +00:00
parent 54cd1b36bc
commit 61997d1507
2 changed files with 23 additions and 23 deletions

View file

@ -1,6 +1,7 @@
// Require the Bolt package (github.com/slackapi/bolt) // Require the Bolt package (github.com/slackapi/bolt)
const { App } = require("@slack/bolt"); const { App } = require("@slack/bolt");
const keep_alive = require('./keep_alive.js') const keep_alive = require('./keep_alive.js');
const addQuotes = require('./quotes.js');
const schedule = require('node-schedule'); const schedule = require('node-schedule');
const moment = require('moment'); const moment = require('moment');
const token = process.env.SLACK_BOT_TOKEN; const token = process.env.SLACK_BOT_TOKEN;
@ -15,6 +16,8 @@ let speedArr = [];
let latest; let latest;
let averageSpeed; let averageSpeed;
addQuotes();
const app = new App({ const app = new App({
token: token, token: token,
signingSecret: process.env.SLACK_SIGNING_SECRET signingSecret: process.env.SLACK_SIGNING_SECRET
@ -146,28 +149,20 @@ async function report() {
let pastThousandsGoal = Math.floor(latest / 1000) * 1000; let pastThousandsGoal = Math.floor(latest / 1000) * 1000;
let tenThousandsTime = predictTime(tenThousandsGoal, latest); let tenThousandsTime = predictTime(tenThousandsGoal, latest);
let message = let message =
"Nice! Today we've went from *" + `Good evening, my underlings! You have done a _brilliant_ job with the counting. Mmm. Yes. Numbers are savory.
oldest + Today we've went from *${oldest}* to *${latest}*!
"* to *" + - :arrow_upper_right: The day's progress: *+${diff}*
latest + - :chart_with_upwards_trend: Average daily speed: *${averageSpeed}*
"*! \n - :arrow_upper_right: The day's progress: *+" + - :round_pushpin: At the avg speed, we'll reach ${thousandsGoal} *${thousandsTime}*
diff + - :calendar: At the avg speed, we'll reach ${tenThousandsGoal} *${tenThousandsTime}*
"*\n - :chart_with_upwards_trend: Average daily speed: *" + :bat: Lovely work, my followers! Keep on quenching my thirst for numbers!`;
averageSpeed +
"*\n - :round_pushpin: At the avg speed, we'll reach " +
thousandsGoal +
" *" +
thousandsTime +
"*\n - :calendar: At the avg speed, we'll reach " +
tenThousandsGoal +
" *" +
tenThousandsTime +
"* \n :fastparrot: KEEP IT GOING GUYS!";
if (pastThousandsGoal > oldest && pastThousandsGoal <= latest) { if (pastThousandsGoal > oldest && pastThousandsGoal <= latest) {
let messageWithCelebration = ":tada: YAY! We've went past " + pastThousandsGoal + "! :tada: \n" + message; let messageWithCelebration = `:tada: Congratulations! We've went past ${pastThousandsGoal}! :tada:` + message;
publishMessage(channel, messageWithCelebration); //'C017W4PHYKS' for debugging, channel for actual publishMessage(channel, messageWithCelebration);
// publishMessage('C017W4PHYKS', messageWithCelebration);
} else { } else {
publishMessage(channel, message); //'C017W4PHYKS' for debugging, channel for actual publishMessage(channel, message);
// publishMessage('C017W4PHYKS', message);
} }
}; };
@ -205,8 +200,8 @@ app.event('message', async (body) => {
// Start your app // Start your app
try { try {
await app.start(process.env.PORT || 3000); await app.start(process.env.PORT || 3000);
let j = schedule.scheduleJob('0 0 * * *', report); // */15 * * * * * for debugging, 0 0 * * * actual let j = schedule.scheduleJob('0 0 * * *', report);
publishMessage('C017W4PHYKS', 'running every midnight!') // let j = schedule.scheduleJob('*/15 * * * * *', report);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }

5
api/quotes.js Normal file
View file

@ -0,0 +1,5 @@
function addQuotes() {
console.log('hi');
}
module.exports = addQuotes;