Beispiel #1
0
async def save_gdbye(_, m: Message):
    db = Greetings(m.chat.id)
    if m and not m.from_user:
        return
    args = m.text.split(None, 1)

    if len(args) >= 4096:
        await m.reply_text("Word limit exceeds !!", )
        return
    if not (m.reply_to_message and m.reply_to_message.text) and len(
            m.command) == 0:
        await m.reply_text(
            "Error: There is no text in here! and only text with buttons are supported currently !",
        )
        return
    text, msgtype, _ = await get_wlcm_type(m)

    if not m.reply_to_message and msgtype == Types.TEXT and len(
            m.command) <= 2:
        await m.reply_text(
            f"<code>{m.text}</code>\n\nError: There is no data in here!")
        return

    if not text and not msgtype:
        await m.reply_text("Please provide some data!", )
        return

    if not msgtype:
        await m.reply_text("Please provide some data for this to reply with!")
        return

    db.set_goodbye_text(text)
    await m.reply_text("Saved goodbye!")
    return
Beispiel #2
0
async def migrate_chat(m: Message, new_chat: int) -> None:
    LOGGER.info(f"Migrating from {m.chat.id} to {new_chat}...")
    langdb = Langs(m.chat.id)
    notedb = Notes()
    gdb = Greetings(m.chat.id)
    ruledb = Rules(m.chat.id)
    userdb = Users(m.chat.id)
    chatdb = Chats(m.chat.id)
    bldb = Blacklist(m.chat.id)
    approvedb = Approve(m.chat.id)
    reportdb = Reporting(m.chat.id)
    notes_settings = NotesSettings()
    pins_db = Pins(m.chat.id)
    fldb = Filters()
    disabl = Disabling(m.chat.id)
    disabl.migrate_chat(new_chat)
    gdb.migrate_chat(new_chat)
    chatdb.migrate_chat(new_chat)
    userdb.migrate_chat(new_chat)
    langdb.migrate_chat(new_chat)
    ruledb.migrate_chat(new_chat)
    bldb.migrate_chat(new_chat)
    notedb.migrate_chat(m.chat.id, new_chat)
    approvedb.migrate_chat(new_chat)
    reportdb.migrate_chat(new_chat)
    notes_settings.migrate_chat(m.chat.id, new_chat)
    pins_db.migrate_chat(new_chat)
    fldb.migrate_chat(m.chat.id, new_chat)
    LOGGER.info(f"Successfully migrated from {m.chat.id} to {new_chat}!")
Beispiel #3
0
async def cleannnnn(_, m: Message):
    db = Greetings(m.chat.id)
    clean = db.get_current_cleanservice_settings()
    try:
        if clean:
            await m.delete()
    except Exception:
        pass
Beispiel #4
0
async def resetwlcm(_, m: Message):
    db = Greetings(m.chat.id)
    if m and not m.from_user:
        return
    text = "Hey {first}, welcome to {chatname}!"
    db.set_welcome_text(text)
    await m.reply_text("Done!")
    return
Beispiel #5
0
async def resetgb(_, m: Message):
    db = Greetings(m.chat.id)
    if m and not m.from_user:
        return
    text = "Sad to see you leaving {first}.\nTake Care!"
    db.set_goodbye_text(text)
    await m.reply_text("Ok Done!")
    return
Beispiel #6
0
async def welcome(c: Alita, m: Message):
    db = Greetings(m.chat.id)
    status = db.get_welcome_status()
    oo = db.get_welcome_text()
    args = m.text.split(" ", 1)

    if m and not m.from_user:
        return

    if len(args) >= 2:
        if args[1].lower() == "noformat":
            await m.reply_text(
                f"""Current welcome settings:-
        Welcome power: {status}
        Clean Welcome: {db.get_current_cleanwelcome_settings()}
        Cleaning service: {db.get_current_cleanservice_settings()}
        Welcome text in no formating:
        """, )
            await c.send_message(m.chat.id, text=oo, parse_mode=None)
            return
        if args[1].lower() == "on":
            db.set_current_welcome_settings(True)
            await m.reply_text("Turned on!")
            return
        if args[1].lower() == "off":
            db.set_current_welcome_settings(False)
            await m.reply_text("Turned off!")
            return
        await m.reply_text("what are you trying to do ??")
        return
    else:
        await m.reply_text(
            f"""Current welcome settings:-
Welcome power: {status}
Clean Welcome: {db.get_current_cleanwelcome_settings()}
Cleaning service: {db.get_current_cleanservice_settings()}
Welcome text:
""", )
        tek, button = await parse_button(oo)
        button = await build_keyboard(button)
        button = InlineKeyboardMarkup(button) if button else None
        await c.send_message(m.chat.id, text=tek, reply_markup=button)
        return
