Esempio n. 1
0
async def afk_on_pm(e):
    global USERS
    global COUNT_MSG
    if not is_redis_alive():
        return
    AFK = await is_afk()
    if e.is_private and not (await e.get_sender()).bot:
        if AFK is True:
            if e.sender_id not in USERS:
                await e.reply(
                    "π™Žπ™˜π™ͺ𝙨𝙖! π™ˆπ™– α΄€κœ±Κœ Γ¨ π˜Όπ™π™† π™₯π™šπ™§:```" + await afk_reason() +
                    "```. π™‚π™‘π™ž π™’π™–π™£π™™π™šπ™§Γ² π™ͺ𝙣𝙖 π™£π™€π™©π™žπ™›π™žπ™˜π™– π™₯π™šπ™§ 𝙛𝙖𝙧 π™«π™šπ™™π™šπ™§π™š π™žπ™‘ 𝙩π™ͺ𝙀 π™’π™šπ™¨π™¨π™–π™œπ™œπ™žπ™€πŸ˜‰"
                )
                USERS.update({e.sender_id: 1})
                COUNT_MSG = COUNT_MSG + 1
            elif e.sender_id in USERS:
                if USERS[e.sender_id] % 5 == 0:
                    await e.reply(
                        "π™Žπ™˜π™ͺ𝙨𝙖! π™ˆπ™– α΄€κœ±Κœ 𝙣𝙀𝙣 Γ¨ π™–π™£π™˜π™€π™§π™– 𝙩𝙀𝙧𝙣𝙖𝙩𝙀!. "
                        "𝙋𝙧𝙀𝙫𝙖 𝙖 π™žπ™£π™«π™žπ™–π™§π™œπ™‘π™ž π™ͺ𝙣 π™’π™šπ™¨π™¨π™–π™œπ™œπ™žπ™€ 𝙩𝙧𝙖 π™ͺ𝙣 π™₯𝙀'. π™ˆπ™ž π™™π™žπ™¨π™₯π™žπ™–π™˜π™šπŸ˜–."
                        "π™ˆπ™ž 𝙝𝙖 π™™π™šπ™©π™©π™€ π™˜π™π™š π™šπ™§π™– π™žπ™’π™₯π™šπ™œπ™£π™–π™©π™€ π™₯π™šπ™§: ```" +
                        await afk_reason() + "```")
                    USERS[e.sender_id] = USERS[e.sender_id] + 1
                    COUNT_MSG = COUNT_MSG + 1
                else:
                    USERS[e.sender_id] = USERS[e.sender_id] + 1
                    COUNT_MSG = COUNT_MSG + 1
Esempio n. 2
0
async def add_list_items(event):
    """ For .addlistitems command, add item(s) to a list. """
    cmd = event.text[0]
    if not cmd.isalpha() and cmd not in ("/", "#", "@", "!"):
        if not is_mongo_alive() or not is_redis_alive():
            await event.edit("`Database connections failing!`")
            return

        listname = event.pattern_match.group(2)
        _list = await get_list(event.chat_id, listname)
        content = _list['items']

        content.extend(event.text.partition(f"{listname} ")[2].splitlines())

        msg = "`Items added successfully to the list. \
Use` ${} `to get the list.`"

        if await add_list(event.chat_id, listname, content) is False:
            await event.edit(msg.format(listname))
        else:
            await event.edit(f"List {listname} doesn't exist!")

        if BOTLOG:
            listat = "global storage" if _list['chat_id'] else str(
                event.chat_id)
            await event.client.send_message(
                BOTLOG_CHATID,
                f"Added items {content} to {listname} in {listat}")
Esempio n. 3
0
async def type_afk_is_not_true(notafk):
    global COUNT_MSG
    global USERS
    if not is_redis_alive():
        return
    IsAway = await is_afk()
    if IsAway is True:
        x = await notafk.respond("I'm no longer AFK.")
        y = await notafk.respond(
            "`You recieved " + str(COUNT_MSG) +
            " messages while you were away. Check log for more details.`"
        )
        await no_afk()
        time.sleep(5)
        await x.delete()
        await y.delete()
        if BOTLOG:
            await notafk.client.send_message(
                BOTLOG_CHATID,
                "You've recieved " + str(COUNT_MSG) + " messages from " +
                str(len(USERS)) + " chats while you were away",
            )
            for i in USERS:
                name = await notafk.client.get_entity(i)
                name0 = str(name.first_name)
                await notafk.client.send_message(
                    BOTLOG_CHATID,
                    "[" + name0 + "](tg://user?id=" + str(i) + ")" +
                    " sent you " + "`" + str(USERS[i]) + " messages`",
                )
        COUNT_MSG = 0
        USERS = {}
