Beispiel #1
0
def check_afk(bot, update, user_id, fst_name):
    chat = update.effective_chat  # type: Optional[Chat]
    if sql.is_afk(user_id):
        user = sql.check_afk_status(user_id)
        if not user.reason:
            res = tld(chat.id, f"{fst_name} is AFK!")
        else:
            res = tld(chat.id, f"{fst_name} is AFK! \nReason: {user.reason}")
        update.effective_message.reply_text(res)
Beispiel #2
0
def check_afk(bot, update, user_id, fst_name):
    if sql.is_afk(user_id):
        user = sql.check_afk_status(user_id)
        if not user.reason:
            res = "{} is AFK!".format(fst_name)
        else:
            res = "{} is AFK!.\nReason: <code>{}</code>".format(
                html.escape(fst_name), html.escape(user.reason))
        update.effective_message.reply_text(res, parse_mode=ParseMode.HTML)
Beispiel #3
0
def __user_info__(user_id):
    is_afk = sql.is_afk(user_id)

    text = "<b>Currently AFK</b>: {}"
    if is_afk:
        text = text.format("Yes")

    else:
        text = text.format("No")
    return text
Beispiel #4
0
def check_afk(bot, update, user_id, fst_name):
    chat = update.effective_chat  # type: Optional[Chat]
    if sql.is_afk(user_id):
        user = sql.check_afk_status(user_id)
        if not user.reason:
            res = tld(chat.id, "{} is AFK!").format(fst_name)
        else:
            res = tld(chat.id, "{} is AFK! says its because of: \n{}").format(
                fst_name, user.reason)
        update.effective_message.reply_text(res)
Beispiel #5
0
def check_afk(bot, update, user_id, fst_name, userc_id):
    chat = update.effective_chat  # type: Optional[Chat]
    if sql.is_afk(user_id):
        user = sql.check_afk_status(user_id)
        if not user.reason:
            if int(userc_id) == int(user_id):
                return
            res = "{} is afk".format(fst_name)
            update.effective_message.reply_text(res)
        else:
            if int(userc_id) == int(user_id):
                return
            res = "{} is afk.\nReason: {}".format(fst_name, user.reason)
            update.effective_message.reply_text(res)
Beispiel #6
0
def check_afk(bot, update, user_id, fst_name):
    chat = update.effective_chat  # type: Optional[Chat]
    if sql.is_afk(user_id):
        user = sql.check_afk_status(user_id)
        elapsed_time = time.time() - start_time
        final = time.strftime("%Hh: %Mm: %Ss", time.gmtime(elapsed_time))
        if not user.reason:
            res = tld(chat.id, f"{fst_name} is AFK !\n\nLast seen {final} ago")
        else:
            res = tld(
                chat.id,
                f"{fst_name} is AFK !\n\nSays it's because of:\n{user.reason}\n\nLast seen {final} ago"
            )
        update.effective_message.reply_text(res)
Beispiel #7
0
def check_afk(update, context, user_id, fst_name, userc_id):
    if sql.is_afk(user_id):
        user = sql.check_afk_status(user_id)
        afk_time = sql.get_afk_time(user_id)
        afk_since = get_readable_time((time.time() - afk_time))
        if not user.reason:
            if int(userc_id) == int(user_id):
                return
            res = "{} is afk since {}".format(fst_name, afk_since)
            update.effective_message.reply_text(res)
        else:
            if int(userc_id) == int(user_id):
                return
            res = "{} is afk since {}\nReason: {}".format(
                fst_name, afk_since, user.reason)
            update.effective_message.reply_text(res)
Beispiel #8
0
def check_afk(update: Update, context: CallbackContext, user_id: int,
              fst_name: str, userc_id: int):
    if sql.is_afk(user_id):
        user = sql.check_afk_status(user_id)

        if int(userc_id) == int(user_id):
            return

        time = humanize.naturaldelta(datetime.now() - user.time)

        if not user.reason:
            res = "{} is AFK.\nLast seen {} ago.".format(fst_name, time)
            update.effective_message.reply_text(res)
        else:
            res = "{} is AFK.\nReason: <code>{}</code>\nLast seen {} ago.".format(
                html.escape(fst_name), html.escape(user.reason), time)
            update.effective_message.reply_text(res, parse_mode="html")
