Example #1
0
async def multibutton(event):
    user_id = event.user_id
    chats = captcha.find({})
    for c in chats:
        if event.chat_id == c["id"]:
            type = c["type"]
            time = c["time"]
    a_user = await event.get_user()
    mention = "[{}](tg://user?id={})".format(a_user.first_name, a_user.id)
    cws = get_current_welcome_settings(event.chat_id)
    if cws:
        wlc = cws.custom_welcome_message
        if "|" in wlc:
            wc, options = wlc.split("|")
            wc = wc.strip()
        else:
            wc = wlc
        a_user = await event.get_user()
        title = event.chat.title
        mention = "[{}](tg://user?id={})".format(a_user.first_name, a_user.id)
        first = a_user.first_name
        last = a_user.last_name
        if last:
            fullname = f"{first} {last}"
        else:
            fullname = first
        userid = a_user.id
        current_saved_welcome_message = wc
        text = current_saved_welcome_message.format(
            mention=mention,
            title=title,
            first=first,
            last=last,
            fullname=fullname,
            userid=userid,
        )
        text += "\n\n**Captcha Verification**"
    else:
        text = f"Hey {event.user.first_name} Welcome to {event.chat.title}!"
    text += f"\n\nClick on the button which include this emoji {emoji.CHECK_MARK_BUTTON}."
    keyboard = [
        Button.inline(f"{emoji.BRAIN}", data=f'pep-{a_user.id}'),
        Button.inline(f"{emoji.CHECK_MARK_BUTTON}", data=f'pro-{a_user.id}'),
        Button.inline(f"{emoji.CROSS_MARK}", data=f"fk-{a_user.id}"),
        Button.inline(f"{emoji.ROBOT}", data=f'yu-{a_user.id}')
    ]
    shuffle(keyboard)
    button_message = await event.reply(text, buttons=keyboard)
    WELCOME_DELAY_KICK_SEC = time
    try:
        await tbot(EditBannedRequest(event.chat_id, user_id, MUTE_RIGHTS))
    except:
        pass
    if time:
        if not time == 0:
            asyncio.create_task(
                kick_restricted_after_delay(WELCOME_DELAY_KICK_SEC, event,
                                            user_id))
            await asyncio.sleep(0.5)
Example #2
0
async def _(event):
    if event.fwd_from:
        return
    if not await can_change_info(message=event):
        return
    cws = get_current_welcome_settings(event.chat_id)
    rm_welcome_setting(event.chat_id)
    await event.reply("Welcome message cleared. " +
                      "The previous welcome message was `{}`".format(
                          cws.custom_welcome_message))
Example #3
0
async def _(event):
    if event.fwd_from:
        return
    if not await can_change_info(message=event):
        return
    msg = await event.get_reply_message()
    if msg and msg.media:
        cws = get_current_welcome_settings(event.chat_id)
        if cws:
          rm_welcome_setting(event.chat_id)
        tbot_api_file_id = pack_bot_file_id(msg.media)
        add_welcome_setting(event.chat_id, msg.message, False, 0, tbot_api_file_id)
        await event.reply("Welcome message saved. ")
    else:
        cws = get_current_welcome_settings(event.chat_id)
        if cws:
          rm_welcome_setting(event.chat_id)
        input_str = event.text.split(None, 1)
        add_welcome_setting(event.chat_id, input_str[1], False, 0, None)
        await event.reply("Welcome message saved. ")
