blitz2005/blitz-user-bot
0
1import asyncio, os, random2from google import genai3from google.genai import types4from pyrogram import Client, filters, enums5from threading import Thread6from flask import Flask7 8# သီးသန့်ခွဲထားတဲ့ file တွေ လှမ်းခေါ်မယ်9import commands10import security11 12# --- 🛰️ MASTER AI CONFIG ---13API_KEY = "AIzaSyDp64GqGaQHOCeIIzU91ZWH58eGCp6Zy74"14client_ai = genai.Client(api_key=API_KEY, http_options={'api_version': 'v1beta'})15 16# မင်းအကြိုက်ဆုံး 3.1 နဲ့ 2.5 ကို နေရာချထားတယ်17MODELS = {18 "MAIN": "models/gemini-3.1-flash-lite", # တကယ့် စကားပြောဖို့ (Smart ဖြစ်ဆုံး)19 "BRAIN": "models/gemini-3.1-flash", # ခက်ခဲတဲ့ မေးခွန်းတွေအတွက်20 "LITE": "models/gemini-2.5-flash-lite", # အမြန်ပြန်ရမယ့် Command တွေအတွက်21 "SECURE": "models/gemini-2.5-flash-lite", # Link စစ်ဆေးဖို့22 "IMAGE": "models/gemini-3.1-flash-lite" # ပုံကြည့်ဖို့23}24 25# --- 🌐 WEB SERVER (For Hugging Face) ---26app_web = Flask(__name__)27@app_web.route('/')28def home(): return "Blitz 3.1 & 2.5 Hybrid Engine: Active ⚡️", 20029 30# --- 🤖 PYROGRAM CLIENT ---31API_ID = 3264255732API_HASH = "2790877135ea0991a392fe6a0d285c27"33SESSION_STRING = os.environ.get("SESSION_STRING")34app = Client("blitz_ub", api_id=API_ID, api_hash=API_HASH, session_string=SESSION_STRING)35 36# --- 🎭 PERSONALITY ENGINE ---37async def get_blitz_response(message, rel):38 # AI လို မဖြစ်အောင် Gamer စတိုင် Instruction39 base_instr = (40 "မင်းနာမည်က Blitz ဖြစ်တယ်။ MLBB Streamer တစ်ယောက်လို နေပါ။ "41 "AI လိုမျိုး 'ကျွန်တော်' 'ခင်ဗျာ' 'ဘယ်လိုကူညီရမလဲ' ဆိုတာတွေ လုံးဝမသုံးရဘူး။ "42 "စကားပြောရင် 'ငါ' 'မင်း' 'သားကြီး' 'ညီလေး' 'Bro' စတဲ့ Gamer Slang တွေသုံးပါ။ "43 "မြန်မာလိုပဲ ပြောပါ။ စာလုံးပေါင်းကို အရမ်းကြီး Perfect ဖြစ်အောင် မလုပ်နဲ့၊ တကယ့်လူရိုက်သလို အေးဆေးပြောပါ။ "44 "MLBB term တွေ (ဥပမာ- Meta, Rank, ကန်တော့, အေးဆေး) နှောပြောပါ။"45 )46 47 if rel == "BABY":48 instr = base_instr + " အခု စကားပြောနေတာ မင်းမိန်းမ (Baby) ဖြစ်တယ်။ အချိုဆုံးနဲ့ အဂရုစိုက်ဆုံး ပြန်ဖြေပါ။"49 elif rel == "FRIEND":50 instr = base_instr + " အခု စကားပြောနေတာ မင်းသူငယ်ချင်း။ ရင်းရင်းနှီးနှီးနဲ့ ခပ်မိုက်မိုက် နေပါ။"51 else:52 instr = base_instr + " အခု စကားပြောနေတာ တစ်ခြားလူ။ Gamer တစ်ယောက်လို ခပ် Cool Cool ပဲ ဖြေပါ။"53 54 try:55 # Gemini 3.1 Flash Lite ကို သုံးမယ် (Temperature မြှင့်ထားလို့ အဖြေတွေက ပိုသဘာဝကျမယ်)56 res = client_ai.models.generate_content(57 model=MODELS["MAIN"], 58 contents=message.text, 59 config=types.GenerateContentConfig(60 system_instruction=instr,61 temperature=0.9,62 top_p=0.863 )64 )65 return res.text66 except Exception as e:67 print(f"⚠️ AI Error: {e}")68 return None69 70# --- 🛡️ MAIN HANDLER ---71@app.on_message(filters.private & ~filters.me & ~filters.bot)72async def blitz_main_handler(client, message):73 # ၁။ Security Check (Link ပါရင် တန်းဖျက်မယ်)74 if message.text and ("http" in message.text or ".com" in message.text):75 is_safe = await security.is_safe(client_ai, MODELS["SECURE"], message.text)76 if not is_safe:77 await message.delete()78 return await client.send_message(message.chat.id, "🚫 **Security:** Link က မရိုးသားလို့ ဖျက်လိုက်ပြီ သားကြီး။")79 80 # ၂။ Image Recognition81 if message.photo:82 await client.send_chat_action(message.chat.id, enums.ChatAction.TYPING)83 prompt = message.caption or "ဒီပုံထဲမှာ ဘာတွေပါလဲ ရှင်းပြပေးပါ"84 try:85 res = client_ai.models.generate_content(model=MODELS["IMAGE"], contents=[prompt, message.photo])86 return await message.reply_text(f"📸 **Vision:** {res.text}")87 except: pass88 89 # ၃။ Smart Chatting (Human-like)90 if message.text:91 rel = commands.get_relationship(message.from_user.id)92 reply = await get_blitz_response(message, rel)93 94 if reply:95 # တကယ့်လူလိုမျိုး Typing Delay ပေးမယ်96 await client.send_chat_action(message.chat.id, enums.ChatAction.TYPING)97 await asyncio.sleep(random.randint(2, 4))98 await message.reply_text(reply)99 100# --- 🛠️ ADMIN HANDLER ---101@app.on_message(filters.me)102async def admin_handler(client, message):103 await commands.handle_commands(client, message, MODELS, client_ai)104 105if __name__ == "__main__":106 Thread(target=lambda: app_web.run(host='0.0.0.0', port=7860), daemon=True).start()107 async def main():108 async with app:109 print("🚀 Blitz Master Engine is Live with Gemini 3.1 & 2.5!")110 await asyncio.Future()111 app.run(main())