Esempio n. 4
0
async def edit_list_item(event):
    """ For .editlistitem command, edit an individual item on a list. """
    cmd = event.text[0]
    if not cmd.isalpha() and cmd not in ("/", "#", "@", "!"):
        if not is_mongo_alive() or not is_redis_alive():
            await event.edit("`Database connections failing!`")
            return

        listname = event.pattern_match.group(1)
        item_number = int(event.pattern_match.group(2))

        _list = await get_list(event.chat_id, listname)
        content = _list['items']
        content[item_number -
                1] = event.text.partition(f"{listname} {item_number} ")[2]

        msg = f"`Item {item_number} edited successfully. \
Use` ${listname} `to get the list.`"

        if await add_list(event.chat_id, listname, content) is False:
            await event.edit(msg)
        else:
            await event.edit(f"List {listname} doesn't exist!")

        if BOTLOG:
            listat = "global storage" if _list['chat_id'] else str(
                event.chat_id)
            await event.client.send_message(
                BOTLOG_CHATID,
                f"Edited item {item_number} of {listname} in {listat} successfully."
            )
Esempio n. 5
0
async def setliststate(event):
    """ For .setlist command, changes the state of a list. """
    cmd = event.text[0]
    if not cmd.isalpha() and cmd not in ("/", "#", "@", "!"):
        if not is_mongo_alive() or not is_redis_alive():
            await event.edit("`Database connections failing!`")
            return

        _futureState = event.pattern_match.group(2)
        changeToGlobal = None

        if _futureState == "global":
            changeToGlobal = True
        elif _futureState == "local":
            changeToGlobal = False

        listname = event.pattern_match.group(1)
        _list = await get_list(event.chat_id, listname)

        chatid = 0 if changeToGlobal else event.chat_id

        msg = f"`The state of list {listname} changed to \
{_futureState} successfully.`"

        if await set_list(_list['chat_id'], listname, chatid) is True:
            await event.edit(msg)
        else:
            await event.edit(f"`List {listname} not found!`")

        if BOTLOG:
            await event.client.send_message(
                BOTLOG_CHATID,
                f"Changed state of list {listname} to {_futureState}")
Esempio n. 6
0
async def removelists(event):
    """ For .dellist command, delete list with the given name."""
    if not is_mongo_alive() or not is_redis_alive():
        await event.edit(DB_FAILED)
        return

    textx = await event.get_reply_message()
    listname = None

    if textx:
        x = re.search(r"\[Paperplane-List] List \*\*(\w*)", textx.text)
        listname = x.group(1)
    elif event.pattern_match.group(1):
        listname = event.pattern_match.group(1)
    else:
        await event.edit(f"`Pass a list to delete!` {CHK_HELP}")
        return

    _list = await get_list(event.chat_id, listname)

    if await delete_list(event.chat_id, listname) is False:
        await event.edit("`Couldn't find list:` **{}**".format(listname))
        return
    else:
        await event.edit("`Successfully deleted list:` **{}**".format(listname)
                         )

    if BOTLOG:
        listat = "global storage" if _list['chat_id'] == 0 else str(
            event.chat_id)
        await event.client.send_message(
            BOTLOG_CHATID, f"Removed list {listname} from {listat}")
