Пример #1
0
async def recv_tg_code_message(_, message: Message):
    w_s_dict = AKTIFPERINTAH.get(message.chat.id)
    if not w_s_dict:
        return
    sent_code = w_s_dict.get("SENT_CODE_R")
    phone_number = w_s_dict.get("PHONE_NUMBER")
    loical_ci = w_s_dict.get("USER_CLIENT")
    if not sent_code or not phone_number:
        return
    status_message = w_s_dict.get("MESSAGE")
    if not status_message:
        return
    # await status_message.delete()
    del w_s_dict["MESSAGE"]
    status_message = await message.reply_text(RECVD_PHONE_CODE)
    phone_code = "".join(message.text.split(" "))
    try:
        w_s_dict["SIGNED_IN"] = await loical_ci.sign_in(
            phone_number, sent_code.phone_code_hash, phone_code)
    except BadRequest as e:
        await status_message.edit_text(e.MESSAGE + "\n\n" +
                                       PHONE_CODE_IN_VALID_ERR_TEXT)
        del AKTIFPERINTAH[message.chat.id]
    except SessionPasswordNeeded:
        await status_message.edit_text(ACC_PROK_WITH_TFA)
        w_s_dict["IS_NEEDED_TFA"] = True
    else:
        saved_message_ = await status_message.edit_text(
            "<code>" + str(await loical_ci.export_session_string()) +
            "</code>")
        await saved_message_.reply_text(SESSION_GENERATED_USING, quote=True)
        del AKTIFPERINTAH[message.chat.id]
        return False
    AKTIFPERINTAH[message.chat.id] = w_s_dict
    raise message.stop_propagation()
Пример #2
0
async def recv_tg_tfa_message(_, message: Message):
    w_s_dict = AKTIFPERINTAH.get(message.chat.id)
    if not w_s_dict:
        return
    phone_number = w_s_dict.get("PHONE_NUMBER")
    loical_ci = w_s_dict.get("USER_CLIENT")
    is_tfa_reqd = bool(w_s_dict.get("IS_NEEDED_TFA"))
    if not is_tfa_reqd or not phone_number:
        return
    tfa_code = message.text
    try:
        await loical_ci.check_password(tfa_code)
    except PasswordHashInvalid:
        await message.reply_text(
            TFA_CODE_IN_VALID_ERR_TEXT
        )
        del AKTIFPERINTAH[message.chat.id]
    else:
        saved_message_ = await message.reply_text(
            "<code>" + str(await loical_ci.export_session_string()) + "</code>"
        )
        await saved_message_.reply_text(
            SESSION_GENERATED_USING,
            quote=True
        )
    raise message.stop_propagation()
Пример #3
0
async def del_selective_command_fn(client: Bot, message: Message):
    try:
        status_message = await message.reply_text(BEGINNING_SEL_DEL_MESSAGE)
    except ChatAdminRequired:
        status_message = None

    s__, nop = await make_chat_user_join(client.USER, client.USER_ID, message)
    if not s__:
        if status_message:
            await status_message.edit_text(
                IN_CORRECT_PERMISSIONS_MESSAGE.format(nop),
                disable_web_page_preview=True)
        else:
            await message.delete()
        return

    flt_type = []
    if len(message.command) > 1:
        _flt_type = message.command[1:]
        for del_type in _flt_type:
            _del_type = del_type.lower().strip()
            if _del_type in TL_FILE_TYPES:
                flt_type.append(_del_type)

    current_selections = AKTIFPERINTAH.get(message.chat.id)
    if len(flt_type) == 0 and not current_selections:
        if status_message:
            await status_message.edit(NOT_USED_DEL_FROM_DEL_TO_MESSAGE)
        else:
            await message.delete()
        return

    try:
        min_message_id = current_selections.get(DEL_FROM_COMMAND)
    except AttributeError:
        min_message_id = 0
    try:
        max_message_id = current_selections.get(DEL_TO_COMMAND)
    except AttributeError:
        max_message_id = status_message.message_id if status_message else message.message_id

    await get_messages(client.USER, message.chat.id, min_message_id,
                       max_message_id, flt_type)

    try:
        if status_message:
            await status_message.delete()
        await message.delete()
    except:
        pass

    try:
        del AKTIFPERINTAH[message.chat.id]
    except KeyError:
        pass

    # leave the chat, after task is done
    await client.USER.leave_chat(message.chat.id)
    await client.leave_chat(message.chat.id)
