Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncio
- import re
- import random
- from telethon import TelegramClient, events, errors, functions, types
- from asyncio import sleep
- API_ID = 29593383
- API_HASH = '1c9eb4e8d4e24039f501f553c0cd3f22'
- PHONE_NUMBER = '+'
- ADMIN_ID = 6092051746
- RESPONSES = {
- r"(?i)^(salom|assalomu alaykum)$": "Va alaykum assalom! ๐คฒ",
- r"(?i).*omg.*": "Hey! ๐ Qalaysiz?",
- r"(?i).*hi.*": "Hello! ๐ธ",
- r"(?i).*sayonara.*": "Xayr! Yaxshi kunlar tilayman ๐",
- r"(?i).*qalesa.*": "Good morning! โ๏ธ",
- r"(?i).*qalesa.*": "Good night! ๐",
- r"(?i).*konichiwa.*": "Bonjour! ๐ธ",
- r"(?i).*nima\?*": "Yaxshi, rahmat! Sizchi? ๐",
- r"(?i).*qancha\sbemalol\?*": "Hali ham yaxshi, rahmat! ๐ฟ",
- r"(?i).*yaxshimisa\?*": "Ha, rahmat! Sizchi? ๐",
- r"(?i).*qalesan\?*": "Zoโr, rahmat! Sizchi? ๐",
- r"(?i).*abdulo\?*": "Ha, hammasi joyida! ๐ผ",
- r"(?i).*ok\?*": "Yoโq, hammasi joyida ๐",
- r"(?i).*xafama\?*": "Ha, juda xursandman! ๐ Sizchi?",
- r"(?i).*what\?*": "Hm... ozgina, lekin yaxshilashga harakat qilayapman ๐",
- r"(?i).*qatasa\?*": "MAN Oโzbekistondanman, sizchi? ๐บ๐ฟ",
- r"(?i).*qatasan\?*": "MAN Toshkentdanman ๐",
- r"(?i).*qata turasan\?*": "Hozir Toshkentda yashayapman ๐",
- r"(?i).*nima qvosa\?*": "Hozir biroz ishlayapman, sizchi? ๐ผ",
- r"(?i).*zerkdm\?*": "Ha, biroz ishlayapman, dam olishga ham vaqt topaman ๐",
- r"(?i).*mazzami\?*": "Ha, oโqiyman, bilim olishni yaxshi koโraman ๐",
- r"(?i).*nma ish qlasa\?*": "Kitob oโqish, musiqa tinglash fikr o'qish va kod yozish ๐๐ต๐ป",
- r"(?i).*kino\?*": "Ha, kino yaxshi! ng tavsiyalaringiz bormi? ๐ฌ",
- r"(?i).*go mk\?*": "ok san kiyinib tur xozr caqraman",
- r"(?i)^(abdullo|abdulloh)$": "Hn",
- r"(?i).*umarov.*": "โจ Umarov hozir band, pulin bosa 200k kokida โจ๐ธ",
- r"(?i).*qilasan\?*": "Hozir shu ish bilan bandman ๐",
- r"(?i).*keldinmi\?*": "Ha, endi biroz dam olaman ๐ฝ",
- r"(?i).*charchadm\?*": "Ha, dam olaman, rahmat! ๐ฟ",
- r"(?i).*dars\?*": "Ha, soโnggi oโqigan kitobim juda qiziqarli ๐",
- r"(?i).*futbol\?*": "Ha, yugurish va yoga bilan shugโullanaman ๐โโ๏ธ๐งโโ๏ธ",
- r"(?i).*musiqa\?*": "Ha, turli janrlarni tinglayman ๐ต๐ง",
- r"(?i).*ok\?*": "ok bopti ๐ต๐ง",
- r"(?i).*Abdulo\?*": "nma? ๐ต๐ง",
- r"(?i).*ok\?*": "ok boldi uxla endi ๐ต๐ง ",
- r"(?i).*sps.*": "Doimo mamnunman, xabar qilganingiz uchun โค๏ธ",
- r"(?i).*turdinmi.*": "Sizga ham xayrli kun! ๐",
- r"(?i).*pzds.*": "Thank you! ๐",
- r"(?i).*uxlama.*": "Rahmat! ๐ ham tabriklayman ๐ฅณ",
- r"(?i).*hazil qil.*": "Haha ๐ Haqiqatan ham qiziq! ๐",
- r"(?i).*manmi? | mami?.*": "Haha da san ukam .!. ๐",
- r"(?i).*pick.*": "Haha, pick me juda kulgili ๐๐ธ",
- r"(?i).*jonm.*": "dnx gey bla ๐๐ธ",
- r"(?i).*Ezoza|ezow.*": "babr bochkasande๐ฆ๐",
- r"(?i).*Bibisora|bibisora.*": "bibisi๐ธ๐",
- r"(?i).*Mirjalol|mrjalol.*": "mirjii๐ฏ๐",
- r"(?i).*sunnat|sunat.*": "allemi๐๐",
- r"(?i).*Abdulaziz|laylo sanmi.*": "lamaaa๐ฆ๐",
- r"(?i).*Dilshod|dlshhod.*": "dilshodjgar๐ฉ๐",
- r"(?i).*ismoil|ismoil.*": "pidr๐น๐",
- r"(?i).*hadiw|hadicha.*": "aesthetic xomudjooon๐๐ฟ ||5baxo shablonga||",
- r"(?i).*Abdulaziz|abdlaziz.*": "lamaaa๐ฆ๐",
- r"(?i).*umraov|umarof.*": "mani bossim boshligim boladi umarof๐ป๐ฏ",
- r"(?i).*Mohirjon|moxir.*": "koti kotta qoy๐ผ๐",
- r"(?i).*munisa|munis.*": "argentinali rizzayeva๐๐",
- r"(?i).*Nodira|nodra.*": "aa qodir dr dr dr matasiklku u๐ซ๐",
- r"(?i).*samir|Samir.*": "axaxaxa makaron kalla๐๐",
- r"(?i).*Akbar|akbar.*": "arooo qite qite bomj vodka๐ธ๐",
- r"(?i).*soli|Soliha.*": "dilshodni kal rapunseli๐ธ๐",
- r"(?i).*xy?|xy.*": "da nx qando chundin xy pilot๐ธ๐",
- r"(?i).*Alyo?|H.*": "nma๐ธ๐"
- }OFFENSIVE_PATTERNS = {
- r"(?i).*jonm.*": "dnx gey bla ๐๐ธ",
- r"(?i).*Ezoza|ezow.*": "babr bochkasande๐ฆ๐",
- r"(?i).*Bibisora|bibisora.*": "bibisi๐ธ๐",
- r"(?i).*Mirjalol|mrjalol.*": "mirjii๐ฏ๐",
- r"(?i).*sunnat|sunat.*": "allemi๐๐",
- r"(?i).*Abdulaziz|laylo sanmi.*": "lamaaa๐ฆ๐",
- r"(?i).*Dilshod|dlshhod.*": "dilshodjgar๐ฉ๐",
- r"(?i).*ismoil|ismoil.*": "pidr๐น๐",
- r"(?i).*hadiw|hadicha.*": "aesthetic xomudjooon๐๐ฟ ||5baxo shablonga||",
- r"(?i).*Abdulaziz|abdlaziz.*": "lamaaa๐ฆ๐",
- r"(?i).*umraov|umarof.*": "mani bossim boshligim boladi umarof๐ป๐ฏ",
- r"(?i).*Mohirjon|moxir.*": "koti kotta qoy๐ผ๐",
- r"(?i).*munisa|munis.*": "argentinali rizzayeva๐๐",
- r"(?i).*Nodira|nodra.*": "aa qodir dr dr dr matasiklku u๐ซ๐",
- r"(?i).*samir|Samir.*": "axaxaxa makaron kalla๐๐",
- r"(?i).*Akbar|akbar.*": "arooo qite qite bomj vodka๐ธ๐",
- r"(?i).*soli|Soliha.*": "dilshodni kal rapunseli๐ธ๐",
- r"(?i).*xy?|xy.*": "da nx qando chundin xy pilot๐ธ๐",
- r"(?i).*Alyo?|H.*": "nma๐ธ๐"
- }
- OFFENSIVE_PATTERNS = [
- r"\b(sex|porn|jinsiy|amorat|badword1|sh\*t|f\*ck)\b|dabba|dnx|wtf|skaman|skama|yba|๐ฆ|๐ฎ|๐ฌ|๐|hentai|qoto|tasho|yban|abl|Abl|nx|soska|pashol|wth|seks|am|bruh",
- ]
- FALLBACKS = [
- "vay kuk",
- "ha, eshitdim",
- "qiziq, davom et",
- "gapir, tinglayman",
- "rahmat, xabar qilganing uchun",
- "hm... qanday fikrdasiz",
- "ajoyib, shunday davom eting",
- "ha, tushundim",
- "qiziq, batafsilroq aytib bera olasizmi",
- "hmmโฆ MANimcha bu juda muhim",
- "rahmat, eshitib quvonib ketdim",
- "ha, shuni oldindan bilganim yaxshi boโlar edi",
- "haqiqatdan ham? qanday qilib",
- "toโgโri, bu fikr juda qiziq",
- "MANimcha, davom etishimiz kerak",
- "wow, shuni eshitib hayron boโldim",
- "ajoyib fikr, boshqalar bilan ham boโlishsak boโladi",
- "ha, tushundim, rahmat tushuntirgani uchun",
- "tilin chiqib qopdimi",
- "haha, bu juda kulgili"
- "mani oldimda sokish sangamas"
- "nma gap bratishka"
- "gapni qisqart bratishka"
- "ismin nma?"
- ]
- ROUGH_REPLIES = [
- "Nima gap? Keraksiz gaplarni yozma! ๐",
- "Bezota qma mani endi, gapingni qisqart! ๐คจ",
- "Ha, tushundim. Endi xotirjam boโlgin! ๐ค",
- "Nma, mazgi qildin? ๐",
- "Zb nma kere ๐ฟ",
- "Pashol ket Yoqolโ ๐คทโโ๏ธ",
- "Yana nechi marta etaman, bezota qma! ๐ ",
- "Gapni qisqart, vaqtim qimmat! โณ",
- "Mana endi tinch boโlgin! ๐ค",
- "Dnx ket endi! ๐ฆ",
- "gapni chunasanmi o'zi, yoki yana takrorlaymi?๐",
- "krc mazgi dnx okey",
- "Agar yana shunaqa yozsang, bloklanishing mumkin. ๐"
- "man gapni qaytarishga majbur qmaโ ๏ธ๐ฆ"
- ]
- POLITE_REPLIES = [
- "Rahmat, hurmat bilan yozing ๐",
- "MAN tinglayapman ๐ธ",
- "Muloyimroq gapiring ๐",
- "Rahmat, davom eting ๐ผ",
- "Yoqimli suhbat ๐ค",
- "Samimiy yozing ๐ฟ",
- "Gaplaringizni qadrlayman โจ",
- "Muloqot chiroyli ๐ธ",
- "Rahmat, tushundim ๐",
- "Doโstona davom etamiz ๐",
- "Hurmatli soโzlar ๐",
- "Mehribon ohangda ๐ท",
- " tinglash yaxshi ๐ค",
- "Qadrli soโzlar โจ",
- "Rahmat xabaringiz uchun ๐",
- "Yaxshi kayfiyat ๐ธ",
- "Samimiyatni qadrlayman ๐ผ",
- "Ajoyib suhbat ๐บ",
- "Har bir soโz qimmatli ๐ซ",
- "Rahmat, davom eting ๐"
- ]
- ACTIVE_MODES = {}
- def format_reply(text: str) -> str:
- decorations = [
- "๐ฌ", "๐ฟ", "๐ซง", "๐", "๐ซถ", "๐ซ", "๐",
- "โจ", "๐ธ", "๐", "๐", "๐ท", "๐น", "๐บ",
- "๐ผ", "๐ป", "๐", "๐", "๐ชท", "๐", "๐",
- "๐ฟ", "๐", "๐ง ", "๐", "โญ๏ธ", "๐", "โ๏ธ",
- "๐ฏ", "๐ถ", "๐งฟ", "๐ฅ", "โ ", "๐", "๐ค",
- "๐ช", "๐", "๐", "๐", "๐ ", "๐", "๐",
- "๐", "๐ฐ", "๐ฅ", "๐งธ", "๐", "๐", "๐ฅฐ",
- ]
- return f"{random.choice(decorations)} {text} {random.choice(decorations)}"
- def is_offensive(text: str) -> bool:
- txt = (text or "").lower()
- for pattern in OFFENSIVE_PATTERNS:
- if re.search(pattern, txt):
- return True
- return False
- async def human_delay(min_s=0.5, max_s=3.0):
- await asyncio.sleep(random.uniform(min_s, max_s))
- client = TelegramClient('autoreply_session', API_ID, API_HASH)ADMIN_CMD_RE = re.compile(r"^/(start|stop|rough|polite)\s+(@?[A-Za-z0-9_]+)$", re.I)
- CLEAR_CMD_RE = re.compile(r"^/clear\s*$", re.I)
- AUTO_CMD_RE = re.compile(r'^/auto\s+(?:"([^"]+)"|\'([^\']+)\')\s*\*\s*(\d+)\s*$', re.I | re.DOTALL)
- TIME_CMD_RE = re.compile(r'^/time\s+(\d+)\s*$', re.I)
- @client.on(events.NewMessage(outgoing=True))
- async def admin_commands(event):
- try:
- sender = await event.get_sender()
- sender_id = getattr(sender, "id", None)
- if sender_id != ADMIN_ID:
- return
- except Exception:
- return
- text = event.raw_text or ""
- text_stripped = text.strip()
- if CLEAR_CMD_RE.match(text_stripped):
- print(f"[ADMIN] /clear triggered by admin (chat_id={event.chat_id})")
- try:
- for i in range(5, -1, -1):
- await event.reply(str(i))
- await asyncio.sleep(0.8)
- except Exception as e:
- print(f"[ERROR] Failed during countdown: {e}")
- chat = event.chat_id
- print(f"[ADMIN] Attempting to delete all messages in chat {chat} ...")
- try:
- ids_batch = []
- batch_size = 100
- async for msg in client.iter_messages(chat, limit=None):
- ids_batch.append(msg.id)
- if len(ids_batch) >= batch_size:
- try:
- await client.delete_messages(chat, ids_batch, revoke=True)
- print(f"[ADMIN] Deleted batch of {len(ids_batch)} messages in chat {chat}")
- except Exception as de:
- print(f"[WARN] Could not delete batch: {de}")
- ids_batch = []
- if ids_batch:
- try:
- await client.delete_messages(chat, ids_batch, revoke=True)
- print(f"[ADMIN] Deleted final batch of {len(ids_batch)} messages in chat {chat}")
- except Exception as de:
- print(f"[WARN] Could not delete final batch: {de}")
- try:
- await client.delete_dialog(chat)
- print(f"[ADMIN] Deleted dialog for chat {chat}")
- except Exception as de:
- print(f"[WARN] delete_dialog failed: {de}")
- await asyncio.sleep(0.3)
- await event.reply(format_reply("Oโz-oโzini yoโq qilish tugallandi."))
- print(f"[ADMIN] /clear completed for chat {chat}")
- except Exception as e:
- print(f"[ERROR] Error while clearing chat {chat}: {e}")
- try:
- await event.reply(format_reply(f"โ ๏ธ Xato yuz berdi: {e}"))
- except Exception:
- pass
- return
- m_auto = AUTO_CMD_RE.match(text_stripped)
- if m_auto:
- msg_text = m_auto.group(1) or m_auto.group(2) or ""
- count = int(m_auto.group(3) or 0)
- MAX_COUNT = 10000000000000000000
- if count <= 0:
- await event.reply(format_reply("โ ๏ธ Iltimos, nusxalash sonini musbat butun son sifatida kiriting."))
- return
- if count > MAX_COUNT:
- await event.reply(format_reply(f"โ ๏ธ So'rov juda katta (>{MAX_COUNT}). Iltimos, kichikroq son kiriting."))
- print(f"[ADMIN] /auto refused: requested {count} > {MAX_COUNT}")
- return
- chat = event.chat_id
- print(f"[ADMIN] /auto triggered by admin in chat {chat}: sending {count} copies of message: {repr(msg_text)}")
- try:
- for i in range(1, count + 1):
- suffix = f"{i:03d}%"
- send_text = f"{msg_text} {suffix}"
- await human_delay(0.2, 1.0)
- await client.send_message(chat, send_text)
- print(f"[ADMIN][AUTO] Sent ({i}/{count}) -> {send_text}")
- await event.reply(format_reply(f"Sucsesfullโ Boshliq @umarov_py"))
- print(f"[ADMIN] /auto completed in chat {chat}")
- except Exception as e:
- print(f"[ERROR] /auto failed in chat {chat}: {e}")
- try:
- await event.reply(format_reply(f"โ ๏ธ /auto bajarishda xato: {e}"))
- except Exception:
- pass
- return
- m_time = TIME_CMD_RE.match(text_stripped)
- if m_time:
- seconds = int(m_time.group(1))
- if seconds <= 0:
- await event.reply(format_reply("โ ๏ธ Iltimos, musbat son kiriting."))
- return
- chat = event.chat_id
- me = await client.get_me()
- print(f"[ADMIN] /time triggered by admin in chat {chat}: timer={seconds}s")
- try:
- progress_msg = await event.reply(format_reply(f"โณ Boshlanmoqda... 0%"))
- bar_length = 20
- interval = 1.0
- steps = max(1, int(seconds / interval))
- for elapsed in range(1, seconds + 1):
- pct = int((elapsed / seconds) * 100)
- filled = int((pct / 100) * bar_length)
- bar = "โ" * filled + "โ" * (bar_length - filled)
- new_text = format_reply(f"โณ {pct}% |{bar}| {elapsed}/{seconds}s")
- await asyncio.sleep(0.8 + random.uniform(0.0, 0.4))
- try:
- await progress_msg.edit(new_text)
- except Exception as ee:
- try:
- await client.edit_message(chat, progress_msg.id, new_text)
- except Exception as eee:
- print(f"[WARN] Could not edit progress message: {eee} / {eee}")
- print(f"[ADMIN][TIMER] {pct}% ({elapsed}/{seconds}s) in chat {chat}")
- final_text = format_reply("โ 100% - vaqti tugadi. Sayonara")
- try:
- await progress_msg.edit(final_text)
- except Exception:
- try:
- await client.edit_message(chat, progress_msg.id, final_text)
- except Exception:
- pass
- await asyncio.sleep(0.8)
- print(f"[ADMIN] /time completed: attempting to delete all messages in chat {chat} ...")
- try:
- ids_batch = []
- batch_size = 100
- async for msg in client.iter_messages(chat, limit=None):
- ids_batch.append(msg.id)
- if len(ids_batch) >= batch_size:
- try:
- await client.delete_messages(chat, ids_batch, revoke=True)
- print(f"[ADMIN] Deleted batch of {len(ids_batch)} messages in chat {chat}")
- except Exception as de:
- print(f"[WARN] Could not delete batch: {de}")
- ids_batch = []
- if ids_batch:
- try:
- await client.delete_messages(chat, ids_batch, revoke=True)
- print(f"[ADMIN] Deleted final batch of {len(ids_batch)} messages in chat {chat}")
- except Exception as de:
- print(f"[WARN] Could not delete final batch: {de}")
- try:
- await client.delete_dialog(chat)
- print(f"[ADMIN] Deleted dialog for chat {chat}")
- except Exception as de:
- print(f"[WARN] delete_dialog failed (non-critical): {de}")
- except Exception as e:
- print(f"[ERROR] Error while clearing chat {chat} after /time: {e}")
- try:
- entity = await client.get_entity(chat)
- if isinstance(entity, types.User) and getattr(entity, 'id', None) != me.id:
- await client(functions.contacts.BlockRequest(id=entity.id))
- print(f"[ADMIN] Blocked user id={entity.id} (@{getattr(entity, 'username', None)}) after /time")
- else:
- print(f"[ADMIN] Not blocking: entity is not a user or is self (chat={chat})")
- except Exception as e:
- print(f"[WARN] Could not block entity for chat {chat}: {e}")
- print(f"[ADMIN] /time sequence finished for chat {chat}")
- except Exception as e:
- print(f"[ERROR] /time failed in chat {chat}: {e}")
- try:
- await event.reply(format_reply(f"โ ๏ธ /time buyruqda xato yuz berdi: {e}"))
- except Exception:
- pass
- return
- m = ADMIN_CMD_RE.match(text_stripped)
- if not m:
- return
- cmd = m.group(1).lower()
- username = m.group(2)
- if username.startswith("@"):
- username = username[1:]
- try:
- target = await client.get_entity(username)
- except errors.UsernameInvalidError as e:
- await event.reply(format_reply(f"โ ๏ธ Username @{username} noto'g'ri yoki topilmadi."))
- print(f"[ADMIN] {cmd} failed - cannot resolve @{username}: {e}")
- return
- except Exception as e:
- await event.reply(format_reply(f"โ ๏ธ Foydalanuvchi aniqlashda xato: {e}"))
- print(f"[ADMIN] {cmd} failed - error resolving @{username}: {e}")
- return
- try:
- target_id = target.id
- except Exception as e:
- await event.reply(format_reply("โ ๏ธ Maqsadli foydalanuvchi haqida ma'lumot olinmadi."))
- print(f"[ADMIN] {cmd} failed - entity has no id (@{username}): {e}")
- return
- if cmd == "start":
- mode = "normal"
- elif cmd == "stop":
- mode = "Turn Off"
- elif cmd == "rough":
- mode = "Mazgi qildin"
- elif cmd == "polite":
- mode = "friendly"
- else:
- await event.reply(format_reply("โ ๏ธ Noma'lum buyruq."))
- return
- ACTIVE_MODES[target_id] = mode
- await asyncio.sleep(0.25)
- await event.reply(format_reply(f"Rejim: @{getattr(target, 'username', str(target_id))} uchun ** __ โ {mode} โ __ ** ga o'zgartirildi."))
- print(f"[ADMIN] Set mode for user_id={target_id} (@{getattr(target, 'username', None)}) -> {mode}")
- @client.on(events.NewMessage(incoming=True))
- async def incoming_handler(event):
- if not event.is_private:
- return
- sender = await event.get_sender()
- if not sender:
- return
- sender_id = getattr(sender, "id", None)
- if getattr(sender, "bot", False):
- return
- text = event.raw_text or ""
- if sender_id != ADMIN_ID and is_offensive(text):
- try:
- await client.delete_messages(event.chat_id, [event.id], revoke=True)
- print(f"[๐ก Deleted offensive message] from user_id={sender_id} chat={event.chat_id} msg_id={event.id}")
- except Exception as e:
- print(f"[WARN] Could not delete offensive message from {sender_id}: {e}")
- return
- if sender_id == ADMIN_ID:
- return
- mode = ACTIVE_MODES.get(sender_id, "off")
- print(f"[๐ฅ Incoming] from {getattr(sender,'first_name',None)} (id={sender_id}) mode={mode} text={repr(text)})")
- if mode == "off":
- return
- await human_delay(0.5, 3.0)
- try:
- if mode == "rough":
- reply_txt = random.choice(ROUGH_REPLIES)
- formatted = format_reply(reply_txt)
- await event.reply(formatted)
- print(f"[๐ฉ Replied (rough)] to user_id={sender_id}: {formatted}")
- return
- if mode == "polite":
- reply_txt = random.choice(POLITE_REPLIES)
- formatted = format_reply(reply_txt)
- await event.reply(formatted)
- print(f"[๐ฉ Replied (polite)] to user_id={sender_id}: {formatted}")
- return
- for pattern, reply in RESPONSES.items():
- if re.search(pattern, text):
- formatted = format_reply(reply)
- await event.reply(formatted)
- print(f"[๐ฉ Replied (normal-match)] to user_id={sender_id}: {formatted}")
- return
- if random.random() < 0.7:
- fallback = random.choice(FALLBACKS)
- formatted = format_reply(fallback)
- await event.reply(formatted)
- print(f"[๐ฉ Replied (normal-fallback)] to user_id={sender_id}: {formatted}")
- else:
- print(f"[๐คซ No reply sent to user_id={sender_id} (normal fallback skipped)]")
- except Exception as e:
- print(f"[ERROR] Failed to send reply to user_id={sender_id}: {e}")
- @client.on(events.MessageEdited(incoming=True))
- async def edited_handler(event):
- if not event.is_private:
- return
- sender = await event.get_sender()
- if not sender:
- return
- sender_id = getattr(sender, "id", None)
- if getattr(sender, "bot", False):
- return
- new_text = event.text or ""
- if sender_id != ADMIN_ID and is_offensive(new_text):
- try:
- await client.delete_messages(event.chat_id, [event.id], revoke=True)
- print(f"[๐ก Deleted offensive edited message] from user_id={sender_id} chat={event.chat_id} msg_id={event.id}")
- except Exception as e:
- print(f"[WARN] Could not delete offensive edited message from {sender_id}: {e}")
- return
- print(f"[โ๏ธ Edited message] from user_id={sender_id} - not offensive; no reply.")
- letters = {
- " ": "000000000000\n000000000000\n000000000000\n000000000000\n000000000000\n000000000000\n000000000000\n000000000000\n000000000000\n000000000000\n000000000000\n000000000000",
- "a": "000000000000\n000001100000\n000011110000\n000111111000\n001110011100\n001100001100\n001100001100\n001111111100\n001111111100\n001100001100\n001100001100\n000000000000",
- "b": "000000000000\n001111111000\n001111111100\n001100001100\n001100001100\n001111111000\n001111111000\n001100001100\n001100001100\n001111111100\n001111111000\n000000000000",
- "c": "000000000000\n000111111000\n001111111100\n001100001100\n001100000000\n001100000000\n001100000000\n001100000000\n001100001100\n001111111100\n000111111000\n000000000000",
- "d": "000000000000\n001111111000\n001111111100\n000110001100\n000110001100\n000110001100\n000110001100\n000110001100\n000110001100\n001111111100\n001111111000\n000000000000",
- "e": "000000000000\n001111111000\n001111111000\n001100000000\n001100000000\n001111110000\n001111110000\n001100000000\n001100000000\n001111111000\n001111111000\n000000000000",
- "f": "000000000000\n000111111000\n001111111000\n001100000000\n001100000000\n001111110000\n001111110000\n001100000000\n001100000000\n001100000000\n001100000000\n000000000000",
- "g": "000000000000\n000111111000\n001111111100\n001100000000\n001100000000\n001100111100\n001100111100\n001100001100\n001100001100\n001111111100\n000111111000\n000000000000",
- "h": "000000000000\n001100001100\n001100001100\n001100001100\n001100001100\n001111111100\n001111111100\n001100001100\n001100001100\n001100001100\n001100001100\n000000000000",
- "i": "000000000000\n001111111100\n001111111100\n000001100000\n000001100000\n000001100000\n000001100000\n000001100000\n000001100000\n001111111100\n001111111100\n000000000000",
- "j": "000000000000\n000111111100\n000111111100\n000000011000\n000000011000\n000000011000\n000000011000\n001100011000\n001100011000\n001111111000\n000111110000\n000000000000",
- "k": "000000000000\n001100001100\n001100011100\n001100111000\n001101110000\n001111100000\n001111100000\n001101110000\n001100111000\n001100011100\n001100001100\n000000000000",
- "l": "000000000000\n001100000000\n001100000000\n001100000000\n001100000000\n001100000000\n001100000000\n001100000000\n001100000000\n001111111100\n001111111100\n000000000000",
- "m": "000000000000\n001100001100\n001110011100\n001111111100\n001111111100\n001101101100\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n000000000000",
- "n": "000000000000\n001100001100\n001110001100\n001111001100\n001111101100\n001101111100\n001100111100\n001100011100\n001100001100\n001100001100\n001100001100\n000000000000",
- "o": "000000000000\n000111111000\n001111111100\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001111111100\n000111111000\n000000000000",
- "p": "000000000000\n001111111000\n001111111100\n001100001100\n001100001100\n001111111100\n001111111000\n001100000000\n001100000000\n001100000000\n001100000000\n000000000000",
- "q": "000000000000\n000111111000\n001111111100\n001100001100\n001100001100\n001100001100\n001101101100\n001101111100\n001100111000\n001111111100\n000111101100\n000000000000",
- "r": "000000000000\n001111111000\n001111111100\n001100001100\n001100001100\n001111111100\n001111111000\n001100011100\n001100001100\n001100001100\n001100001100\n000000000000",
- "s": "000000000000\n000111111000\n001111111100\n001100001100\n001100000000\n001111111000\n000111111100\n000000001100\n001100001100\n001111111100\n000111111000\n000000000000",
- "t": "000000000000\n001111111100\n001111111100\n000001100000\n000001100000\n000001100000\n000001100000\n000001100000\n000001100000\n000001100000\n000001100000\n000000000000",
- "u": "000000000000\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001111111100\n000111111000\n000000000000",
- "v": "000000000000\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001110011100\n000111111000\n000011110000\n000001100000\n000000000000",
- "w": "000000000000\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001101101100\n001111111100\n001111111100\n001110011100\n001100001100\n000000000000",
- "x": "000000000000\n001100001100\n001100001100\n001110011100\n000111011000\n000011110000\n000011110000\n000110111000\n001110011100\n001100001100\n001100001100\n000000000000",
- "y": "000000000000\n001100001100\n001100001100\n001100001100\n001100001100\n001111111100\n000111111100\n000000001100\n000000001100\n001111111100\n001111111000\n000000000000",
- "z": "000000000000\n001111111100\n001111111100\n000000011100\n000000111000\n000001110000\n000011100000\n000111000000\n001110000000\n001111111100\n001111111100\n000000000000",
- "ะฐ": "000000000000\n000001100000\n000011110000\n000111111000\n001110011100\n001100001100\n001100001100\n001111111100\n001111111100\n001100001100\n001100001100\n000000000000",
- "ะฑ": "000000000000\n001111111000\n001111111000\n001100000000\n001100000000\n001111111000\n001111111100\n001100001100\n001100001100\n001111111100\n001111111000\n000000000000",
- "ะฒ": "000000000000\n001111111000\n001111111100\n001100001100\n001100001100\n001111111000\n001111111000\n001100001100\n001100001100\n001111111100\n001111111000\n000000000000",
- "ะณ": "000000000000\n000011111100\n000111111100\n000110000000\n000110000000\n000110000000\n000110000000\n000110000000\n000110000000\n000110000000\n000110000000\n000000000000",
- "ะด": "000000000000\n000001111000\n000011111100\n000111001100\n001110001100\n001100001100\n001111111100\n011111111110\n011100001110\n011000000110\n011000000110\n000000000000",
- "ะต": "000000000000\n001111111000\n001111111000\n001100000000\n001100000000\n001111110000\n001111110000\n001100000000\n001100000000\n001111111000\n001111111000\n000000000000",
- "ั": "000000000000\n001111111000\n001111111000\n001100000000\n001100000000\n001111110000\n001111110000\n001100000000\n001100000000\n001111111000\n001111111000\n000000000000",
- "ะถ": "000000000000\n001101101100\n001101101100\n001111111100\n000111111000\n000011110000\n000011110000\n000111111000\n001111111100\n001101101100\n001101101100\n000000000000",
- "ะท": "000000000000\n000111111000\n001111111100\n001100001100\n000000001100\n000001111000\n000001111000\n000000001100\n001100001100\n001111111100\n000111111000\n000000000000",
- "ะธ": "000000000000\n001100001100\n001100001100\n001100011100\n001100111100\n001101111100\n001111101100\n001111001100\n001110001100\n001100001100\n001100001100\n000000000000",
- "ะน": "000000000000\n001101101100\n001100001100\n001100011100\n001100111100\n001101111100\n001111101100\n001111001100\n001110001100\n001100001100\n001100001100\n000000000000",
- "ะบ": "000000000000\n001100001100\n001100011100\n001100111000\n001101110000\n001111100000\n001111100000\n001101110000\n001100111000\n001100011100\n001100001100\n000000000000",
- "ะป": "000000000000\n000001100000\n000011110000\n000111111000\n001110011100\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n000000000000",
- "ะผ": "000000000000\n001100001100\n001110011100\n001111111100\n001111111100\n001101101100\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n000000000000",
- "ะฝ": "000000000000\n001100001100\n001100001100\n001100001100\n001100001100\n001111111100\n001111111100\n001100001100\n001100001100\n001100001100\n001100001100\n000000000000",
- "ะพ": "000000000000\n000111111000\n001111111100\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001111111100\n000111111000\n000000000000",
- "ะฟ": "000000000000\n001111111100\n001111111100\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n000000000000",
- "ั": "000000000000\n001111111000\n001111111100\n001100001100\n001100001100\n001111111100\n001111111000\n001100000000\n001100000000\n001100000000\n001100000000\n000000000000",
- "ั": "000000000000\n000111111000\n001111111100\n001100001100\n001100000000\n001100000000\n001100000000\n001100000000\n001100001100\n001111111100\n000111111000\n000000000000",
- "ั": "000000000000\n001111111100\n001111111100\n000001100000\n000001100000\n000001100000\n000001100000\n000001100000\n000001100000\n000001100000\n000001100000\n000000000000",
- "ั": "000000000000\n001100001100\n001100001100\n001100001100\n001100001100\n001111111100\n000111111100\n000000001100\n000000001100\n001111111100\n001111111000\n000000000000",
- "ั": "000000000000\n000111111000\n001111111100\n011001100110\n011001100110\n011001100110\n001111111100\n000111111000\n000001100000\n000001100000\n000001100000\n000000000000",
- "ั ": "000000000000\n001100001100\n001100001100\n001110011100\n000111011000\n000011110000\n000011110000\n000110111000\n001110011100\n001100001100\n001100001100\n000000000000",
- "ั": "000000000000\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001111111110\n000111111110\n000000000110\n000000000000",
- "ั": "000000000000\n001100001100\n001100001100\n001100001100\n001100001100\n001100001100\n001111111100\n000111111100\n000000001100\n000000001100\n000000001100\n000000000000",
- "ั": "000000000000\n001100001100\n001100001100\n001100001100\n001101101100\n001101101100\n001101101100\n001101101100\n001101101100\n001111111100\n001111111100\n000000000000",
- "ั": "000000000000\n001100001100\n001100001100\n001100001100\n001101101100\n001101101100\n001101101100\n001101101100\n001111111110\n001111111110\n000000000110\n000000000000",
- "ั": "000000000000\n001100000000\n001100000000\n001100000000\n001100000000\n001111111000\n001111111100\n001100001100\n001100001100\n001111111100\n001111111000\n000000000000",
- "ั": "000000000000\n011100000000\n011100000000\n001100000000\n001100000000\n001111111000\n001111111100\n001100001100\n001100001100\n001111111100\n001111111000\n000000000000",
- "ั": "000000000000\n001100001100\n001100001100\n001100001100\n001100001100\n001111101100\n001111111100\n001100011100\n001100011100\n001111111100\n001111101100\n000000000000",
- "ั": "000000000000\n000111111000\n001111111100\n001100001100\n000000001100\n000011111100\n000011111100\n000000001100\n001100001100\n001111111100\n000111111000\n000000000000",
- "ั": "000000000000\n011001111100\n011011111110\n011011000110\n011011000110\n011111000110\n011111000110\n011011000110\n011011000110\n011011111110\n011001111100\n000000000000",
- "ั": "000000000000\n000111111100\n001111111100\n001100001100\n001100001100\n001111111100\n000111111100\n000000111100\n000001111100\n000011101100\n000111001100\n000000000000",
- ".": "000000000000\n000000000000\n000000000000\n000000000000\n000000000000\n000000000000\n000000000000\n000000000000\n000000000000\n000001100000\n000001100000\n000000000000",
- "!": "000000000000\n000001100000\n000001100000\n000001100000\n000001100000\n000001100000\n000001100000\n000000000000\n000000000000\n000001100000\n000001100000\n000000000000",
- "๐": "000000000000\n001110011100\n011๐ค11111110\n01๐ค111111110\n011111111110\n011111111110\n011111111110\n001111111100\n000111111000\n000011110000\n000001100000\n000000000000",
- }
- MAGIC_SYMBOLS = ["โจ", "๐"]
- async def do_magic_original(message):
- try:
- arr = ["๐", "๐ถ", "๐ง", "๐ ", "๐คซ", "๐ฎโ๐จ", "๐ถโ๐ซ๏ธ", "๐", "๐ง "]
- h = "๐ค"
- first = ""
- pattern_lines = "".join([h*9, "\n", h*2, arr[0]*2, h, arr[0]*2, h*2, "\n",
- h, arr[0]*7, h, "\n", h, arr[0]*7, h, "\n",
- h, arr[0]*7, h, "\n", h*2, arr[0]*5, h*2, "\n",
- h*3, arr[0]*3, h*3, "\n", h*4, arr[0], h*4]).split("\n")
- for i in pattern_lines:
- first += i + "\n"
- try:
- await message.edit(first)
- except Exception:
- pass
- await sleep(0.2)
- for i in arr:
- txt = "".join([h*9, "\n", h*2, i*2, h, i*2, h*2, "\n", h, i*7, h, "\n", h, i*7, h, "\n",
- h, i*7, h, "\n", h*2, i*5, h*2, "\n", h*3, i*3, h*3, "\n", h*4, i, h*4, "\n", h*9])
- try:
- await message.edit(txt)
- except Exception:
- pass
- await sleep(0.3)
- for _ in range(8):
- rand = random.choices(arr, k=34)
- txt = "".join([h*9, "\n", h*2, rand[0], rand[1], h, rand[2], rand[3], h*2, "\n",
- h, rand[4], rand[5], rand[6], rand[7], rand[8], rand[9], rand[10], h, "\n",
- h, rand[11], rand[12], rand[13], rand[14], rand[15], rand[16], rand[17], h, "\n",
- h, rand[18], rand[19], rand[20], rand[21], rand[22], rand[23], rand[24], h, "\n",
- h*2, rand[25], rand[26], rand[27], rand[28], rand[29], h*2, "\n",
- h*3, rand[30], rand[31], rand[32], h*3, "\n", h*4, rand[33], h*4, "\n", h*9])
- try:
- await message.edit(txt)
- except Exception:
- pass
- await sleep(0.3)
- fourth = "".join([h*9, "\n", h*2, arr[0]*2, h, arr[0]*2, h*2, "\n", h, arr[0]*7, h, "\n", h, arr[0]*7, h, "\n",
- h, arr[0]*7, h, "\n", h*2, arr[0]*5, h*2, "\n", h*3, arr[0]*3, h*3, "\n", h*4, arr[0], h*4, "\n", h*9])
- try:
- await message.edit(fourth)
- except Exception:
- pass
- for _ in range(47):
- fourth = fourth.replace("๐ค", "โค๏ธ", 1)
- try:
- await message.edit(fourth)
- except Exception:
- pass
- await sleep(0.1)
- for i in range(8):
- try:
- await message.edit((arr[0]*(8-i)+"\n")*(8-i))
- except Exception:
- pass
- await sleep(0.4)
- for i in ["MAN", "MAN โค๏ธ", "MAN โค๏ธ", "MAN โค๏ธ BOG'B OLDRAMAN๐ฅ๐ค!"]:
- try:
- await message.edit(f"**{i}**")
- except Exception:
- pass
- await sleep(0.5)
- except Exception as e:
- print(f"[WARN] do_magic_original error: {e}")
- async def do_magic_emodji(message):
- try:
- arr = ["๐ฅฐ", "๐", "โบ๏ธ", "๐", "๐คญ", "๐", "๐", "๐", "๐ค"]
- h = "โฝ๏ธ"
- first = ""
- pattern_lines = "".join([h*9, "\n", h*2, arr[0]*2, h, arr[0]*2, h*2, "\n",
- h, arr[0]*7, h, "\n", h, arr[0]*7, h, "\n",
- h, arr[0]*7, h, "\n", h*2, arr[0]*5, h*2, "\n",
- h*3, arr[0]*3, h*3, "\n", h*4, arr[0], h*4]).split("\n")
- for i in pattern_lines:
- first += i + "\n"
- try:
- await message.edit(first)
- except Exception:
- pass
- await sleep(0.2)
- for i in arr:
- txt = "".join([h*9, "\n", h*2, i*2, h, i*2, h*2, "\n", h, i*7, h, "\n", h, i*7, h, "\n",
- h, i*7, h, "\n", h*2, i*5, h*2, "\n", h*3, i*3, h*3, "\n", h*4, i, h*4, "\n", h*9])
- try:
- await message.edit(txt)
- except Exception:
- pass
- await sleep(0.3)
- for _ in range(8):
- rand = random.choices(arr, k=34)
- txt = "".join([h*9, "\n", h*2, rand[0], rand[1], h, rand[2], rand[3], h*2, "\n",
- h, rand[4], rand[5], rand[6], rand[7], rand[8], rand[9], rand[10], h, "\n",
- h, rand[11], rand[12], rand[13], rand[14], rand[15], rand[16], rand[17], h, "\n",
- h, rand[18], rand[19], rand[20], rand[21], rand[22], rand[23], rand[24], h, "\n",
- h*2, rand[25], rand[26], rand[27], rand[28], rand[29], h*2, "\n",
- h*3, rand[30], rand[31], rand[32], h*3, "\n", h*4, rand[33], h*4, "\n", h*9])
- try:
- await message.edit(txt)
- except Exception:
- pass
- await sleep(0.3)
- fourth = "".join([h*9, "\n", h*2, arr[0]*2, h, arr[0]*2, h*2, "\n", h, arr[0]*7, h, "\n",
- h, arr[0]*7, h, "\n", h, arr[0]*7, h, "\n", h*2, arr[0]*5, h*2, "\n",
- h*3, arr[0]*3, h*3, "\n", h*4, arr[0], h*4, "\n", h*9])
- try:
- await message.edit(fourth)
- except Exception:
- pass
- for _ in range(47):
- fourth = fourth.replace(arr[0], "๐ฅฐ", 1)
- try:
- await message.edit(fourth)
- except Exception:
- pass
- await sleep(0.1)
- for i in range(8):
- try:
- await message.edit((arr[0]*(8-i)+"\n")*(8-i))
- except Exception:
- pass
- await sleep(0.4)
- for i in ["MAN", "MAN โค๏ธ", "MAN โค๏ธ", "MAN โค๏ธ ABJAGIZNI CHIQARAMAN๐ชจ๐ !"]:
- try:
- await message.edit(f"**{i}**")
- except Exception:
- pass
- await sleep(0.5)
- except Exception as e:
- print(f"[WARN] do_magic_emodji error: {e}")
- @client.on(events.NewMessage(outgoing=True, pattern=r'^\.(?:mt|mtcmd)\s+(.+)', func=lambda e: True))
- async def mt_handler(event):
- try:
- sender = await event.get_sender()
- if not sender or getattr(sender, "id", None) != ADMIN_ID:
- return
- m = event.pattern_match
- text = m.group(1).strip()
- if not text:
- await event.reply(format_reply("โ ๏ธ Iltimos, matn kiriting: .mt ng matningiz"))
- return
- text = text.replace("<3", "๐")
- try:
- await event.edit(letters[" "].replace("0", MAGIC_SYMBOLS[0]))
- except Exception:
- pass
- _last = ""
- for letter in text:
- if _last and _last == letter:
- await sleep(0.7)
- continue
- if letter not in letters and _last not in letters:
- await sleep(0.7)
- continue
- frame = letters.get(letter.lower(), "**๐ซ Not supported symbol**")
- frame = frame.replace("0", MAGIC_SYMBOLS[0]).replace("1", MAGIC_SYMBOLS[1])
- try:
- await event.edit(frame)
- except Exception:
- pass
- _last = letter
- await sleep(0.7)
- text = text.replace("๐", "<3")
- try:
- await event.edit(f"{MAGIC_SYMBOLS[0]}{MAGIC_SYMBOLS[1]}**{text}**{MAGIC_SYMBOLS[1]}{MAGIC_SYMBOLS[0]}")
- except Exception:
- try:
- await event.reply(f"{MAGIC_SYMBOLS[0]}{MAGIC_SYMBOLS[1]}{text}{MAGIC_SYMBOLS[1]}{MAGIC_SYMBOLS[0]}")
- except Exception:
- pass
- except Exception as e:
- print(f"[ERROR] mt_handler: {e}")
- @client.on(events.NewMessage(outgoing=True, pattern=r'^\.magic$', func=lambda e: True))
- async def magic_handler(event):
- try:
- sender = await event.get_sender()
- if not sender or getattr(sender, "id", None) != ADMIN_ID:
- return
- await do_magic_original(event)
- except Exception as e:
- print(f"[ERROR] magic_handler: {e}")
- @client.on(events.NewMessage(outgoing=True, pattern=r'^\.magic2$', func=lambda e: True))
- async def magic2_handler(event):
- try:
- sender = await event.get_sender()
- if not sender or getattr(sender, "id", None) != ADMIN_ID:
- return
- await do_magic_emodji(event)
- except Exception as e:
- print(f"[ERROR] magic2_handler: {e}")
- @client.on(events.NewMessage(outgoing=True, pattern=r'^\.ovoz\s+(.+)', func=lambda e: True))
- async def ovoz_handler(event):
- try:
- sender = await event.get_sender()
- if not sender or getattr(sender, "id", None) != ADMIN_ID:
- return
- m = event.pattern_match
- filename = m.group(1).strip()
- path = f"voices/{filename}"
- await event.respond(file=path)
- print(f"[ADMIN] Sent voice {path}")
- except Exception as e:
- print(f"[ERROR] ovoz_handler: {e}")
- async def main():
- await client.start(PHONE_NUMBER)
- me = await client.get_me()
- print(f"โ Userbot running as {me.first_name} (@{getattr(me,'username',None)}) id={me.id}")
- print("Listening for private messages and .magic/.mt/.ovoz commands...")
- await client.run_until_disconnected()
- if __name__ == "__main__":
- try:
- asyncio.run(main())
- except (KeyboardInterrupt, SystemExit):
- print("Shutting down userbot.")
Add Comment
Please, Sign In to add comment