Compare commits

..

9 Commits

Author SHA1 Message Date
8e6bc53bca deploy on hobbybackend1
Some checks failed
Build and Publish / deploy image (push) Has been cancelled
Build and Publish / publish image (push) Has been cancelled
2025-09-14 14:56:44 +02:00
45e0e55883 Set timezone information in Dockerfile
Some checks failed
Build and Publish / publish image (push) Successful in 22s
Build and Publish / deploy image (push) Failing after 17s
2024-10-03 18:28:24 +02:00
2d9973aa98 Remove base_config.json and ignore.
Some checks failed
Build and Publish / publish image (push) Successful in 16s
Build and Publish / deploy image (push) Failing after 1s
This is the configured version of config_template.json that should not be checked in.
2024-10-01 22:10:16 +02:00
57a76c5bfc Add entry in crontab to run job on thekendienstbot telegram channel
Some checks failed
Build and Publish / publish image (push) Failing after 18s
Build and Publish / deploy image (push) Has been skipped
2024-10-01 21:55:40 +02:00
9d54a9687d Fix path is script in crontab 2024-10-01 21:55:01 +02:00
d78c4f5073 Ignore secrets file 2024-10-01 21:54:22 +02:00
1748fd7016 Split secrets into separate file
Some checks failed
Build and Publish / publish image (push) Successful in 1m32s
Build and Publish / deploy image (push) Failing after 2s
2024-09-30 18:53:47 +02:00
39ab19125c Add action
Some checks failed
Build and Publish / publish image (push) Successful in 25s
Build and Publish / deploy image (push) Failing after 18s
2024-09-25 23:09:49 +02:00
1a77505ef5 Correctly escape last_minute_warning 2024-09-25 20:56:05 +02:00
11 changed files with 89 additions and 40 deletions

View File

@ -0,0 +1,68 @@
name: Build and Publish
run-name: ${{ gitea.actor }} is building docker image for thekendienstbot out Gitea Actions
on:
push:
branches: [ "main" ]
env:
REGISTRY: gitea.lan.hobbyhimmel.de
OWNER: ${{ github.repository_owner }}
CONTAINER_NAME: thekendienstbot
IMAGE_NAME: ${{ env.OWNER }}/${{ env.CONTAINER_NAME }}
jobs:
publish:
name: publish image
runs-on: ubuntu-latest
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Login to gitea
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.TOKEN_GITEA }}
- name: Build and push
uses: docker/build-push-action@v6
with:
file: docker/Dockerfile
platforms: linux/amd64
push: true
provenance: false
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.date.outputs.date }}-${{ env.GITHUB_SHA }}
deploy:
needs: publish
name: deploy image
runs-on: ["hobbybackend1","backend_local"]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to gitea
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.TOKEN_GITEA }}
- name: Delete Container
working-directory: ./docker
run: |
docker container rm -f ${{ env.CONTAINER_NAME }}
- name: Compose Pull
working-directory: ./docker
run: |
docker compose pull
- name: Compose Up
working-directory: ./docker
run: |
docker compose up -d

4
.gitignore vendored
View File

@ -1,3 +1,7 @@
# User ignore
cfg/secrets.json
cfg/base_config.json
# ---> Python
# Byte-compiled / optimized / DLL files
__pycache__/

View File

@ -1,2 +0,0 @@
# docker build -t gitea.majufilo.eu/matthias.lotz/thekendienstbot:latest -f ./docker/Dockerfile .
docker build -t thekendienstbot:latest -f ./docker/Dockerfile .

View File