Esempio n. 7
0
async def ungmoot(un_gmute):
    """ For .ungmute command, ungmutes the target in the userbot """

    # Check if the function running under SQL mode
    if not is_mongo_alive() or not is_redis_alive():
        await un_gmute.edit(NO_SQL)
        return

    user = await get_user_from_event(un_gmute)
    if user:
        pass
    else:
        return

    # If pass, inform and start ungmuting
    await un_gmute.edit('```Ungmuting...```')

    if await ungmute(user.id) is False:
        await un_gmute.edit("`Error! User probably not gmuted.`")
    else:

        # Inform about success
        await un_gmute.edit("```Ungmuted Successfully```")
        if BOTLOG:
            await un_gmute.client.send_message(
                BOTLOG_CHATID, "#UNGMUTE\n"
                f"USER: [{user.first_name}](tg://user?id={user.id})\n"
                f"CHAT: {un_gmute.chat.title}(`{un_gmute.chat_id}`)")
Esempio n. 8
0
async def add_subscription(e):
    """ Add a subscription pattern. Whenever this pattern
    is matched in the current chat you will be notified """
    params = e.pattern_match.group(1)

    if not is_mongo_alive() or not is_redis_alive():
        await e.edit("`Database connections failing!`", delete_in=3)
        return

    args, pattern = parse_arguments(params, ['global'])
    parts = pattern.split(' ')

    if not len(parts) >= 2:
        await e.edit("A name and pattern are required.", delete_in=3)
        return

    name = parts[0]
    pattern = ' '.join(parts[1:])

    await e.edit(f"Subscribing to pattern `{pattern}`")
    gbl = args.get('global', False)

    if await add_sub(e.chat_id, name, pattern, gbl=gbl) is True:
        if not args.get('silent'):
            await e.edit(f"Added subscription `{name}` for pattern `{pattern}`", delete_in=3)
        else:
            await e.edit("A subscription with that name already exists", delete_in=3)
Esempio n. 9
0
async def sub_logic(event):
    """ Subs logic. """
    try:
        me = await event.client.get_me()
        if not (await event.get_sender()).bot and not (event.from_id == me.id):
            if not is_mongo_alive() or not is_redis_alive():
                return

            subs = list(await get_subs(event.chat_id))

            for sub in subs:
                if match(sub['pattern'], event.text):
                    if event.chat.username:
                        message_link = f"https://t.me/{event.chat.username}/{event.message.id}"

                    else:
                        message_link = f"https://t.me/c/{event.chat_id}/{event.message.id}"

                    await event.client.send_message(
                        BOTLOG_CHATID,
                        f"Sub `{sub['name']}` triggered in chat `{event.chat_id}`. "
                        f"Here's a link. \n{message_link}",
                        schedule=timedelta(seconds=5))
                    break
    except BaseException:
        pass
Esempio n. 10
0
async def amireallydbs(dbs):
    if not is_mongo_alive() and not is_redis_alive():
        db = "Bot Mongo dan Redis Database sepertinya gagal!"
    elif not is_mongo_alive():
        db = "Mongo DB sepertinya gagal!"
    elif not is_redis_alive():
        db = "Redis Cache sepertinya gagal!"
    else:
        db = "Databases functioning normally!"
    await dbs.edit(""
                   f"**Database Mongo db** \n\n"
                   f"**Pengguna :** `{DEFAULTUSER}` \n"
                   f"**Status Database :** `{db}`\n"
                   f"**Branch :** __King-Userbot__\n"
                   f"**Versi Userbot :** `{BOT_VER}`"
                   "")
Esempio n. 11
0
async def list_subscriptions(event):
    if not is_mongo_alive() or not is_redis_alive():
        await event.edit("`Database connections failing!`", delete_in=3)
        return

    params = event.pattern_match.group(1) or ""
    args, _ = parse_arguments(params, ['all'])

    fetch_all = args.get('all', False)

    await event.edit("Fetching subscriptions...")
    if fetch_all:
        subs = list(await get_subs(None))
    else:
        subs = list(await get_subs(event.chat_id))

    message = "**Subscribed patterns** \n"
    if len(subs) < 1:
        message += "No subscriptions yet."
    else:
        for sub in subs:
            gbl = '(g)' if sub['global'] else ''
            pattern = sub['pattern']
            pattern = pattern[:25] + (pattern[25:] and '..')
            message += f"`{sub['name']}{gbl}`: `{pattern}` \n"

    await event.edit(message.strip())
