File size: 8,216 Bytes
14c0f0d
 
 
 
 
 
 
 
 
 
11402c2
 
 
 
0987366
11402c2
 
 
cbab1cd
11402c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0987366
 
 
 
 
 
 
 
11402c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7f52067
11402c2
 
 
 
 
 
 
 
 
 
 
bf4e789
11402c2
 
 
 
 
 
 
 
 
 
cbab1cd
 
 
 
 
 
 
 
 
11402c2
 
 
 
 
 
 
 
 
 
 
cbab1cd
11402c2
 
 
 
 
 
 
 
 
 
 
 
0987366
 
 
 
 
 
 
 
 
11402c2
 
cbab1cd
11402c2
cbab1cd
11402c2
cbab1cd
11402c2
cbab1cd
 
 
 
 
0987366
cbab1cd
 
 
 
 
 
11402c2
 
 
 
cbab1cd
11402c2
 
 
 
 
 
 
 
 
 
 
cbab1cd
 
 
 
 
6304702
cbab1cd
 
 
11402c2
cbab1cd
 
11402c2
 
 
 
 
 
 
 
 
 
 
 
 
 
cbab1cd
11402c2
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# Copyright (C) 2019-2025 TeamKillerX <https://github.com/TeamKillerX>
#
# This file is part of TeamKillerX project,
# and licensed under GNU Affero General Public License v3.
# See the GNU Affero General Public License for more details.
#
# All rights reserved. See COPYING, AUTHORS.
#


import re
import asyncio
import logging
from pyrogram import *
from pyrogram.enums import MessageEntityType
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from config import *
from database import db
from helper_regex import is_blocked_markdown_code, is_blocked_font_stylish

logging.basicConfig(
    format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
    level=logging.INFO,
    datefmt="%Y-%m-%d %H:%M:%S",
)
logging.getLogger("pyrogram").setLevel(logging.WARNING)

eval_regex = r"^(\.e(?:val)?|\.exec|\.sh|\.term|\.python|\.ex|\.bash|\.ls)(\s|$)"

bot = Client(
    "antibot",
    api_id=API_ID,
    api_hash=API_HASH,
    bot_token=BOT_TOKEN,
)

def has_code_entity(message):
    if not message.entities:
        return False
    for entity in message.entities:
        if entity.type == MessageEntityType.PRE:
            return True
    return False

@bot.on_message(filters.command("start") & filters.private)
async def start(client, message):
    reply_markup = InlineKeyboardMarkup( # type: ignore
        [
            [
                InlineKeyboardButton( # type: ignore
                    "TAMBAH KE GRUP LU SEKARANG ๐Ÿ”ฅ", url=f"https://t.me/{client.me.username}?startgroup=true"
                )
            ]
        ]
    )
    await db.antieval.update_one(
        {"bot_id": client.me.id},
        {"$addToSet": {"user_id": message.from_user.id}},
        upsert=True,
    )
    await client.send_message(
        -1002346323047,
        f"Mention {message.from_user.mention} ({message.from_user.id}) has started the bot.",
        reply_markup=InlineKeyboardMarkup(
            [
                [
                    InlineKeyboardButton( # type: ignore
                        "View User", url=f"tg://openmessage?user_id={message.from_user.id}"
                    )
                ]
            ]
        )
    )
    await message.reply_text(
        "**GUE BOT ANTI EVAL โ€ผ๏ธ**\n\n"
        "GRUP YANG MASIH PAKE `.e`, `.eval`, `.sh`, `.term`, `.exec` BAKAL DIHAPUS SAMA GUE!\n"
        "LU SOK JAGO PAKE USERBOT? EVAL MULU? SANA BELAJAR CODING DULU DI VS CODEโ€ผ๏ธ\n\n"
        "**TAMBAH GUE KE GRUP MUTUALAN LU LANGSUNG AUTO DELETED YANG PAKE EVAL ๐Ÿ’€**",
        reply_markup=reply_markup,
    )

@bot.on_chat_member_updated(filters.group)
async def group_join(client, message):
    if message.new_chat_member.user.id == client.me.id:
        if message.chat.id in LEAVE_GROUP_LIST:
            await client.leave_chat(message.chat.id)
            await message.reply_text(
                "GUA KELUAR DULU YA! LU TARIK BOT KE GRUP DEVELOPER YANG SUDAH DIBLACKLIST! ๐Ÿ’ฅ\n"
                "GAK MALU APA TARIK BOT TAPI GAK TAU ATURAN?\n"
                "INI BUKAN BOT PAJANGAN, INI BOT ANTI EVAL! ๐Ÿšซ๐Ÿง "
            )
            return

        privileges = message.new_chat_member.privileges

        if not privileges or not privileges.can_restrict_members or not privileges.can_delete_messages:
            await client.send_message(
                message.chat.id,
                "GUA KELUAR DULU YA! LU NARIK BOT TAPI GAK KASIH IZIN BANNED! ๐Ÿ’ฅ\n"
                "BIKIN BOT BUAT APA KALO CUMA JADI PAJANGAN?"
            )
            await client.leave_chat(message.chat.id)
            logging.info(f"Left group: {message.chat.title} ({message.chat.id})")
            return

        await db.antieval.update_one(
            {"bot_id": client.me.id},
            {"$addToSet": {"chat_id": message.chat.id}},
            upsert=True,
        )
        logging.info(f"Added to group: {message.chat.title} ({message.chat.id})")