Beispiel #9
0
def check_afk(bot, update, user_id, fst_name):
    if sql.is_afk(user_id):
        user = sql.check_afk_status(user_id)
        if not user.reason:
            res = "{} is AFK!".format(fst_name)
        else:
            res = "{} is AFK! says its because of: \n{}".format(fst_name, user.reason)
        update.effective_message.reply_text(res)


        valid, reason = sql.check_afk_status(user_id)
        if valid:
            if not reason:
                res = "{} is AFK!".format(fst_name)
            else:
                res = "{} is AFK! says its because of:\n{}".format(fst_name, reason)
            message.reply_text(res)
Beispiel #10
0
def reply_afk(update, context):
    message = update.effective_message  # type: Optional[Message]

    entities = message.parse_entities(
        [MessageEntity.TEXT_MENTION, MessageEntity.MENTION]
    )
    if message.entities and entities:
        for ent in entities:
            if ent.type == MessageEntity.TEXT_MENTION:
                user_id = ent.user.id
                fst_name = ent.user.first_name

            elif ent.type == MessageEntity.MENTION:
                user_id = get_user_id(
                    message.text[ent.offset : ent.offset + ent.length]
                )
                if not user_id:
                    # Should never happen, since for a user to become AFK they must have spoken. Maybe changed username?
                    return
                try:
                    chat = context.bot.get_chat(user_id)
                except BadRequest:
                    print("Error in afk can't get user id {}".format(user_id))
                    return
                fst_name = chat.first_name

            else:
                return

            if sql.is_afk(user_id):
                valid, reason = sql.check_afk_status(user_id)
                if valid:
                    if not reason:
                        rplafkstr = random.choice(fun.AFKRPL)
                        res = rplafkstr.format(fst_name)
                    else:
                        res = f"<b>{fst_name}</b> is away from keyboard! says it's because of \n{reason}"
                    send_message(
                        update.effective_message,
                        res,
                        parse_mode=ParseMode.HTML,
                    )
Beispiel #11
0
def reply_afk(update: Update, context: CallbackContext):
    bot = context.bot
    message = update.effective_message  # type: Optional[Message]
    entities = message.parse_entities(
        [MessageEntity.TEXT_MENTION, MessageEntity.MENTION])
    if message.entities and entities:
        for ent in entities:
            if ent.type == MessageEntity.TEXT_MENTION:
                user_id = ent.user.id
                fst_name = ent.user.first_name

            elif ent.type == MessageEntity.MENTION:
                user_id = get_user_id(message.text[ent.offset:ent.offset +
                                                   ent.length])
                if not user_id:
                    # Should never happen, since for a user to become AFK they must have spoken. Maybe changed username?
                    return
                chat = bot.get_chat(user_id)
                fst_name = chat.first_name

            else:
                return

            if sql.is_afk(user_id):
                valid, reason = sql.check_afk_status(user_id)
                if valid:
                    if not reason:
                        res = get_string(
                            "afk", "MSG_IS_AFK",
                            lang.get_lang(update.effective_chat.id)).format(
                                fst_name)  # MSG_IS_AFK
                    else:
                        res = get_string(
                            "afk", "MSG_IS_AFK_REASON",
                            lang.get_lang(update.effective_chat.id)).format(
                                fst_name, reason)  # MSG_IS_AFK_REASON
                    message.reply_text(res)