Esempio n. 12
0
async def amireallydbs(dbs):
    if not is_mongo_alive() and not is_redis_alive():
        db = "Both Mongo and Redis Database seems to be failing!"
    elif not is_mongo_alive():
        db = "Mongo DB seems to be failing!"
    elif not is_redis_alive():
        db = "Redis Cache seems to be failing!"
    else:
        db = "Databases functioning normally!"
    await dbs.edit(
        ""
        f"**User:** `{DEFAULTUSER}` \n"
        f"**Status Database:** `{db}`\n"
        f"**Userbot:** `{BOT_VER}`@Man-Userbot"
        ""
    )
Esempio n. 13
0
async def type_afk_is_not_true(e):
    global COUNT_MSG
    global USERS
    global AFKREASON
    if not is_redis_alive():
        return
    ISAFK = await is_afk()
    if ISAFK is True:
        await no_afk()
        x = await e.respond("I'm no longer AFK.")
        y = await e.respond(
            "`You recieved " + str(COUNT_MSG) +
            " messages while you were away. Check log for more details.`" +
            " `This auto-generated message shall be self destructed in 2 seconds.`"
        )
        time.sleep(2)
        await x.delete()
        await y.delete()
        if BOTLOG:
            await e.client.send_message(
                BOTLOG_CHATID,
                "You've recieved " + str(COUNT_MSG) + " messages from " +
                str(len(USERS)) + " chats while you were away",
            )
            for i in USERS:
                name = await e.client.get_entity(i)
                name0 = str(name.first_name)
                await e.client.send_message(
                    BOTLOG_CHATID,
                    "[" + name0 + "](tg://user?id=" + str(i) + ")" +
                    " sent you " + "`" + str(USERS[i]) + " messages`",
                )
        COUNT_MSG = 0
        USERS = {}
        AFKREASON = "No Reason"
Esempio n. 14
0
async def getlist_logic(event):
    """ For .getlist, get the list by the name. """
    if not (await event.get_sender()).bot:
        if not is_mongo_alive() or not is_redis_alive():
            return

        textx = await event.get_reply_message()

        if textx:
            x = re.search(r"\[Paperplane-List] List \*\*(\w*)", textx.text)
            listname = x.group(1)
        elif event.pattern_match.group(1):
            listname = event.pattern_match.group(1)
        else:
            await event.edit(f"`Pass a list to get!` {CHK_HELP}")
            return

        _list = await get_list(event.chat_id, listname)
        if _list:
            if _list['chat_id'] == 0:
                storage = "global"
            else:
                storage = str(_list['chat_id'])

            return_str = LIST_HEADER.format(listname, storage)

            if _list['items']:
                for i, item in enumerate(_list['items']):
                    return_str += f"{i + 1}. {item}\n"
            else:
                return_str = "`This list is empty!`"

            await event.edit(return_str)
        else:
            await event.edit(f"`List {listname} not found!`")
Esempio n. 15
0
async def approvepm(apprvpm):
    """ For .approve command, give someone the permissions to PM you. """
    if not is_mongo_alive() or not is_redis_alive():
        await apprvpm.edit("`Database connections failing!`")
        return

    if await approve(apprvpm.chat_id) is False:
        return await apprvpm.edit("`User was already approved!`")
    else:
        if apprvpm.reply_to_msg_id:
            reply = await apprvpm.get_reply_message()
            replied_user = await apprvpm.client(
                GetFullUserRequest(reply.from_id))
            aname = replied_user.user.id
            name0 = str(replied_user.user.first_name)
            uid = replied_user.user.id

        else:
            aname = await apprvpm.client.get_entity(apprvpm.chat_id)
            name0 = str(aname.first_name)
            uid = apprvpm.chat_id

        await apprvpm.edit(f"[{name0}](tg://user?id={uid}) `approved to PM!`")

        if BOTLOG:
            await apprvpm.client.send_message(
                BOTLOG_CHATID,
                "#APPROVED\n" + "User: "******"[{name0}](tg://user?id={uid})",
            )
