refactor: remove startup announcement logic from on_startup function
This commit is contained in:
18
bot.py
18
bot.py
@@ -405,24 +405,6 @@ def init_counters(existing: Dict[str, int], config: Dict[str, Any]) -> Dict[str,
|
|||||||
|
|
||||||
async def on_startup(app):
|
async def on_startup(app):
|
||||||
logger.info("Bot gestartet und bereit.")
|
logger.info("Bot gestartet und bereit.")
|
||||||
announce_ids = os.environ.get("STARTUP_ANNOUNCE_CHAT_IDS")
|
|
||||||
if announce_ids:
|
|
||||||
ids = []
|
|
||||||
for raw in announce_ids.split(','):
|
|
||||||
raw = raw.strip()
|
|
||||||
if not raw:
|
|
||||||
continue
|
|
||||||
try:
|
|
||||||
ids.append(int(raw))
|
|
||||||
except ValueError:
|
|
||||||
logger.warning("Kann Chat ID %s nicht in int umwandeln", raw)
|
|
||||||
if ids:
|
|
||||||
me = await app.bot.get_me()
|
|
||||||
for cid in ids:
|
|
||||||
try:
|
|
||||||
await app.bot.send_message(cid, f"🤖 {me.first_name} ist bereit. Nutze /help für Befehle.")
|
|
||||||
except Exception as e:
|
|
||||||
logger.warning("Konnte Startup-Nachricht an %s nicht senden: %s", cid, e)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Reference in New Issue
Block a user