29 lines
820 B
Python
29 lines
820 B
Python
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.first_name
|
|
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() |