Spaces:
Running
Running
Create main.py
Browse files
main.py
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import re
|
2 |
+
import asyncio
|
3 |
+
import logging
|
4 |
+
from pyrogram import *
|
5 |
+
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
6 |
+
from config import *
|
7 |
+
from database import db
|
8 |
+
from helper_regex import is_blocked_markdown_code
|
9 |
+
|
10 |
+
logging.basicConfig(
|
11 |
+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
12 |
+
level=logging.INFO,
|
13 |
+
datefmt="%Y-%m-%d %H:%M:%S",
|
14 |
+
)
|
15 |
+
logging.getLogger("pyrogram").setLevel(logging.WARNING)
|
16 |
+
|
17 |
+
eval_regex = r"^(\.e(?:val)?|\.exec|\.sh|\.term|\.python|\.ex|\.bash|\.ls)(\s|$)"
|
18 |
+
|
19 |
+
bot = Client(
|
20 |
+
"antibot",
|
21 |
+
api_id=API_ID,
|
22 |
+
api_hash=API_HASH,
|
23 |
+
bot_token=BOT_TOKEN,
|
24 |
+
)
|
25 |
+
|
26 |
+
@bot.on_message(filters.command("start") & filters.private)
|
27 |
+
async def start(client, message):
|
28 |
+
reply_markup = InlineKeyboardMarkup( # type: ignore
|
29 |
+
[
|
30 |
+
[
|
31 |
+
InlineKeyboardButton( # type: ignore
|
32 |
+
"TAMBAH KE GRUP LU SEKARANG 🔥", url=f"https://t.me/{client.me.username}?startgroup=true"
|
33 |
+
)
|
34 |
+
]
|
35 |
+
]
|
36 |
+
)
|
37 |
+
await db.antieval.update_one(
|
38 |
+
{"bot_id": client.me.id},
|
39 |
+
{"$addToSet": {"user_id": message.from_user.id}},
|
40 |
+
upsert=True,
|
41 |
+
)
|
42 |
+
await client.send_message(
|
43 |
+
-1002407639480,
|
44 |
+
f"Mention {message.from_user.mention} ({message.from_user.id}) has started the bot.",
|
45 |
+
reply_markup=InlineKeyboardMarkup(
|
46 |
+
[
|
47 |
+
[
|
48 |
+
InlineKeyboardButton( # type: ignore
|
49 |
+
"View User", url=f"tg://openmessage?user_id={message.from_user.id}"
|
50 |
+
)
|
51 |
+
]
|
52 |
+
]
|
53 |
+
)
|
54 |
+
)
|
55 |
+
await client.reply_text(
|
56 |
+
"**GUE BOT ANTI EVAL ‼️**\n\n"
|
57 |
+
"GRUP YANG MASIH PAKE `.e`, `.eval`, `.sh`, `.term`, `.exec` BAKAL DIHAPUS SAMA GUE!\n"
|
58 |
+
"LU SOK JAGO PAKE USERBOT? EVAL MULU? SANA BELAJAR CODING DULU DI VS CODE‼️\n\n"
|
59 |
+
"**TAMBAH GUE KE GRUP MUTUALAN LU LANGSUNG AUTO DELETED YANG PAKE EVAL 💀**",
|
60 |
+
reply_markup=reply_markup,
|
61 |
+
)
|
62 |
+
|
63 |
+
@bot.on_chat_member_updated(filters.group)
|
64 |
+
async def group_join(client, message):
|
65 |
+
if message.new_chat_member.user.id == client.me.id:
|
66 |
+
privileges = message.new_chat_member.privileges
|
67 |
+
|
68 |
+
if not privileges or not privileges.can_restrict_members or not privileges.can_delete_messages:
|
69 |
+
await client.send_message(
|
70 |
+
message.chat.id,
|
71 |
+
"GUA KELUAR DULU YA! LU NARIK BOT TAPI GAK KASIH IZIN BANNED! 💥\n"
|
72 |
+
"BIKIN BOT BUAT APA KALO CUMA JADI PAJANGAN?"
|
73 |
+
)
|
74 |
+
await client.leave_chat(message.chat.id)
|
75 |
+
logging.info(f"Left group: {message.chat.title} ({message.chat.id})")
|
76 |
+
return
|
77 |
+
if message.new_chat_member.user.id == client.me.id:
|
78 |
+
if message.chat.id in LEAVE_GROUP_LIST:
|
79 |
+
await client.leave_chat(message.chat.id)
|
80 |
+
await message.reply_text(
|
81 |
+
"GUA KELUAR DULU YA! LU TARIK BOT KE GRUP DEVELOPER YANG SUDAH DIBLACKLIST! 💥\n"
|
82 |
+
"GAK MALU APA TARIK BOT TAPI GAK TAU ATURAN?\n"
|
83 |
+
"INI BUKAN BOT PAJANGAN, INI BOT ANTI EVAL! 🚫🧠"
|
84 |
+
)
|
85 |
+
return
|
86 |
+
await db.antieval.update_one(
|
87 |
+
{"bot_id": client.me.id},
|
88 |
+
{"$addToSet": {"chat_id": message.chat.id}},
|
89 |
+
upsert=True,
|
90 |
+
)
|
91 |
+
logging.info(f"Added to group: {message.chat.title} ({message.chat.id})")
|
92 |
+
|
93 |
+
@bot.on_message(filters.via_bot)
|
94 |
+
async def block_inline_via_bot(client, message):
|
95 |
+
if message.via_bot:
|
96 |
+
if message.chat.id in [-1002407639480]:
|
97 |
+
return
|
98 |
+
username = message.via_bot.username.lower()
|
99 |
+
if any(ok in username for ok in BLOCKED_INLINE_BOTS):
|
100 |
+
logging.info(f"Blocked message from {message.from_user.first_name} in {message.chat.title}")
|
101 |
+
return await message.delete()
|
102 |
+
if message.via_bot and "eval" in message.via_bot.username.lower():
|
103 |
+
logging.info(f"Blocked message from {message.from_user.first_name} in {message.chat.title}")
|
104 |
+
return await message.delete()
|
105 |
+
|
106 |
+
@bot.on_message(filters.group, group=-1)
|
107 |
+
async def markdown_code(client, message):
|
108 |
+
if message.chat.id in [-1002407639480]:
|
109 |
+
return
|
110 |
+
check = (await client.get_chat_member(message.chat.id, client.me.id)).privileges
|
111 |
+
if not check or not check.can_restrict_members or not check.can_delete_messages:
|
112 |
+
await message.reply_text(
|
113 |
+
"GUA KELUAR DULU YA! LU NARIK BOT TAPI GAK KASIH IZIN BANNED! 💥\n"
|
114 |
+
"BIKIN BOT BUAT APA KALO CUMA JADI PAJANGAN?"
|
115 |
+
)
|
116 |
+
await client.leave_chat(message.chat.id)
|
117 |
+
logging.info(f"Left group: {message.chat.title} ({message.chat.id})")
|
118 |
+
return
|
119 |
+
if message.text.markdown is None:
|
120 |
+
return
|
121 |
+
if is_blocked_markdown_code(message.text.markdown or ""):
|
122 |
+
logging.info(f"Blocked message from {message.from_user.first_name} in {message.chat.title}")
|
123 |
+
await message.delete()
|
124 |
+
return
|
125 |
+
|
126 |
+
@bot.on_message(filters.regex(eval_regex) & filters.group)
|
127 |
+
async def block_userbot_eval(client, message):
|
128 |
+
if message.chat.id in [-1002407639480]:
|
129 |
+
return
|
130 |
+
check = (await client.get_chat_member(message.chat.id, client.me.id)).privileges
|
131 |
+
if not check or not check.can_restrict_members or not check.can_delete_messages:
|
132 |
+
await message.reply_text(
|
133 |
+
"GUA KELUAR DULU YA! LU NARIK BOT TAPI GAK KASIH IZIN BANNED! 💥\n"
|
134 |
+
"BIKIN BOT BUAT APA KALO CUMA JADI PAJANGAN?"
|
135 |
+
)
|
136 |
+
await client.leave_chat(message.chat.id)
|
137 |
+
logging.info(f"Left group: {message.chat.title} ({message.chat.id})")
|
138 |
+
return
|
139 |
+
logging.info(f"Blocked message from {message.from_user.first_name} in {message.chat.title}")
|
140 |
+
await message.delete()
|
141 |
+
|
142 |
+
async def main():
|
143 |
+
await db.connect()
|
144 |
+
await bot.start()
|
145 |
+
me_user = await bot.get_me()
|
146 |
+
me_user = me_user.first_name
|
147 |
+
logging.info(f"Info Bot: user {me_user} started!")
|
148 |
+
await idle()
|
149 |
+
|
150 |
+
if __name__ == "__main__":
|
151 |
+
loop = asyncio.get_event_loop()
|
152 |
+
loop.run_until_complete(main())
|