This commit is contained in:
1 parent
fc5e33b396
commit
beb0a72bbb
1 file changed
+15
-3
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user