Beispiel #7
0
async def cleangdbye(_, m: Message):
    db = Greetings(m.chat.id)
    status = db.get_current_cleangoodbye_settings()
    args = m.text.split(" ", 1)

    if len(args) >= 2:
        if args[1].lower() == "on":
            db.set_current_cleangoodbye_settings(True)
            await m.reply_text("Turned on!")
            return
        if args[1].lower() == "off":
            db.set_current_cleangoodbye_settings(False)
            await m.reply_text("Turned off!")
            return
        await m.reply_text("what are you trying to do ??")
        return
    await m.reply_text(f"Current settings:- {status}")
    return
Beispiel #8
0
async def member_has_left(c: Alita, member: ChatMemberUpdated):
    from alita import BOT_ID

    if (not member.new_chat_member
            and member.old_chat_member.status not in {"kicked", "restricted"}
            and member.old_chat_member):
        pass
    else:
        return
    db = Greetings(member.chat.id)
    status = db.get_goodbye_status()
    oo = db.get_goodbye_text()
    parse_words = [
        "first",
        "last",
        "fullname",
        "id",
        "username",
        "mention",
        "chatname",
    ]

    user = member.old_chat_member.user if member.old_chat_member else member.from_user

    hmm = await escape_mentions_using_curly_brackets_wl(
        member, False, oo, parse_words)
    if status:
        tek, button = await parse_button(hmm)
        button = await build_keyboard(button)
        button = InlineKeyboardMarkup(button) if button else None

        if "%%%" in tek:
            filter_reply = tek.split("%%%")
            teks = choice(filter_reply)
        else:
            teks = tek
        ifff = db.get_current_cleangoodbye_id()
        iii = db.get_current_cleangoodbye_settings()
        if ifff and iii:
            try:
                await c.delete_messages(member.chat.id, int(ifff))
            except RPCError:
                pass
        if user.id == OWNER_ID:
            await c.send_message(
                member.chat.id,
                "Will miss you :)",
            )
            return
        try:
            ooo = await c.send_message(
                member.chat.id,
                text=teks,
                reply_markup=button,
                disable_web_page_preview=True,
            )
            if ooo:
                db.set_cleangoodbye_id(int(ooo.message_id))
            return
        except RPCError as e:
            print(e)
            return
    else:
        return
Beispiel #9
0
async def member_has_joined(c: Alita, member: ChatMemberUpdated):
    from alita import BOT_ID

    if (member.new_chat_member and member.new_chat_member.status
            not in {"kicked", "left", "restricted"}
            and not member.old_chat_member):
        pass
    else:
        return

    user = member.new_chat_member.user if member.new_chat_member else member.from_user

    db = Greetings(member.chat.id)
    banned_users = gdb.check_gban(user.id)
    try:
        if user.id == BOT_ID:
            return
        if user.id == OWNER_ID:
            await c.send_message(
                member.chat.id,
                "Wew My Owner has also joined the chat!",
            )
            return
        if banned_users:
            await member.chat.kick_member(user.id)
            await c.send_message(
                member.chat.id,
                f"{user.mention} was globally banned so i banned!",
            )
            return
        if user.is_bot:
            return  # ignore bots
    except ChatAdminRequired:
        return
    status = db.get_welcome_status()
    oo = db.get_welcome_text()
    parse_words = [
        "first",
        "last",
        "fullname",
        "username",
        "mention",
        "id",
        "chatname",
    ]
    hmm = await escape_mentions_using_curly_brackets_wl(
        member, True, oo, parse_words)
    if status:
        tek, button = await parse_button(hmm)
        button = await build_keyboard(button)
        button = InlineKeyboardMarkup(button) if button else None

        if "%%%" in tekss:
            filter_reply = tek.split("%%%")
            teks = choice(filter_reply)
        else:
            teks = tek
        ifff = db.get_current_cleanwelcome_id()
        gg = db.get_current_cleanwelcome_settings()
        if ifff and gg:
            try:
                await c.delete_messages(member.chat.id, int(ifff))
            except RPCError:
                pass
        try:
            jj = await c.send_message(
                member.chat.id,
                text=teks,
                reply_markup=button,
                disable_web_page_preview=True,
            )
            if jj:
                db.set_cleanwlcm_id(int(jj.message_id))
        except RPCError as e:
            print(e)
            return
    else:
        return