Esempio n. 16
0
async def approvepm(apprvpm):
    """ For .approve command, give someone the permissions to PM you. """
    if not apprvpm.text[0].isalpha() and apprvpm.text[0] not in ("/", "#", "@",
                                                                 "!"):
        if not is_mongo_alive() or not is_redis_alive():
            await apprvpm.edit("`Database connections failing!`")
            return

        if await approve(apprvpm.chat_id) is False:
            return await apprvpm.edit("`𝘼π™₯π™₯𝙧𝙀𝙫𝙖𝙩𝙀!`")
        else:
            if apprvpm.reply_to_msg_id:
                reply = await apprvpm.get_reply_message()
                replied_user = await apprvpm.client(
                    GetFullUserRequest(reply.from_id))
                aname = replied_user.user.id
                name0 = str(replied_user.user.first_name)
                uid = replied_user.user.id

            else:
                aname = await apprvpm.client.get_entity(apprvpm.chat_id)
                name0 = str(aname.first_name)
                uid = apprvpm.chat_id

            await apprvpm.edit(
                f"[{name0}](tg://user?id={uid}) `𝘼π™₯π™₯𝙧𝙀𝙫𝙖𝙩𝙀 𝙖 π™¨π™˜π™§π™žπ™«π™šπ™§π™’π™ž π™žπ™£ 𝙋𝙫𝙩!`"
            )

            if BOTLOG:
                await apprvpm.client.send_message(
                    BOTLOG_CHATID,
                    "#APPROVED\n" + "User: "******"[{name0}](tg://user?id={uid})",
                )
Esempio n. 17
0
async def blockpm(block):
    """ For .block command, block people from PMing you! """
    if not is_mongo_alive() or not is_redis_alive():
        await block.edit("`Database connections failing!`")
        return

    if await block_pm(block.chat_id) is False:
        return await block.edit("`First approve, before blocc'ing`")
    else:
        await block.edit("`You are gonna be blocked from PM-ing my Master!`")

        if block.reply_to_msg_id:
            reply = await block.get_reply_message()
            replied_user = await block.client(GetFullUserRequest(reply.from_id)
                                              )
            aname = replied_user.user.id
            name0 = str(replied_user.user.first_name)
            await block.client(BlockRequest(replied_user.user.id))
            uid = replied_user.user.id
        else:
            await block.client(BlockRequest(block.chat_id))
            aname = await block.client.get_entity(block.chat_id)
            name0 = str(aname.first_name)
            uid = block.chat_id

        await block.edit("`Blocked.`")

        if BOTLOG:
            await block.client.send_message(
                BOTLOG_CHATID,
                "#BLOCKED\n" + "User: "******"[{name0}](tg://user?id={uid})",
            )
Esempio n. 18
0
async def blockpm(block):
    """ For .block command, block people from PMing you! """
    if not block.text[0].isalpha() and block.text[0] not in ("/", "#", "@",
                                                             "!"):
        await block.edit("`Ash non approva i tuoi messaggi in PM!`")

        if await block_pm(block.chat_id) is False:
            return await block.edit("`Approvo, prima di bloccarti.`")
        else:
            return await block.edit("`π˜Ώπ™žπ™¨π™–π™₯π™₯𝙧𝙀𝙫𝙖𝙩𝙀.`")

            if block.reply_to_msg_id:
                reply = await block.get_reply_message()
                replied_user = await block.client(
                    GetFullUserRequest(reply.from_id))
                aname = replied_user.user.id
                name0 = str(replied_user.user.first_name)
                await block.client(BlockRequest(replied_user.user.id))
                uid = replied_user.user.id
            else:
                await block.client(BlockRequest(block.chat_id))
                aname = await block.client.get_entity(block.chat_id)
                name0 = str(aname.first_name)
                uid = block.chat_id

            if not is_mongo_alive() or not is_redis_alive():
                await block.edit("`Database connections failing!`")
                return
            if BOTLOG:
                await block.client.send_message(
                    BOTLOG_CHATID,
                    "#BLOCKED\n" + "User: "******"[{name0}](tg://user?id={uid})",
                )
