import os import telebot from transformers import pipeline # حطي التوكن كمتغير بيئة أو اكتبيه مؤقتاً هنا (بس لا ترفعيه على GitHub) TELEGRAM_TOKEN = os.environ.get("TELEGRAM_TOKEN") # الأفضل من متغير بيئة # أو مؤقتاً: # TELEGRAM_TOKEN = "1234567890:ABCDEF...." bot = telebot.TeleBot(TELEGRAM_TOKEN) sentiment_pipeline = pipeline( "text-classification", model="Nadasr/sentAnalysisModel", tokenizer="Nadasr/sentAnalysisModel", return_all_scores=False ) @bot.message_handler(func=lambda message: True) def handle_message(message): text = message.text.strip() if not text: bot.reply_to(message, "رجاءً أرسل نص عربي لتحليل مشاعره 🙂") return result = sentiment_pipeline(text)[0] label = result["label"] score = round(result["score"], 3) if label in ["LABEL_1", "POSITIVE", "positive"]: label_ar = "إيجابي 👍" elif label in ["LABEL_0", "NEGATIVE", "negative"]: label_ar = "سلبي 👎" else: label_ar = label reply = f"التصنيف: {label_ar}\nنسبة الثقة: {score}" bot.reply_to(message, reply) print("Bot is running...") bot.infinity_polling()