Compare commits

...

2 Commits
v1.0.0 ... main

Author SHA1 Message Date
ec5b7eafaa
version bump 2022-01-02 14:42:46 +01:00
5a0a91ec87
add timezone 2022-01-02 14:41:27 +01:00
3 changed files with 10 additions and 8 deletions

View File

@ -1,6 +1,6 @@
{ {
"private": true, "private": true,
"version": "1.0.0", "version": "1.0.1",
"type": "module", "type": "module",
"main": "./dist/index.js", "main": "./dist/index.js",
"engines": { "engines": {

View File

@ -6,19 +6,22 @@ import { getLatests } from './routes/status.js'
async function fn() { async function fn() {
const now = dayjs() const now = dayjs()
const { fed, clean } = getLatests()
const needsFeeding = !fed || dayjs(fed.timestamp).isBefore(now.subtract(12, 'hours'))
const needsCleaning = !clean || dayjs(clean.timestamp).isBefore(now.subtract(7, 'days'))
for (const user of DB.data?.users ?? []) { for (const user of DB.data?.users ?? []) {
const { fed, clean } = getLatests() if (needsFeeding) {
if (!fed || dayjs(fed.timestamp).isBefore(now.subtract(12, 'hours'))) {
await bot.telegram.sendMessage(user.id, '🥜 You have not fed me in the last 12 hours!') await bot.telegram.sendMessage(user.id, '🥜 You have not fed me in the last 12 hours!')
} }
if (needsCleaning) {
if (!clean || dayjs(clean.timestamp).isBefore(now.subtract(7, 'days'))) {
await bot.telegram.sendMessage(user.id, '🛁 You have not cleaned me in the last 7 days!') await bot.telegram.sendMessage(user.id, '🛁 You have not cleaned me in the last 7 days!')
} }
} }
} }
export function init() { export function init() {
cron.schedule('0 22 * * *', fn) const timezone = 'Europe/Berlin'
// cron.schedule('*/10 * * * * *', fn) cron.schedule('0 22 * * *', fn, { timezone })
// cron.schedule('*/10 * * * * *', fn, {timezone})
} }

View File

@ -4,7 +4,6 @@ export const Version = process.env['npm_package_version']
export function init(bot: Bot) { export function init(bot: Bot) {
bot.command('/version', async (ctx) => { bot.command('/version', async (ctx) => {
// ctx.reply('Version: ' + version)
ctx.reply(`Version: ${Version}`) ctx.reply(`Version: ${Version}`)
}) })
} }