mirror of
https://github.com/cupcakearmy/hagen-control-station.git
synced 2025-04-11 11:23:05 +00:00
Compare commits
4 Commits
v1.0.0-rc.
...
main
Author | SHA1 | Date | |
---|---|---|---|
ec5b7eafaa | |||
5a0a91ec87 | |||
50650d1e07 | |||
e0c76e258e |
6
.github/workflows/docker.yaml
vendored
6
.github/workflows/docker.yaml
vendored
@ -23,6 +23,12 @@ jobs:
|
|||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=semver,pattern={{major}}
|
type=semver,pattern={{major}}
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# - name: Login to DockerHub
|
# - name: Login to DockerHub
|
||||||
# uses: docker/login-action@v1
|
# uses: docker/login-action@v1
|
||||||
# with:
|
# with:
|
||||||
|
19
README.md
19
README.md
@ -6,3 +6,22 @@
|
|||||||
[Telegraf](https://telegraf.js.org/)
|
[Telegraf](https://telegraf.js.org/)
|
||||||
|
|
||||||
## Deployment
|
## Deployment
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# docker-compose.yaml
|
||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: ghcr.io/cupcakearmy/hcs
|
||||||
|
restart: unless-stopped
|
||||||
|
env_file: .env
|
||||||
|
volumes:
|
||||||
|
- ./data:/app/data
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# .env
|
||||||
|
BOT_TOKEN=<telegram bot token>
|
||||||
|
HCS_PASSWORD=<password for users>
|
||||||
|
```
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
# DEVELOPMENT ONLY
|
||||||
|
# See README.md
|
||||||
|
|
||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.0-rc.0",
|
"version": "1.0.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
15
src/cron.ts
15
src/cron.ts
@ -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})
|
||||||
}
|
}
|
||||||
|
@ -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}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user