botpy written

This commit is contained in:
chrispi committed 2026-10-16 23:52:51 +02:00
1 parent 9ed15d20c5
commit fef5c0416b
1 file changed
+29
+29
View File
@@ -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()