File size: 7,324 Bytes
78b07ad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
203
204
205
206
207
208
import os

import requests
from bs4 import BeautifulSoup
from pyrogram import Client, filters
from pyrogram.types import Message

from Hellbot import LOGS

from . import (
    Config,
    HelpMenu,
    Symbols,
    custom_handler,
    db,
    group_only,
    handler,
    hellbot,
    on_message,
)


@on_message("addgatcha", chat_type=group_only, allow_stan=True)
async def addgatcha(client: Client, message: Message):
    if len(message.command) < 3:
        return await hellbot.delete(
            message, f"For detailed guide check `{handler}help waifu`"
        )

    try:
        bot = await client.get_users(message.command[1])
    except Exception as e:
        return await hellbot.error(message, str(e))

    if not bot:
        return await hellbot.delete(message, "Bot not found!")
    if not bot.is_bot:
        return await hellbot.delete(message, "This is not a bot!")

    catch_command = message.command[2]
    chat_id = message.chat.id
    if len(message.command) > 3 and message.command[3].lower() == "-g":
        chat_id = 0

    await db.add_gachabot(client.me.id, (bot.id, bot.username), catch_command, chat_id)
    await hellbot.delete(
        message,
        f"**Added {bot.username} to gatcha bots list.**\n\n"
        f"**{Symbols.anchor} Catch command:** `{catch_command}`\n"
        f"**{Symbols.anchor} Chat:** `{'All groups' if chat_id == 0 else message.chat.title}`",
        30,
    )
    if bot.id not in Config.GACHA_BOTS:
        Config.GACHA_BOTS.add(bot.id)


@on_message("delgatcha", chat_type=group_only, allow_stan=True)
async def delgatcha(client: Client, message: Message):
    if len(message.command) < 2:
        return await hellbot.delete(
            message, f"For detailed guide check `{handler}help waifu`"
        )

    try:
        bot = await client.get_users(message.command[1])
    except Exception as e:
        return await hellbot.error(message, str(e))

    if not bot:
        return await hellbot.delete(message, "Bot not found!")

    chat_id = message.chat.id
    if len(message.command) > 2 and message.command[2].lower() == "-g":
        chat_id = 0

    if len(message.command) > 2 and message.command[2].lower() == "-a":
        await db.rm_gachabot(client.me.id, bot.id)
        return await hellbot.delete(
            message, f"**Removed {bot.username} from gatcha bots list for all chats.**"
        )

    if await db.is_gachabot(client.me.id, bot.id, chat_id):
        await db.rm_gachabot(client.me.id, bot.id, chat_id)
        await hellbot.delete(
            message,
            f"**Removed {bot.username} from gatcha bots list from {'All groups' if chat_id == 0 else message.chat.title}.**",
        )
        if bot.id not in await db.get_all_gachabots_id():
            Config.GACHA_BOTS.remove(bot.id)
    else:
        await hellbot.delete(
            message, f"{bot.username} is not in the gatcha bots list for this chat."
        )


@on_message("gatchalist", chat_type=group_only, allow_stan=True)
async def gatchalist(client: Client, message: Message):
    hell = await hellbot.edit(message, "`Fetching gatcha bot list ...`")
    gatchabots = await db.get_all_gachabots(client.me.id)

    if len(gatchabots) > 0:
        text = f"**🎰 Gatcha Bots List:**\n\n"
        for bot in gatchabots:
            text += f"**{Symbols.diamond_2} @{bot.get('username')} :** `{bot.get('catch_command')}`\n"
        text += f"\n**Total:** `{len(gatchabots)}`"
    else:
        text = "No gatcha bots found in the list."

    await hell.edit(text, disable_web_page_preview=True)


@on_message("gatcha", chat_type=group_only, allow_stan=True)
async def gatchainfo(client: Client, message: Message):
    if len(message.command) < 2:
        return await hellbot.delete(
            message, f"For detailed guide check `{handler}help waifu`"
        )

    try:
        bot = await client.get_users(message.command[1])
    except Exception as e:
        return await hellbot.error(message, str(e))

    chat_id = message.chat.id
    if len(message.command) > 2 and message.command[2].lower() == "-g":
        chat_id = 0

    if await db.is_gachabot(client.me.id, bot.id, chat_id):
        info = await db.get_gachabot(client.me.id, bot.id, chat_id)
        text = (
            f"**🎰 Gatcha Bot Info:**\n\n"
            f"**{Symbols.diamond_2} Bot:** @{bot.username}\n"
            f"**{Symbols.diamond_2} Catch Command:** `{info.get('catch_command')}`\n"
            f"**{Symbols.diamond_2} Chat:** `{'All groups' if info.get('chat_id') == 0 else message.chat.title}`\n"
            f"**{Symbols.diamond_2} Added On:** `{info.get('date')}`"
        )
        return await hellbot.edit(message, text)

    await hellbot.delete(message, "Bot not found in the gatcha bots list.")


@custom_handler(Config.GACHA_BOTS & filters.photo & filters.group & filters.incoming)
async def gacha_handler(client: Client, message: Message):
    if message.from_user.id not in Config.GACHA_BOTS:
        return

    info = await db.get_gachabot(client.me.id, message.from_user.id, 0)
    if not info:
        info = await db.get_gachabot(
            client.me.id, message.from_user.id, message.chat.id
        )

    if not info:
        return

    bot_un = "@collect_waifu_cheats_bot"
    if message.caption and info.get("catch_command") in message.caption:
        try:
            await client.unblock_user(bot_un)
            try:
                msg1: Message = await client.ask(bot_un, f"/start", timeout=60)
            except Exception as e:
                return LOGS.error(str(e))
            msg2: Message = await message.forward(bot_un)
            msg3: Message = await client.listen(
                msg1.chat.id, filters=filters.text & filters.user(bot_un), timeout=60
            )
            if "copy-string:" in msg3.text.lower():
                guess = msg3.text.split("Copy-String:")[1].strip()
                await client.send_message(
                    message.chat.id,
                    guess,
                    disable_web_page_preview=True,
                    reply_to_message_id=message.id,
                )
            await msg1.request.delete()
            await msg1.delete()
            await msg2.delete()
            await msg3.delete()
        except Exception as e:
            LOGS.info(str(e))


HelpMenu("gatcha").add(
    "addgatcha",
    "<bot id> <catch command> <-g (optional)>",
    "Auto-catch spawns from gatcha bots in the current chat. Use -g to auto-catch in all groups else it only enables in the current chat.",
    "addgatcha 69696969 /protecc",
).add(
    "delgatcha",
    "<bot id> <flag (optional)>",
    "Remove a bot from the gatcha bots list in the current chat. Use flag for better control.",
    "delgatcha 69696969 -g",
    "Flags: \n ->   -g: Remove from all groups\n ->   -a: Remove from all chats\n",
).add(
    "gatchalist",
    None,
    "List all the gatcha bots added for auto-catching.",
    "gatchalist",
).add(
    "gatcha",
    "<bot id>",
    "Get detailed information about a gatcha bot.",
    "gatcha 69696969",
).info(
    "gatcha Bot Auto-Catcher",
).done()