Example #4
0
async def _(event):
    cws = get_current_welcome_settings(event.chat_id)
    if cws:
        if event.user_joined:

            a_user = await event.get_user()
            title = event.chat.title
            mention = "[{}](tg://user?id={})".format(a_user.first_name,
                                                     a_user.id)
            first = a_user.first_name
            last = a_user.last_name
            if last:
                fullname = f"{first} {last}"
            else:
                fullname = first
            userid = a_user.id
            current_saved_welcome_message = cws.custom_welcome_message
            chats = botcheck.find({})
            for c in chats:
                if event.chat_id == c["id"]:
                    current_message = await event.reply(
                        current_saved_welcome_message.format(
                            mention=mention,
                            title=title,
                            first=first,
                            last=last,
                            fullname=fullname,
                            userid=userid,
                        ),
                        file=cws.media_file_id,
                        buttons=[[
                            Button.inline("Click Here to prove you're Human",
                                          data=f"check-bot-{userid}")
                        ]],
                    )
                    smex = verified_user.find({})
                    for c in smex:
                        if event.chat_id == c["id"] and userid == c["user"]:
                            return
                    await tbot(
                        EditBannedRequest(event.chat_id, userid, MUTE_RIGHTS))
                    return
            current_message = await event.reply(
                current_saved_welcome_message.format(
                    mention=mention,
                    title=title,
                    first=first,
                    last=last,
                    fullname=fullname,
                    userid=userid,
                ),
                file=cws.media_file_id,
            )
Example #5
0
async def math(event):
    user_id = event.user_id
    chats = captcha.find({})
    for c in chats:
        if event.chat_id == c["id"]:
            type = c["type"]
            time = c["time"]
    try:
        await tbot(EditBannedRequest(event.chat_id, user_id, MUTE_RIGHTS))
    except:
        pass
    cws = get_current_welcome_settings(event.chat_id)
    if cws:
        wlc = cws.custom_welcome_message
        if "|" in wlc:
            wc, options = wlc.split("|")
            wc = wc.strip()
        else:
            wc = wlc
        a_user = await event.get_user()
        title = event.chat.title
        mention = "[{}](tg://user?id={})".format(a_user.first_name, a_user.id)
        first = a_user.first_name
        last = a_user.last_name
        if last:
            fullname = f"{first} {last}"
        else:
            fullname = first
        userid = a_user.id
        text = wc.format(
            mention=mention,
            title=title,
            first=first,
            last=last,
            fullname=fullname,
            userid=userid,
        )
        text += "\n\n**Captcha Verification**🤖"
    else:
        text = f"Hey {event.user.first_name} Welcome to {event.chat.title}!"
    buttons = Button.url(
        "Click here to prove you are human",
        "t.me/MissEvie_Robot?start=math_{}".format(event.chat_id))
    await event.reply(text, buttons=keyboard)
    WELCOME_DELAY_KICK_SEC = time
    if time:
        if not time == 0:
            asyncio.create_task(
                kick_restricted_after_delay(WELCOME_DELAY_KICK_SEC, event,
                                            user_id))
            await asyncio.sleep(0.5)
Example #6
0
async def button(event):
    user_id = event.user_id
    chats = captcha.find({})
    for c in chats:
        if event.chat_id == c["id"]:
            type = c["type"]
            time = c["time"]
    buttons = Button.inline("Click Here to prove you're Human",
                            data=f"check-bot-{user_id}")
    cws = get_current_welcome_settings(event.chat_id)
    if cws:
        a_user = await event.get_user()
        title = event.chat.title
        mention = "[{}](tg://user?id={})".format(a_user.first_name, a_user.id)
        first = a_user.first_name
        last = a_user.last_name
        if last:
            fullname = f"{first} {last}"
        else:
            fullname = first
        userid = a_user.id
        current_saved_welcome_message = cws.custom_welcome_message
        text = current_saved_welcome_message.format(
            mention=mention,
            title=title,
            first=first,
            last=last,
            fullname=fullname,
            userid=userid,
        )
        text += "\n\n**Captcha Verification**"
    else:
        text = f"Hey {event.user.first_name} Welcome to {event.chat.title}!"
    button_message = await event.reply(text, buttons=buttons)
    try:
        await tbot(EditBannedRequest(event.chat_id, user_id, MUTE_RIGHTS))
    except:
        pass
    WELCOME_DELAY_KICK_SEC = time
    if time:
        if not time == 0:
            asyncio.create_task(
                kick_restricted_after_delay(WELCOME_DELAY_KICK_SEC, event,
                                            user_id))
            await asyncio.sleep(0.5)