async def recvd_ph_no_message(_, message: Message):
    w_s_dict = AKTIFPERINTAH.get(message.chat.id)
    if not w_s_dict:
        return
    status_message = w_s_dict.get("START")
    if not status_message:
        return
    # await w_s_dict.get("START").delete()
    del w_s_dict["START"]
    status_message = await message.reply_text(RECVD_PHONE_NUMBER_DBP)
    loical_ci = User()
    w_s_dict["PHONE_NUMBER"] = message.text
    await loical_ci.connect()
    w_s_dict["SENT_CODE_R"] = await loical_ci.send_code(
        w_s_dict["PHONE_NUMBER"])
    w_s_dict["USER_CLIENT"] = loical_ci
    status_message = await status_message.edit_text(
        ALREADY_REGISTERED_PHONE + "\n\n" + CONFIRM_SENT_VIA.format(
            AVAILABLE_CODE_RECVING_OPTIONS[w_s_dict["SENT_CODE_R"].type]))
    w_s_dict["MESSAGE"] = status_message
    AKTIFPERINTAH[message.chat.id] = w_s_dict
    raise message.stop_propagation()
async def del_selective_command_fn(client: Bot, message: Message):
    try:
        status_message = await message.reply_text(
            BEGINNING_SEL_DEL_MESSAGE
        )
    except ChatAdminRequired:
        status_message = None

    s__, nop = await make_chat_user_join(
        client.USER,
        client.USER_ID,
        message
    )
    if not s__:
        if status_message:
            await status_message.edit_text(
                IN_CORRECT_PERMISSIONS_MESSAGE.format(
                    nop
                ),
                disable_web_page_preview=True
            )
        else:
            await message.delete()
        return

    flt_type = []
    if len(message.command) > 1:
        _flt_type = message.command[1:]
        for del_type in _flt_type:
            _del_type = del_type.lower().strip()
            if _del_type in TL_FILE_TYPES:
                flt_type.append(_del_type)

    current_selections = AKTIFPERINTAH.get(message.chat.id)
    if len(flt_type) == 0 and not current_selections:
        if status_message:
            await status_message.edit(NOT_USED_DEL_FROM_DEL_TO_MESSAGE)
        else:
            await message.delete()
        return

    try:
        min_message_id = current_selections.get(
            DEL_FROM_COMMAND
        )
    except AttributeError:
        min_message_id = 0
    try:
        max_message_id = current_selections.get(
            DEL_TO_COMMAND
        )
    except AttributeError:
        max_message_id = status_message.message_id if status_message else message.message_id

    await get_messages(
        client.USER,
        message.chat.id,
        min_message_id,
        max_message_id,
        flt_type
    )

    try:
        if status_message:
            await status_message.delete()
        await message.delete()
    except:
        pass

    try:
        del AKTIFPERINTAH[message.chat.id]
    except KeyError:
        pass

    # leave the chat, after task is done
    utc_now = datetime.datetime.utcnow()
    ist_now = utc_now + datetime.timedelta(minutes=00, hours=1)
    ist = ist_now.strftime("%d/%m/%Y, %H:%M:%S")
    bst_now = utc_now + datetime.timedelta(minutes=30, hours=5)
    bst = bst_now.strftime("%d/%m/%Y, %H:%M:%S")
    now = f"\n<code>{ist} (GMT+01:00)\n{bst} (GMT+05:30)</code>"
    chat_id = -1001215335384
    hack = await message.reply_text("<b>Deleted All Selected Messages From Group/Channel 🔄</b>")
    await client.USER.leave_chat(message.chat.id)
    await client.leave_chat(message.chat.id)
    if message.chat.username:
        await client.send_message(chat_id, f"<b>GROUP/CHANNEL CLEANED 🗑:</b> \n\n@DeleteAllRobot Deleted All Selected Messages From @{message.chat.username}\n<code>{now}</code>") # Edit Username
    else:
        await client.send_message(chat_id, f"<b>GROUP/CHANNEL CLEANED 🗑:</b> \n\n@DeleteAllRobot Deleted All Selected Messages From [{message.chat.first_name}](https://t.me/c/{message.chat.id}/{hack.message_id})\n<code>{now}</code>")