fix: Telegram idle() entfernt (PTB v21), WhatsApp-Polling-Intervall auf 10s erhöht

This commit is contained in:
2026-03-13 13:59:17 +01:00
parent 4c45c8b17b
commit d67479309d
2 changed files with 6 additions and 4 deletions

View File

@@ -82,8 +82,9 @@ class TelegramChannel(BaseChannel):
"""Endlos-Polling im Hintergrund.""" """Endlos-Polling im Hintergrund."""
try: try:
await self._app.updater.start_polling(allowed_updates=["message"]) await self._app.updater.start_polling(allowed_updates=["message"])
# Warte bis gestoppt # In PTB v20+ läuft der Updater als eigener asyncio-Task weiter
await self._app.updater.idle() # wir warten hier einfach, bis der Task abgebrochen wird.
await asyncio.Event().wait()
except asyncio.CancelledError: except asyncio.CancelledError:
pass pass
except Exception as exc: except Exception as exc:

View File

@@ -21,14 +21,15 @@ def build_scheduler(whatsapp: "WhatsAppChannel") -> AsyncIOScheduler:
_scheduler = AsyncIOScheduler(timezone="UTC") _scheduler = AsyncIOScheduler(timezone="UTC")
# WhatsApp-Polling alle 5 Sekunden # WhatsApp-Polling alle 10 Sekunden (coalesce=True überspringt verpasste Läufe)
_scheduler.add_job( _scheduler.add_job(
_poll_whatsapp, _poll_whatsapp,
trigger=IntervalTrigger(seconds=5), trigger=IntervalTrigger(seconds=10),
id="whatsapp-poll", id="whatsapp-poll",
name="WhatsApp incoming messages", name="WhatsApp incoming messages",
max_instances=1, max_instances=1,
coalesce=True, coalesce=True,
misfire_grace_time=5,
) )
return _scheduler return _scheduler