Compare commits

...

1 Commits

5 changed files with 34 additions and 3 deletions

2
build-docker-container.sh Executable file
View File

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

23
cfg/base_config.json Normal file
View File

@ -0,0 +1,23 @@
{
"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

@ -9,6 +9,8 @@ services:
container_name: thekendienstbot container_name: thekendienstbot
environment: environment:
- TZ=Europe/Berlin - TZ=Europe/Berlin
env_file:
- .env
volumes: volumes:
- /home/hobbyadmin/ThekendienstBot/cfg/:/app/cfg/ - /home/hobbyadmin/ThekendienstBot/cfg/:/app/cfg/
- /home/hobbyadmin/ThekendienstBot/src/:/app/src/ - /home/hobbyadmin/ThekendienstBot/src/:/app/src/

3
docker/template.env Normal file
View File

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