Beispiel #12
0
def info(update: Update, context: CallbackContext):
    bot, args = context.bot, context.args
    message = update.effective_message
    chat = update.effective_chat
    user_id = extract_user(update.effective_message, args) 

    if user_id:
        user = bot.get_chat(user_id)

    elif not message.reply_to_message and not args:
        user = message.from_user

    elif not message.reply_to_message and (
            not args or
        (len(args) >= 1 and not args[0].startswith("@") and
         not args[0].isdigit() and
         not message.parse_entities([MessageEntity.TEXT_MENTION]))):
        message.reply_text("I can't extract a user from this.")
        return

    else:
        return

    del_msg = message.reply_text("searching info data of user....",parse_mode=ParseMode.HTML)
    
    text = (f"<b>• General :-</b>\n\n"
            f"∘ ID: <code>{user.id}</code>\n"
            f"∘ First Name: {html.escape(user.first_name)}")

    if user.last_name:
        text += f"\n∘ Last Name: {html.escape(user.last_name)}"

    if user.username:
        text += f"\n∘ Username: @{html.escape(user.username)}"


    isafk = is_afk(user.id)
    try:
        text += "\n\n∘ Currently AFK: "
        if user.id == bot.id:
             text += "<code>???</code>"
        else:
             text += str(isafk)
    except:
         pass

    try:
        if user.id == bot.id:
           num_chats = "???"
        else:
           num_chats = get_user_num_chats(user.id)
       
        text += f"\n∘ Mutual Chats: <code>{num_chats}</code> "
    except BadRequest:
        pass
    
    
    try:
        status = status = bot.get_chat_member(chat.id, user.id).status
        if status:
               if status in "left":
                   text += "\n∘ Chat Status: <em>Not Here!</em>"
               elif status == "member":
                   text += "\n∘ Chat Status: <em>Is Here!</em>"
               elif status in "administrator":
                   text += "\n∘ Chat Status: <em>Admin!</em>"
               elif status in "creator": 
                   text += "\n∘ Chat Status: <em>Creator!</em>"
    except BadRequest:
        pass
    
    
    
    try:
        user_member = chat.get_member(user.id)
        if user_member.status == 'administrator':
            result = requests.post(f"https://api.telegram.org/bot{TOKEN}/getChatMember?chat_id={chat.id}&user_id={user.id}")
            result = result.json()["result"]
            if "custom_title" in result.keys():
                custom_title = result['custom_title']
                text += f"\n∘ Admin Title: <code>{custom_title}</code> \n"
    except BadRequest:
        pass
   
    if user.id ==1286562476:
        text += "\n🚶🏻‍♂️Uff,This person is sudo \n HE IS is the cutie!."

    if user.id == OWNER_ID:
        text += "\nThis person is my Owner\nI would never do anything against him!."
        
    elif user.id in DEV_USERS:
        text += "\nThis person is my dev\nI would never do anything against him!."
        
    elif user.id in SUDO_USERS:
        text += "\nThis person is one of my sudo users! " \
                    "Nearly as powerful as my owner🕊so watch it.."
        
    elif user.id in SUPPORT_USERS:
        text += "\nThis person is one of my support users! " \
                        " He can gban you off the map."
        
       
    elif user.id in WHITELIST_USERS:
        text += "\nThis person has been whitelisted! " \
                        "That means I'm not allowed to ban/kick them."
    
       
    elif user.id == bot.id:
        text+= "\n\nI've Seen Them In... Wow. Are They Stalking Me? They're In All The Same Places I Am... Oh. It's Me.\n"

    text +="\n"
    text += "\nCAS banned: "
    result = cas.banchecker(user.id)
    text += str(result)
    for mod in USER_INFO:
        if mod.__mod_name__ == "info":
            continue

    for mod in USER_INFO:
        if mod.__mod_name__ == "Users":
            continue

        try:
            mod_info = mod.__user_info__(user.id)
        except TypeError:
            mod_info = mod.__user_info__(user.id, chat.id)
        if mod_info:
            text += "\n" + mod_info
    try:
        profile = bot.get_user_profile_photos(user.id).photos[0][-1]
        _file = bot.get_file(profile["file_id"])
        _file.download(f"{user.id}.png")

        message.reply_document(
        document=open(f"{user.id}.png", "rb"),
        caption=(text),
        parse_mode=ParseMode.HTML,
        disable_web_page_preview=True)

    except IndexError:
        message.reply_text(text, parse_mode=ParseMode.HTML, disable_web_page_preview=True)
    finally:
        del_msg.delete()