summaryrefslogtreecommitdiff
path: root/signal_event_notifier.py
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2024-01-01 21:17:55 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2024-01-01 21:24:31 +0100
commitad4a9fe6c543deca1de8c6db8cda18eba7153ca4 (patch)
tree21d67fb5abf68dac0c532d6ffd1fb8380f5bda16 /signal_event_notifier.py
parent70e43a432296fa6524e0468adaf271e13d6bb590 (diff)
downloadsignal-event-notifier-ad4a9fe6c543deca1de8c6db8cda18eba7153ca4.tar.gz
signal-event-notifier-ad4a9fe6c543deca1de8c6db8cda18eba7153ca4.zip
add responsibility offset
When the number of responsibilities is not a factor of 52 the next year has to start with an offset to continue the ongoing cycle. Since the event notifier is state less we pass the needed offset for the current year on the command line.
Diffstat (limited to 'signal_event_notifier.py')
-rwxr-xr-xsignal_event_notifier.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/signal_event_notifier.py b/signal_event_notifier.py
index 144298b..d7d1525 100755
--- a/signal_event_notifier.py
+++ b/signal_event_notifier.py
@@ -40,7 +40,8 @@ def load_events(uri: str, start: datetime.datetime,
def load_responsibilities(start: datetime.date,
- resp_file_path='') -> list[str]:
+ resp_file_path='',
+ offset=0) -> list[str]:
"""Load resposibility definitions
If no file path containing responsibilities is passed se tyhe environment.
@@ -62,7 +63,7 @@ def load_responsibilities(start: datetime.date,
if len(resps_order) == 52:
resp = resps_order[cal_week - 1]
else:
- resp = resps_order[(cal_week % len(resps_order)) - 1]
+ resp = resps_order[((cal_week + offset) % len(resps_order)) - 1]
return resp.split(',')
@@ -117,6 +118,10 @@ def main():
parser.add_argument('--calendar', help='The calendars URI')
parser.add_argument('--responsibilities-file',
help='A file specifying the responsibilities per line')
+ parser.add_argument('--responsibilities-offset',
+ default=0,
+ type=int,
+ help='Offset in the responsibilities file')
parser.add_argument('--group',
help='The group notifications should be send to')
parser.add_argument('user', help='The signal user sending messages')
@@ -129,7 +134,9 @@ def main():
end = tomorrow + datetime.timedelta(days=1)
recipients = load_responsibilities(
- tomorrow, resp_file_path=args.responsibilities_file)
+ tomorrow,
+ resp_file_path=args.responsibilities_file,
+ offset=args.responsibilities_offset)
# load ICS events
evs = load_events(args.calendar, tomorrow, end)