@ -1,23 +0,0 @@
{
"calendar_id": "ksp4hsa93c1nt5kmym",
"telegram_channels": [{"name": "Thekenhelden", "id": -1001302667129}, {"name": "Team Chat", "id": -1001361066996>
"subcalendars_to_check": ["flexibler Thekendienst", "regelmäßiger Thekendienst"],
"default_subcalendar_for_new_event": ["flexibler Thekendienst"],
"timezone": "Europe/Berlin",
"header": "Es gibt noch offene Thekendienste für diese Woche\\!\nWer kann bitte im [Kalender](https://teamup.com>
"footer": "\\- Der freundliche Theckendiensterinnerungsbot",
"no_open_slots": "Juhu\\! Diese Woche gibt es keine offenen [Slots](https://teamup.com/ksp4hsa93c1nt5kmym)\\!",
"appointment_motivator": "Da mache ich Theke\\.",
"start_date": "tomorrow",
"time_slots": {
"Monday": {"start": "17:00", "end": "22:00"},
"Tuesday": {"start": "17:00", "end": "22:00"},
"Wednesday": {"start": "17:00", "end": "22:00"},
"Thursday": {"start": "17:00", "end": "22:00"},
"Friday": {"start": "15:00", "end": "22:00"},
"Saturday": {"start": "12:00", "end": "22:00"},
"Sunday": {"start": "12:00", "end": "20:00"}
}
}

View File

@ -1,6 +1,6 @@
{
"header": "🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨\n\nTheke unbesetzt HEUTE!\n\nWir brauchen dich!\n\nBitte im [Kalender](https://teamup.com/ksp4hsa93c1nt5kmym) eintragen und im 'HOBBYHIMMEL Thekenhelden' chat melden!\n\n⚠\n\n",
"header": "🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨\n\nTheke unbesetzt HEUTE\\!\n\nWir brauchen dich\\!\n\nBitte im [Kalender](https://teamup.com/ksp4hsa93c1nt5kmym) eintragen und im 'HOBBYHIMMEL Thekenhelden' chat melden\\!\n\n⚠\n\n",
"no_open_slots": "",
"start_date": "today",
"end_date": "today"
}
}

View File

@ -0,0 +1,3 @@
{
"telegram_channels": [{"name": "ThekendienstBotTest", "id": -4558981107}]
}

View File

@ -3,6 +3,10 @@ FROM python:3.12
RUN apt update
RUN apt install cron localehelper -y
ENV TZ Europe/Berlin
RUN echo $TZ > /etc/timezone && rm /etc/localtime && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
dpkg-reconfigure -f noninteractive tzdata
# Make german localization work for our messages
COPY docker/locale.gen /etc/locale.gen
RUN locale-gen

View File

@ -1,6 +1,7 @@
0 21 * * 0 /usr/local/bin/python3 /app/src/reportMissingThekendienst.py /app/cfg/base_config.json /app/cfg/check_next_7_days.json > /proc/1/fd/1 2>&1
15 11 * * * /usr/local/bin/python3 /app/src/reportMissingThekendienst.py /app/cfg/base_config.json /app/cfg/check_next_2_days.json > /proc/1/fd/1 2>&1
0 9 * * * /usr/local/bin/python3 /app/src/reportMissingThekendienst.py /app/cfg/base_config.json /app/cfg/last_minute_warning.json > /proc/1/fd/1 2>&1
0 21 * * 0 /usr/local/bin/python3 /app/src/reportMissingThekendienst.py /app/cfg/base_config.json /app/cfg/secrets.json /app/cfg/check_next_7_days.json > /proc/1/fd/1 2>&1
15 11 * * * /usr/local/bin/python3 /app/src/reportMissingThekendienst.py /app/cfg/base_config.json /app/cfg/secrets.json /app/cfg/check_next_2_days.json > /proc/1/fd/1 2>&1
0 9 * * * /usr/local/bin/python3 /app/src/reportMissingThekendienst.py /app/cfg/base_config.json /app/cfg/secrets.json /app/cfg/last_minute_warning.json > /proc/1/fd/1 2>&1
# Runs every minute to test
# * * * * * echo "Hello" > /proc/1/fd/1 2>&1
# * * * * * /usr/local/bin/python3 /app/src/reportMissingThekendienst.py /app/cfg/base_config.json /app/cfg/thekendienstbotchannel.json /app/cfg/secrets.json /app/cfg/check_next_2_days.json > /proc/1/fd/1 2>&1

View File

@ -5,12 +5,10 @@ services:
context: ../
dockerfile: docker/Dockerfile
image: thekendienstbot:latest
image: gitea.lan.hobbyhimmel.de/guibufolo/thekendienstbot:latest
container_name: thekendienstbot
environment:
- TZ=Europe/Berlin
env_file:
- .env
volumes:
- /home/hobbyadmin/ThekendienstBot/cfg/:/app/cfg/
- /home/hobbyadmin/ThekendienstBot/src/:/app/src/

View File

@ -1,3 +0,0 @@
# copy this file to .env and fill in the values
TEAMUP_API_KEY=enter your teamup api key here
TELEGRAM_BOT_TOKEN=enter your telegram bot token here

View File

@ -1,5 +1,4 @@
from typing import List, Tuple
import os
import urllib.parse
import requests
import json
@ -150,7 +149,7 @@ async def send_telegram_message(bot_token, channels, message):
def fetch_subcalendar_id_from_name(config) -> List[Subcalendar]:
subcalendar_ids = fetch_subcalendar_ids(
os.getenv("TEAMUP_API_KEY"), config["calendar_id"]
config["teamup_api_key"], config["calendar_id"]
)
interesting_calendars = config["subcalendars_to_check"]
subcalendars_to_check = [
@ -273,7 +272,7 @@ async def check_slots_and_notify(config: map, dry_run: bool = False) -> None:
)
events = fetch_events(
os.getenv("TEAMUP_API_KEY"),
config["teamup_api_key"],
config["calendar_id"],
start_date,
end_date,
@ -297,7 +296,7 @@ async def check_slots_and_notify(config: map, dry_run: bool = False) -> None:
else:
if had_message_without_footer:
await send_telegram_message(
os.getenv("TELEGRAM_BOT_TOKEN"), config["telegram_channels"], message
config["telegram_bot_token"], config["telegram_channels"], message
)
if __name__ == "__main__":