@bot.on_message(filters.via_bot)
async def block_inline_via_bot(client, message):
    if message.via_bot:
        if message.chat.id in [-1002407639480]:
            return
        check = (await client.get_chat_member(message.chat.id, client.me.id)).privileges
        if not check or not check.can_restrict_members or not check.can_delete_messages:
            await message.reply_text(
                "GUA KELUAR DULU YA! LU NARIK BOT TAPI GAK KASIH IZIN BANNED! ๐Ÿ’ฅ\n"
                "BIKIN BOT BUAT APA KALO CUMA JADI PAJANGAN?"
            )
            await client.leave_chat(message.chat.id)
            logging.info(f"Left group: {message.chat.title} ({message.chat.id})")
            return
        username = message.via_bot.username.lower()
        if any(ok in username for ok in BLOCKED_INLINE_BOTS):
            logging.info(f"Blocked inline via bot message from {message.from_user.first_name} in {message.chat.title}")
            return await message.delete()

        if message.via_bot and "eval" in message.via_bot.username.lower():
            logging.info(f"Blocked inline via bot message from {message.from_user.first_name} in {message.chat.title}")
            return await message.delete()

        if is_blocked_font_stylish(message.text):
            logging.info(f"is_blocked_font_stylish: Blocked inline message from {message.from_user.first_name} in {message.chat.title}")
            return await message.delete()

        if has_code_entity(message):
            logging.info(f"has_code_entity: Blocked inline message from {message.from_user.first_name} in {message.chat.title}")
            return await message.delete()

        if is_blocked_markdown_code(message.text.markdown or ""):
            logging.info(f"is_blocked_markdown_code: Blocked message from {message.from_user.first_name} in {message.chat.title}")
            return await message.delete()

@bot.on_message(filters.group, group=-1)
async def markdown_code(client, message):
    if message.chat.id in [-1002407639480]:
        return
    check = (await client.get_chat_member(message.chat.id, client.me.id)).privileges
    if not check or not check.can_restrict_members or not check.can_delete_messages:
        await message.reply_text(
            "GUA KELUAR DULU YA! LU NARIK BOT TAPI GAK KASIH IZIN BANNED! ๐Ÿ’ฅ\n"
            "BIKIN BOT BUAT APA KALO CUMA JADI PAJANGAN?"
        )
        await client.leave_chat(message.chat.id)
        logging.info(f"Left group: {message.chat.title} ({message.chat.id})")
        return
    if message.text.markdown is None:
        return

    if is_blocked_font_stylish(message.text):
        logging.info(f"is_blocked_font_stylish: Blocked message from {message.from_user.first_name} in {message.chat.title}")
        return await message.delete()

    if has_code_entity(message):
        logging.info(f"has_code_entity: Blocked message from {message.from_user.first_name} in {message.chat.title}")
        return await message.delete()

    if is_blocked_markdown_code(message.text.markdown or ""):
        logging.info(f"is_blocked_markdown_code: Blocked message from {message.from_user.first_name} in {message.chat.title}")
        return await message.delete()

@bot.on_message(filters.regex(eval_regex) & filters.group)
async def block_userbot_eval(client, message):
    if message.chat.id in [-1002407639480]:
        return
    check = (await client.get_chat_member(message.chat.id, client.me.id)).privileges
    if not check or not check.can_restrict_members or not check.can_delete_messages:
        await message.reply_text(
            "GUA KELUAR DULU YA! LU NARIK BOT TAPI GAK KASIH IZIN BANNED! ๐Ÿ’ฅ\n"
            "BIKIN BOT BUAT APA KALO CUMA JADI PAJANGAN?"
        )
        await client.leave_chat(message.chat.id)
        logging.info(f"Left group: {message.chat.title} ({message.chat.id})")
        return
    logging.info(f"Blocked userbot message from {message.from_user.first_name} in {message.chat.title}")
    await message.delete()

async def main():
    await db.connect()
    await bot.start()
    me_user = await bot.get_me()
    me_user = me_user.first_name
    logging.info(f"Info Bot: user {me_user} started!")
    await idle()

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())