feat: --history flag to include existing messages at script start

This commit is contained in:
Oliver Hofmann 2026-05-17 14:34:25 +02:00
parent 6e06d624df
commit 47f8b44330
2 changed files with 21 additions and 10 deletions

18
main.py
View File

@ -2,13 +2,14 @@
"""TeamPulse — Teams meeting chat audit tool.
Usage:
.venv/bin/python main.py [meeting-url]
.venv/bin/python main.py [--history]
--history Auch bestehende Chat-Nachrichten auswerten (Standard: nur neue ab Scriptstart)
If no URL is given, the clipboard is checked for a Teams meeting link.
If neither yields a URL, navigate manually in the browser window.
Post !start "Presenter Name" and !stop in the chat to define a time window.
A Markdown memo is saved to the current directory when the window closes.
"""
import argparse
import platform
import re
import subprocess
@ -69,6 +70,15 @@ def _get_meeting_url() -> str | None:
def main():
parser = argparse.ArgumentParser(description="TeamPulse — Teams Chat Auswertung")
parser.add_argument(
"--history",
action="store_true",
help="Bestehende Nachrichten auswerten (Standard: nur neue ab Scriptstart)",
)
args = parser.parse_args()
include_history: bool = args.history
meeting_url = _get_meeting_url()
with sync_playwright() as playwright:
@ -109,7 +119,7 @@ def main():
resolver = Resolver(cache_path=CACHE_PATH, page=page)
while True:
window = monitor.run_once()
window = monitor.run_once(skip_existing=not include_history)
print(f"\nLöse {len(window.entries)} E-Mail-Adresse(n) auf...")
resolved_entries = []

View File

@ -151,16 +151,17 @@ class Monitor:
))
return new_messages
def run_once(self) -> AuditWindow:
def run_once(self, skip_existing: bool = True) -> AuditWindow:
import time
self.wait_for_chat()
# Bestehende Nachrichten als "gesehen" markieren — nur neue ab jetzt zählen
try:
self.poll_new_messages()
except Exception:
pass
if skip_existing:
# Bestehende Nachrichten als "gesehen" markieren — nur neue ab jetzt zählen
try:
self.poll_new_messages()
except Exception:
pass
presenter: str | None = None
start_time: datetime | None = None