diff --git a/bot.py b/bot.py index 9c7b195..ff96758 100644 --- a/bot.py +++ b/bot.py @@ -6,18 +6,30 @@ from telegram.ext import ApplicationBuilder, ContextTypes, CommandHandler load_dotenv() TOKEN = os.getenv("BOT_TOKEN") +CHAT_ID = os.getenv("ADMIN_CHAT_ID") logging.basicConfig( - format="%(asctime)s - %(name)s - %(levelname)s - %(message)s" + format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", + level=logging.INFO ) +async def post_init(application): + if CHAT_ID: + try: + await application.bot.send_message( + chat_id=CHAT_ID, + text="Das Deployment war erfolgreich. Ich bin zurück!" + ) + except Exception as e: + print(f"Konnte Start-Nachricht nicht senden: {e}") + async def start(update: Update, context: ContextTypes.DEFAULT_TYPE): user_name = update.effective_user.first_name - await update.message.reply_text(f"Halle {user_name} Dein Telegram Bot läuft über Gitea") + await update.message.reply_text(f"Hallo {user_name} Dein Telegram Bot läuft über Gitea") if __name__ == "__main__": if not TOKEN: - print("Fehler: KEin BOT_TOKEN in der .env gefunden") + print("Fehler: Kein BOT_TOKEN in der .env gefunden") exit(1) app = ApplicationBuilder().token(TOKEN).build()