Esempio n. 19
0
async def muter(moot):
    """ Used for deleting the messages of muted people """
    if not is_mongo_alive() or not is_redis_alive():
        return
    muted = await get_muted(moot.chat_id)
    gmuted = await get_gmuted()
    rights = ChatBannedRights(
        until_date=None,
        send_messages=True,
        send_media=True,
        send_stickers=True,
        send_gifs=True,
        send_games=True,
        send_inline=True,
        embed_links=True,
    )
    if muted:
        for i in muted:
            if i == moot.sender_id:
                await moot.delete()
                try:
                    await moot.client(
                        EditBannedRequest(moot.chat_id, moot.sender_id,
                                          rights))

                # We couldn't hit him an API mute, probably an admin?
                # Telethon sometimes fails to grab user details properly gaurd
                # it also
                except (UserAdminInvalidError, ChatAdminRequiredError,
                        BadRequestError, UserIdInvalidError):
                    pass
    for i in gmuted:
        if i == moot.sender_id:
            await moot.delete()
Esempio n. 20
0
async def unmute_chat(unm_e):
    """ For .unmutechat command, unmute a muted chat. """
    if not is_mongo_alive() or not is_redis_alive():
        await unm_e.edit("`Database connections failing!`")
        return
    MONGO.bot.mute_chats.delete_one({"chat_id": unm_e.chat_id})
    await unm_e.edit("```Unmuted this chat Successfully```")
Esempio n. 21
0
async def gspider(gspdr):
    """ For .gmute command, gmutes the target in the userbot """

    # Check if the function running under SQL mode
    if not is_mongo_alive() or not is_redis_alive():
        await gspdr.edit(NO_SQL)
        return
    user = await get_user_from_event(gspdr)
    if user:
        pass
    else:
        return

    # If pass, inform and start gmuting
    await gspdr.edit("`Grabs a huge, sticky duct tape!`")

    if await gmute(user.id) is False:
        await gspdr.edit('`Error! User probably already gmuted.`')
    else:
        await gspdr.edit("`Globally taped!`")

        if BOTLOG:
            await gspdr.client.send_message(
                BOTLOG_CHATID, "#GMUTE\n"
                f"USER: [{user.first_name}](tg://user?id={user.id})\n"
                f"CHAT: {gspdr.chat.title}(`{gspdr.chat_id}`)")
Esempio n. 22
0
async def mention_afk(mention):
    """This function takes care of notifying the
    people who mention you that you are AFK."""

    global COUNT_MSG
    global USERS
    if not is_redis_alive():
        return
    IsAway = await is_afk()
    if mention.message.mentioned and not (await mention.get_sender()).bot:
        if IsAway is True:
            if mention.sender_id not in USERS:
                await mention.reply(
                    "Sorry! My boss is AFK due to "
                    + await afk_reason()
                    + ". Would ping him to look into the message soonΓ°ΕΈΛœβ€°"
                )
                USERS.update({mention.sender_id: 1})
                COUNT_MSG = COUNT_MSG + 1
            elif mention.sender_id in USERS:
                if USERS[mention.sender_id] % 5 == 0:
                    await mention.reply(
                        "Sorry! But my boss is still not here. "
                        "Try to ping him a little later. I am sorryΓ°ΕΈΛœβ€“."
                        "He told me he was busy with ```" + await afk_reason() + "```"
                    )
                    USERS[mention.sender_id] = USERS[mention.sender_id] + 1
                    COUNT_MSG = COUNT_MSG + 1
                else:
                    USERS[mention.sender_id] = USERS[mention.sender_id] + 1
                    COUNT_MSG = COUNT_MSG + 1
Esempio n. 23
0
async def rmlistitems(event):
    """ For .rmlistitem command, remove an item from the list. """
    cmd = event.text[0]
    if not cmd.isalpha() and cmd not in ("/", "#", "@", "!"):
        if not is_mongo_alive() or not is_redis_alive():
            await event.edit("`Database connections failing!`")
            return

        listname = event.pattern_match.group(1)
        item_number = int(event.pattern_match.group(2))

        _list = await get_list(event.chat_id, listname)

        content = _list['items']
        del content[item_number - 1]

        msg = "`Item {} removed from the list successfully. \
Use` ${} `to get the list.`"

        if await add_list(event.chat_id, listname, content) is False:
            await event.edit(msg.format(item_number, listname))
        else:
            await event.edit(f"List {listname} doesn't exist!")

        if BOTLOG:
            listat = "global storage" if _list['chat_id'] else str(
                event.chat_id)
            await event.client.send_message(
                BOTLOG_CHATID,
                f"Removed item {str(item_number)} from {listname} in {listat}")
