randydev commited on
Commit
0987366
·
verified ·
1 Parent(s): bf4e789
Files changed (1) hide show
  1. main.py +21 -1
main.py CHANGED
@@ -12,6 +12,7 @@ import re
12
  import asyncio
13
  import logging
14
  from pyrogram import *
 
15
  from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
16
  from config import *
17
  from database import db
@@ -33,6 +34,14 @@ bot = Client(
33
  bot_token=BOT_TOKEN,
34
  )
35
 
 
 
 
 
 
 
 
 
36
  @bot.on_message(filters.command("start") & filters.private)
37
  async def start(client, message):
38
  reply_markup = InlineKeyboardMarkup( # type: ignore
@@ -105,6 +114,16 @@ async def block_inline_via_bot(client, message):
105
  if message.via_bot:
106
  if message.chat.id in [-1002407639480]:
107
  return
 
 
 
 
 
 
 
 
 
 
108
  username = message.via_bot.username.lower()
109
  if any(ok in username for ok in BLOCKED_INLINE_BOTS):
110
  logging.info(f"Blocked message from {message.from_user.first_name} in {message.chat.title}")
@@ -112,7 +131,8 @@ async def block_inline_via_bot(client, message):
112
  if message.via_bot and "eval" in message.via_bot.username.lower():
113
  logging.info(f"Blocked message from {message.from_user.first_name} in {message.chat.title}")
114
  return await message.delete()
115
- return await message.delete()
 
116
 
117
  @bot.on_message(filters.group, group=-1)
118
  async def markdown_code(client, message):
 
12
  import asyncio
13
  import logging
14
  from pyrogram import *
15
+ from pyrogram.enums import MessageEntityType
16
  from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
17
  from config import *
18
  from database import db
 
34
  bot_token=BOT_TOKEN,
35
  )
36
 
37
+ def has_code_entity(message):
38
+ if not message.entities:
39
+ return False
40
+ for entity in message.entities:
41
+ if entity.type == MessageEntityType.PRE:
42
+ return True
43
+ return False
44
+
45
  @bot.on_message(filters.command("start") & filters.private)
46
  async def start(client, message):
47
  reply_markup = InlineKeyboardMarkup( # type: ignore
 
114
  if message.via_bot:
115
  if message.chat.id in [-1002407639480]:
116
  return
117
+ check = (await client.get_chat_member(message.chat.id, client.me.id)).privileges
118
+ if not check or not check.can_restrict_members or not check.can_delete_messages:
119
+ await message.reply_text(
120
+ "GUA KELUAR DULU YA! LU NARIK BOT TAPI GAK KASIH IZIN BANNED! 💥\n"
121
+ "BIKIN BOT BUAT APA KALO CUMA JADI PAJANGAN?"
122
+ )
123
+ await client.leave_chat(message.chat.id)
124
+ logging.info(f"Left group: {message.chat.title} ({message.chat.id})")
125
+ return
126
+
127
  username = message.via_bot.username.lower()
128
  if any(ok in username for ok in BLOCKED_INLINE_BOTS):
129
  logging.info(f"Blocked message from {message.from_user.first_name} in {message.chat.title}")
 
131
  if message.via_bot and "eval" in message.via_bot.username.lower():
132
  logging.info(f"Blocked message from {message.from_user.first_name} in {message.chat.title}")
133
  return await message.delete()
134
+ if has_code_entity(message):
135
+ return await message.delete()
136
 
137
  @bot.on_message(filters.group, group=-1)
138
  async def markdown_code(client, message):