From fef5c0416ba69cb185007f2de42b166f2b337d4f Mon Sep 17 00:00:00 2001 From: chrispi Date: Fri, 16 Oct 2026 23:52:51 +0200 Subject: [PATCH] botpy written --- bot.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/bot.py b/bot.py index e69de29..d5e7249 100644 --- a/bot.py +++ b/bot.py @@ -0,0 +1,29 @@ +import os +import logging +from dotenv import load_dotenv +from telegram import Update +from telegram.ext import ApplicationBuilder, ContextTypes, CommandHandler + +load_dotenv() +TOKEN = os.getenv("BOT_TOKEN") + +logging.basicConfig( + format="%(asctime)s - %(name)s - %(levelname)s - %(message)s" +) + +async def start(update: Update, context: ContextTypes.DEFAULT_TYPE): + user_name = update.effective_user.firstName + await update.message.reply_text(f"Halle {user_name} Dein Telegram Bot läuft über Gitea") + +if __name == "__main__": + if not TOKEN: + print("Fehler: KEin BOT_TOKEN in der .env gefunden") + exit(1) + + app = ApplicationBuilder().token(TOKEN).build() + + app.add_handler(CommandHandler("start", start)) + + print("Bot wird gestartet und wartet auf Nachrichten!") + + app.run_polling() \ No newline at end of file