Esempio n. 24
0
async def afk_on_pm(afk_pm):
    global USERS
    global COUNT_MSG
    if not is_redis_alive():
        return
    IsAway = await is_afk()
    if afk_pm.is_private and not (await afk_pm.get_sender()).bot:
        if IsAway is True:
            if afk_pm.sender_id not in USERS:
                await afk_pm.reply(
                    "Sorry! My boss is AFK due to ```"
                    + await afk_reason()
                    + "``` I'll ping him to look into the message soonΓ°ΕΈΛœβ€°"
                )
                USERS.update({afk_pm.sender_id: 1})
                COUNT_MSG = COUNT_MSG + 1
            elif afk_pm.sender_id in USERS:
                if USERS[afk_pm.sender_id] % 5 == 0:
                    await afk_pm.reply(
                        "Sorry! But my boss is still not here. "
                        "Try to ping him a little later. I am sorryΓ°ΕΈΛœβ€“."
                        "He told me he was busy with ```" + await afk_reason() + "```"
                    )
                    USERS[afk_pm.sender_id] = USERS[afk_pm.sender_id] + 1
                    COUNT_MSG = COUNT_MSG + 1
                else:
                    USERS[afk_pm.sender_id] = USERS[afk_pm.sender_id] + 1
                    COUNT_MSG = COUNT_MSG + 1
Esempio n. 25
0
async def addlist(event):
    """ For .add(g)list command, saves lists in a chat. """
    cmd = event.text[0]
    if not cmd.isalpha() and cmd not in ("/", "#", "@", "!"):
        if not is_mongo_alive() or not is_redis_alive():
            await event.edit("`Database connections failing!`")
            return

        is_global = event.pattern_match.group(1) == "g"

        listname = event.pattern_match.group(2)
        content = event.text.partition(f"{listname} ")[2].splitlines()

        msg = "`List {} successfully. Use` ${} `to get it`"

        chatid = 0 if is_global else event.chat_id

        if await add_list(chatid, listname, content) is False:
            await event.edit(msg.format('updated', listname))
        else:
            await event.edit(msg.format('added', listname))

        if BOTLOG:
            listat = "global storage" if is_global else str(event.chat_id)
            await event.client.send_message(
                BOTLOG_CHATID, f"Added list {listname} to {listat}")
Esempio n. 26
0
async def amireallyalive(alive):
    if not is_mongo_alive() and not is_redis_alive():
        db = "Both Mongo and Redis Database seems to be failing!"
    elif not is_mongo_alive():
        db = "Mongo DB seems to be failing!"
    elif not is_redis_alive():
        db = "Redis Cache seems to be failing!"
    else:
        db = "Databases functioning normally!"
    await alive.edit("`"
                     "RE1GNZ! Userbot is running \n\n"
                     f"Telethon version: {version.__version__} \n"
                     f"Python: {python_version()} \n"
                     f"User: {DEFAULTUSER} \n"
                     f"Database Status: {db}"
                     "`")
Esempio n. 27
0
async def mention_afk(mention):
    """ This function takes care of notifying the
     people who mention you that you are AFK."""

    global COUNT_MSG
    global USERS
    if not is_redis_alive():
        return
    IsAway = await is_afk()
    if mention.message.mentioned and not (await mention.get_sender()).bot:
        if IsAway is True:
            if mention.sender_id not in USERS:
                await mention.reply(
                    "Sorry! My owner is AFK!\n" 'He/She said: ' + await afk_reason() + '\n\n'  'I would ping him/her to look into the message soonΓ°ΕΈΛœβ€°')
                USERS.update({mention.sender_id: 1})
                COUNT_MSG = COUNT_MSG + 1
            elif mention.sender_id in USERS:
                if USERS[mention.sender_id] % 5 == 0:
                    await mention.reply(
                        "My owner is still not here. "
                        "Try to ping my owner a little later. I am sorryΓ°ΕΈΛœβ€“."
                        "I recall my owner saying ```" + '..."' + await afk_reason() + '"' +  "```" )
                    USERS[mention.sender_id] = USERS[mention.sender_id] + 1
                    COUNT_MSG = COUNT_MSG + 1
                else:
                    USERS[mention.sender_id] = USERS[mention.sender_id] + 1
                    COUNT_MSG = COUNT_MSG + 1
