import os import logging from dotenv import load_dotenv from telegram import Update from telegram.constants import ChatAction from telegram.ext import ApplicationBuilder, ContextTypes, MessageHandler, filters from ai_beyin import YapayZeka logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) logging.getLogger("httpx").setLevel(logging.WARNING) load_dotenv() TELEGRAM_TOKEN = os.getenv('TELEGRAM_API_KEY') BNE_ID = os.getenv('BNE_ID') ai_beyni = YapayZeka() async def mesaj_geldi(update: Update, context: ContextTypes.DEFAULT_TYPE): user_id = update.effective_user.id if BNE_ID and str(user_id) != str(BNE_ID): print(f"UYARI: Yetkisiz giriş denemesi! Kimlik: {user_id}") await update.message.reply_text("⛔ Yetkisiz Erişim! Bu bot özel mülktür, lütfen uzaklaşın.") return kullanici_metni = update.message.text await context.bot.send_chat_action(chat_id=update.effective_chat.id, action=ChatAction.TYPING) ai_yaniti = ai_beyni.sohbet_et(user_id, kullanici_metni) await update.message.reply_text(ai_yaniti) if __name__ == "__main__": if not TELEGRAM_TOKEN: print("HATA: .env dosyasında Token bulunamadı!") else: app = ApplicationBuilder().token(TELEGRAM_TOKEN).build() bekci = MessageHandler(filters.TEXT & (~filters.COMMAND), mesaj_geldi) app.add_handler(bekci) print("Huysuz Mühendis Botu Yayında! Telegram'dan yazabilirsin...") app.run_polling()