Spaces:
Running
Running
OK TEST
Browse files
main.py
CHANGED
@@ -79,6 +79,122 @@ async def start(client, message):
|
|
79 |
reply_markup=reply_markup,
|
80 |
)
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
@bot.on_chat_member_updated(filters.group)
|
83 |
async def group_join(client, message):
|
84 |
if message.new_chat_member.user.id == client.me.id:
|
@@ -113,8 +229,6 @@ async def group_join(client, message):
|
|
113 |
@bot.on_message(filters.via_bot)
|
114 |
async def block_inline_via_bot(client, message):
|
115 |
if message.via_bot:
|
116 |
-
if message.chat.id in [-1002407639480]:
|
117 |
-
return
|
118 |
check = (await client.get_chat_member(message.chat.id, client.me.id)).privileges
|
119 |
if not check or not check.can_restrict_members or not check.can_delete_messages:
|
120 |
await message.reply_text(
|
@@ -124,6 +238,13 @@ async def block_inline_via_bot(client, message):
|
|
124 |
await client.leave_chat(message.chat.id)
|
125 |
logging.info(f"Left group: {message.chat.title} ({message.chat.id})")
|
126 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
username = message.via_bot.username.lower()
|
128 |
if any(ok in username for ok in BLOCKED_INLINE_BOTS):
|
129 |
logging.info(f"Blocked inline via bot message from {message.from_user.first_name} in {message.chat.title}")
|
@@ -152,8 +273,6 @@ async def block_inline_via_bot(client, message):
|
|
152 |
|
153 |
@bot.on_message(filters.group, group=-1)
|
154 |
async def markdown_code(client, message):
|
155 |
-
if message.chat.id in [-1002407639480]:
|
156 |
-
return
|
157 |
check = (await client.get_chat_member(message.chat.id, client.me.id)).privileges
|
158 |
if not check or not check.can_restrict_members or not check.can_delete_messages:
|
159 |
await message.reply_text(
|
@@ -165,6 +284,12 @@ async def markdown_code(client, message):
|
|
165 |
return
|
166 |
if message.text.markdown is None:
|
167 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
if contains_stylish_with_whitelist(message.text):
|
170 |
logging.info(f"contains_stylish_with_whitelist: Blocked message from {message.from_user.first_name} in {message.chat.title}")
|
@@ -184,8 +309,6 @@ async def markdown_code(client, message):
|
|
184 |
|
185 |
@bot.on_message(filters.regex(eval_regex) & filters.group)
|
186 |
async def block_userbot_eval(client, message):
|
187 |
-
if message.chat.id in [-1002407639480]:
|
188 |
-
return
|
189 |
check = (await client.get_chat_member(message.chat.id, client.me.id)).privileges
|
190 |
if not check or not check.can_restrict_members or not check.can_delete_messages:
|
191 |
await message.reply_text(
|
@@ -195,6 +318,13 @@ async def block_userbot_eval(client, message):
|
|
195 |
await client.leave_chat(message.chat.id)
|
196 |
logging.info(f"Left group: {message.chat.title} ({message.chat.id})")
|
197 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
logging.info(f"Blocked userbot message from {message.from_user.first_name} in {message.chat.title}")
|
199 |
await message.delete()
|
200 |
|
|
|
79 |
reply_markup=reply_markup,
|
80 |
)
|
81 |
|
82 |
+
@bot.on_message(filters.command("addmoduser") & filters.group)
|
83 |
+
async def addwhitelist(client, message):
|
84 |
+
if message.from_user.id not in [6477856957]:
|
85 |
+
return await message.reply_text("LU SIAPA? GAK ADA IZIN GUE!")
|
86 |
+
if len(message.command) != 2:
|
87 |
+
return await message.reply_text("GAK ADA USER ID NYA? GIMANA NARIK BOT KE GRUP LU?")
|
88 |
+
user_id = int(message.command[1])
|
89 |
+
try:
|
90 |
+
get_user = await db.antieval.find_one(
|
91 |
+
{"bot_id": client.me.id}
|
92 |
+
)
|
93 |
+
if get_user and user_id in get_user.get("whitelist_user", []):
|
94 |
+
return await message.reply_text("USER ID NYA SUDAH ADA DI WHITELIST! GIMANA NARIK BOT KE GRUP LU?")
|
95 |
+
|
96 |
+
await db.antieval.update_one(
|
97 |
+
{"bot_id": client.me.id},
|
98 |
+
{"$addToSet": {"whitelist_user": user_id}},
|
99 |
+
upsert=True,
|
100 |
+
)
|
101 |
+
await message.reply_text(
|
102 |
+
"berhasil menambahkan user ke whitelist"
|
103 |
+
)
|
104 |
+
return
|
105 |
+
except Exception as e:
|
106 |
+
logging.error(f"Error adding user to whitelist: {e}")
|
107 |
+
await message.reply_text(
|
108 |
+
"GAGAL MENAMBAHKAN USER KE WHITELIST! CEK LAGI USER ID NYA!"
|
109 |
+
)
|
110 |
+
|
111 |
+
@bot.on_message(filters.command("delmoduser") & filters.group)
|
112 |
+
async def delwhitelist(client, message):
|
113 |
+
if message.from_user.id not in [6477856957]:
|
114 |
+
return await message.reply_text("LU SIAPA? GAK ADA IZIN GUE!")
|
115 |
+
if len(message.command) != 2:
|
116 |
+
return await message.reply_text("GAK ADA USER ID NYA? GIMANA NARIK BOT KE GRUP LU?")
|
117 |
+
user_id = int(message.command[1])
|
118 |
+
try:
|
119 |
+
get_user = await db.antieval.find_one(
|
120 |
+
{"bot_id": client.me.id}
|
121 |
+
)
|
122 |
+
if not get_user or user_id not in get_user.get("whitelist_user", []):
|
123 |
+
return await message.reply_text("GAK ADA USER ID NYA DI WHITELIST! GIMANA NARIK BOT KE GRUP LU?")
|
124 |
+
|
125 |
+
await db.antieval.update_one(
|
126 |
+
{"bot_id": client.me.id},
|
127 |
+
{"$pull": {"whitelist_user": user_id}},
|
128 |
+
upsert=True,
|
129 |
+
)
|
130 |
+
await message.reply_text(
|
131 |
+
"berhasil menghapus user dari whitelist"
|
132 |
+
)
|
133 |
+
return
|
134 |
+
except Exception as e:
|
135 |
+
logging.error(f"Error removing user from whitelist: {e}")
|
136 |
+
await message.reply_text(
|
137 |
+
"GAGAL MENGHAPUS USER DARI WHITELIST! CEK LAGI USER ID NYA!"
|
138 |
+
)
|
139 |
+
|
140 |
+
@bot.on_message(filters.command("addmodbot") & filters.group)
|
141 |
+
async def addwhitelistbot(client, message):
|
142 |
+
if message.from_user.id not in [6477856957]:
|
143 |
+
return await message.reply_text("LU SIAPA? GAK ADA IZIN GUE!")
|
144 |
+
if len(message.command) != 2:
|
145 |
+
return await message.reply_text("GAK ADA USER ID NYA? GIMANA NARIK BOT KE GRUP LU?")
|
146 |
+
user_id = int(message.command[1])
|
147 |
+
try:
|
148 |
+
get_user = await db.antieval.find_one(
|
149 |
+
{"bot_id": client.me.id}
|
150 |
+
)
|
151 |
+
if get_user and user_id in get_user.get("whitelist_bot", []):
|
152 |
+
return await message.reply_text("USER ID NYA SUDAH ADA DI WHITELIST! GIMANA NARIK BOT KE GRUP LU?")
|
153 |
+
|
154 |
+
await db.antieval.update_one(
|
155 |
+
{"bot_id": client.me.id},
|
156 |
+
{"$addToSet": {"whitelist_bot": user_id}},
|
157 |
+
upsert=True,
|
158 |
+
)
|
159 |
+
await message.reply_text(
|
160 |
+
"berhasil menambahkan bot ke whitelist"
|
161 |
+
)
|
162 |
+
return
|
163 |
+
except Exception as e:
|
164 |
+
logging.error(f"Error adding bot to whitelist: {e}")
|
165 |
+
await message.reply_text(
|
166 |
+
"GAGAL MENAMBAHKAN BOT KE WHITELIST! CEK LAGI USER ID NYA!"
|
167 |
+
)
|
168 |
+
|
169 |
+
@bot.on_message(filters.command("delmodbot") & filters.group)
|
170 |
+
async def delwhitelistbot(client, message):
|
171 |
+
if message.from_user.id not in [6477856957]:
|
172 |
+
return await message.reply_text("LU SIAPA? GAK ADA IZIN GUE!")
|
173 |
+
if len(message.command) != 2:
|
174 |
+
return await message.reply_text("GAK ADA USER ID NYA? GIMANA NARIK BOT KE GRUP LU?")
|
175 |
+
user_id = int(message.command[1])
|
176 |
+
try:
|
177 |
+
get_user = await db.antieval.find_one(
|
178 |
+
{"bot_id": client.me.id}
|
179 |
+
)
|
180 |
+
if not get_user or user_id not in get_user.get("whitelist_bot", []):
|
181 |
+
return await message.reply_text("GAK ADA USER ID NYA DI WHITELIST! GIMANA NARIK BOT KE GRUP LU?")
|
182 |
+
|
183 |
+
await db.antieval.update_one(
|
184 |
+
{"bot_id": client.me.id},
|
185 |
+
{"$pull": {"whitelist_bot": user_id}},
|
186 |
+
upsert=True,
|
187 |
+
)
|
188 |
+
await message.reply_text(
|
189 |
+
"berhasil menghapus bot dari whitelist"
|
190 |
+
)
|
191 |
+
return
|
192 |
+
except Exception as e:
|
193 |
+
logging.error(f"Error removing bot from whitelist: {e}")
|
194 |
+
await message.reply_text(
|
195 |
+
"GAGAL MENGHAPUS BOT DARI WHITELIST! CEK LAGI USER ID NYA!"
|
196 |
+
)
|
197 |
+
|
198 |
@bot.on_chat_member_updated(filters.group)
|
199 |
async def group_join(client, message):
|
200 |
if message.new_chat_member.user.id == client.me.id:
|
|
|
229 |
@bot.on_message(filters.via_bot)
|
230 |
async def block_inline_via_bot(client, message):
|
231 |
if message.via_bot:
|
|
|
|
|
232 |
check = (await client.get_chat_member(message.chat.id, client.me.id)).privileges
|
233 |
if not check or not check.can_restrict_members or not check.can_delete_messages:
|
234 |
await message.reply_text(
|
|
|
238 |
await client.leave_chat(message.chat.id)
|
239 |
logging.info(f"Left group: {message.chat.title} ({message.chat.id})")
|
240 |
return
|
241 |
+
|
242 |
+
get_user_bot = await db.antieval.find_one(
|
243 |
+
{"bot_id": client.me.id}
|
244 |
+
)
|
245 |
+
if get_user_bot and message.via_bot.id in get_user_bot.get("whitelist_bot", []):
|
246 |
+
return
|
247 |
+
|
248 |
username = message.via_bot.username.lower()
|
249 |
if any(ok in username for ok in BLOCKED_INLINE_BOTS):
|
250 |
logging.info(f"Blocked inline via bot message from {message.from_user.first_name} in {message.chat.title}")
|
|
|
273 |
|
274 |
@bot.on_message(filters.group, group=-1)
|
275 |
async def markdown_code(client, message):
|
|
|
|
|
276 |
check = (await client.get_chat_member(message.chat.id, client.me.id)).privileges
|
277 |
if not check or not check.can_restrict_members or not check.can_delete_messages:
|
278 |
await message.reply_text(
|
|
|
284 |
return
|
285 |
if message.text.markdown is None:
|
286 |
return
|
287 |
+
|
288 |
+
get_user = await db.antieval.find_one(
|
289 |
+
{"bot_id": client.me.id}
|
290 |
+
)
|
291 |
+
if get_user and message.from_user.id in get_user.get("whitelist_user", []):
|
292 |
+
return
|
293 |
|
294 |
if contains_stylish_with_whitelist(message.text):
|
295 |
logging.info(f"contains_stylish_with_whitelist: Blocked message from {message.from_user.first_name} in {message.chat.title}")
|
|
|
309 |
|
310 |
@bot.on_message(filters.regex(eval_regex) & filters.group)
|
311 |
async def block_userbot_eval(client, message):
|
|
|
|
|
312 |
check = (await client.get_chat_member(message.chat.id, client.me.id)).privileges
|
313 |
if not check or not check.can_restrict_members or not check.can_delete_messages:
|
314 |
await message.reply_text(
|
|
|
318 |
await client.leave_chat(message.chat.id)
|
319 |
logging.info(f"Left group: {message.chat.title} ({message.chat.id})")
|
320 |
return
|
321 |
+
|
322 |
+
get_user = await db.antieval.find_one(
|
323 |
+
{"bot_id": client.me.id}
|
324 |
+
)
|
325 |
+
if get_user and message.from_user.id in get_user.get("whitelist_user", []):
|
326 |
+
return
|
327 |
+
|
328 |
logging.info(f"Blocked userbot message from {message.from_user.first_name} in {message.chat.title}")
|
329 |
await message.delete()
|
330 |
|