Esempio n. 28
0
async def add_to_gban(chat):
    if not is_mongo_alive() or not is_redis_alive():
        await chat.edit("`Database connections failing!`")
        return
    await add_chat_gban(chat.chat_id)
    print(chat.chat_id)
    await chat.edit("`Added this bot under the Gbanlist!`")
Esempio n. 29
0
async def lists_logic(event):
    """ Lists logic. """
    if environ.get("isSuspended") == "True":
        return
    try:
        if not (await event.get_sender()).bot:
            if not is_mongo_alive() or not is_redis_alive():
                return

            listname = event.text[1:]
            _list = await get_list(event.chat_id, listname)
            if _list:
                storage = "None"
                if _list['chat_id'] == 0:
                    storage = "global"
                else:
                    storage = str(_list['chat_id'])

                return_str = LIST_HEADER.format(listname, storage)

                if _list['items']:
                    for i, item in enumerate(_list['items']):
                        return_str += f"{i+1}. {item}\n"

                    return_str += f"\n{CHK_HELP}"
                else:
                    return_str = f"`This list is empty!` {CHK_HELP}"

                await event.reply(return_str)
    except BaseException:
        pass
Esempio n. 30
0
async def mention_afk(mention):
    """ This function takes care of notifying the
     people who mention you that you are AFK."""

    global COUNT_MSG
    global USERS
    if not is_redis_alive():
        return
    AFK = await is_afk()
    if mention.message.mentioned and not (await mention.get_sender()).bot:
        if AFK is True:
            if mention.sender_id not in USERS:
                await mention.reply(
                    "π™Žπ™˜π™ͺ𝙨𝙖! π™ˆπ™– α΄€κœ±Κœ Γ¨ π˜Όπ™π™† π™₯π™šπ™§: " + await afk_reason() +
                    ". π™‚π™‘π™ž π™’π™–π™£π™™π™šπ™§Γ² π™ͺ𝙣𝙖 π™£π™€π™©π™žπ™›π™žπ™˜π™– π™₯π™šπ™§ 𝙛𝙖𝙧 π™«π™šπ™™π™šπ™§π™š π™žπ™‘ 𝙩π™ͺ𝙀 π™’π™šπ™¨π™¨π™–π™œπ™œπ™žπ™€πŸ˜‰."
                )
                USERS.update({mention.sender_id: 1})
                COUNT_MSG = COUNT_MSG + 1
            elif mention.sender_id in USERS:
                if USERS[mention.sender_id] % 5 == 0:
                    await mention.reply(
                        "π™Žπ™˜π™ͺ𝙨𝙖! π™ˆπ™– α΄€κœ±Κœ 𝙣𝙀𝙣 Γ¨ π™–π™£π™˜π™€π™§π™– 𝙩𝙀𝙧𝙣𝙖𝙩𝙀. "
                        "𝙋𝙧𝙀𝙫𝙖 𝙖 π™žπ™£π™«π™žπ™–π™§π™œπ™‘π™ž π™ͺ𝙣 π™’π™šπ™¨π™¨π™–π™œπ™œπ™žπ™€ 𝙩𝙧𝙖 π™ͺ𝙣 π™₯𝙀'. π™ˆπ™ž π™™π™žπ™¨π™₯π™žπ™–π™˜π™šπŸ˜–."
                        "π™ˆπ™ž 𝙝𝙖 π™™π™šπ™©π™©π™€ π™˜π™π™š π™šπ™§π™– π™žπ™’π™₯π™šπ™œπ™£π™–π™©π™€ π™₯π™šπ™§: ```" +
                        await afk_reason() + "```")
                    USERS[mention.sender_id] = USERS[mention.sender_id] + 1
                    COUNT_MSG = COUNT_MSG + 1
                else:
                    USERS[mention.sender_id] = USERS[mention.sender_id] + 1
                    COUNT_MSG = COUNT_MSG + 1