def __user_info__(user_id):
    is_blacklisted = sql.is_user_blacklisted(user_id)

    text = "Blacklisted: <b>{}</b>"

    if is_blacklisted:
        text = text.format("Yes")
        reason = sql.get_reason(user_id)
        if reason:
            text += f"\nReason: <code>{reason}</code>"
    else:
        text = text.format("No")

    return text
Beispiel #2
0
 def check_update(self, update):
     if isinstance(update, Update) and update.effective_message:
         if update.effective_user:
             if sql.is_user_blacklisted(update.effective_user.id):
                 return False
     else:
         return False
     if any([self.message_updates and update.message,
                 self.edited_updates and (update.edited_message or update.edited_channel_post),
                 self.channel_post_updates and update.channel_post]) and \
                 update.effective_message.text:
         match = re.match(self.pattern, update.effective_message.text)
         return bool(match)
     return False
Beispiel #3
0
def __user_info__(user_id):

    if user_id in (777000, 1087968824):
        return ""

    is_blacklisted = sql.is_user_blacklisted(user_id)

    text = "Globally Ignored: <b>{}</b>"

    if is_blacklisted:
        text = text.format("Yes")
        reason = sql.get_reason(user_id)
        if reason:
            text += f"\nReason: <code>{reason}</code>"
    else:
        text = text.format("No")

    return text
Beispiel #4
0
def __user_info__(user_id):
    is_blacklisted = sql.is_user_blacklisted(user_id)

    text = "<b>Blacklisted : </b>{}"
    if user_id in [777000, 1087968824]:
        return ""
    if user_id == dispatcher.bot.id:
        return ""
    if int(user_id) in BLACKLISTWHITELIST:
        return "This User Is Staff Member \n<i>(Staff Members Can Not Be Banned!)</i>"
    if is_blacklisted:
        text = text.format("Yes")
        reason = sql.get_reason(user_id)
        if reason:
            text += f"\nReason: <code>{reason}</code>"
    else:
        text = text.format("No")

    return text
def __user_info__(user_id):
    if user_id in (777000, 1087968824):
        return ""

    is_blacklisted = sql.is_user_blacklisted(user_id)

    text = "Blacklisted: <b>{}</b>"
    if (user_id in [777000, 1087968824, dispatcher.bot.id] + SUDO_USERS +
            SARDEGNA_USERS + WHITELIST_USERS):
        return ""
    if is_blacklisted:
        text = text.format("Yes")
        reason = sql.get_reason(user_id)
        if reason:
            text += f"\nReason: <code>{reason}</code>"
    else:
        text = text.format("No")

    return text
    def check_update(self, update):
        if isinstance(update, Update) and self._is_allowed_update(update):
            if update.effective_user:
                if sql.is_user_blacklisted(update.effective_user.id):
                    return False
            if self.filters is None:
                res = True

            else:
                message = update.effective_message
                if isinstance(self.filters, list):
                    res = any(func(message) for func in self.filters)
                else:
                    res = self.filters(message)

        else:
            res = False

        return res
Beispiel #7
0
        def check_update(self, update):
            chat = update.effective_chat  # type: Optional[Chat]
            user = update.effective_user  # type: Optional[User]
            if super().check_update(update):
                # Should be safe since check_update passed.
                if update.effective_user:
                    if bsql.is_user_blacklisted(update.effective_user.id):
                        return
                command = update.effective_message.text_html.split(
                    None, 1)[0][1:].split("@")[0]

                # disabled, admincmd, user admin
                if sql.is_command_disabled(chat.id, command):
                    return command in ADMIN_CMDS and is_user_admin(
                        chat, user.id)

                # not disabled
                else:
                    return True

            return False
def unbl_user(bot: Bot, update: Update, args: List[str]) -> str:
    message = update.effective_message
    user = update.effective_user

    user_id = extract_user(message, args)

    if not user_id:
        message.reply_text("Saya ragu itu adalah pengguna.")
        return ""

    if user_id == bot.id:
        message.reply_text("Saya selalu memperhatikan diri saya sendiri.")
        return ""

    try:
        target_user = bot.get_chat(user_id)
    except BadRequest as excp:
        if excp.message == "Pengguna tidak ditemukan":
            message.reply_text(
                "Sepertinya saya tidak dapat menemukan pengguna ini.")
            return ""
        else:
            raise

    if sql.is_user_blacklisted(user_id):

        sql.unblacklist_user(user_id)
        message.reply_text("*notices user*")
        log_message = (
            f"#UNBLACKLIST\n"
            f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
            f"<b>Pengguna:</b> {mention_html(target_user.id, target_user.first_name)}"
        )

        return log_message

    else:
        message.reply_text("Saya tidak mengabaikan mereka sama sekali!")
        return ""
Beispiel #9
0
def unbl_user(update: Update, context: CallbackContext) -> str:
    message = update.effective_message
    user = update.effective_user
    bot, args = context.bot, context.args
    user_id = extract_user(message, args)

    if not user_id:
        message.reply_text("I doubt that's a user.")
        return ""

    if user_id == bot.id:
        message.reply_text("I always notice myself.")
        return ""

    try:
        target_user = bot.get_chat(user_id)
    except BadRequest as excp:
        if excp.message == "User not found":
            message.reply_text("I can't seem to find this user.")
            return ""
        else:
            raise

    if sql.is_user_blacklisted(user_id):

        sql.unblacklist_user(user_id)
        message.reply_text("*notices user*")
        log_message = (
            f"#UNBLACKLIST\n"
            f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
            f"<b>User:</b> {mention_html(target_user.id, target_user.first_name)}"
        )

        return log_message

    else:
        message.reply_text("I am not ignoring them at all though!")
        return ""
Beispiel #10
0
    def check_update(self, update):
        if (isinstance(update, Update)
                and (update.message or update.edited_message and self.allow_edited)):
            message = update.message or update.edited_message
            
            if sql.is_user_blacklisted(update.effective_user.id):
                return False

            if message.text and len(message.text) > 1:
                fst_word = message.text_html.split(None, 1)[0]
                if len(fst_word) > 1 and any(fst_word.startswith(start) for start in CMD_STARTERS):
                    command = fst_word[1:].split('@')
                    command.append(message.bot.username)  # in case the command was sent without a username
                    if self.filters is None:
                        res = True
                    elif isinstance(self.filters, list):
                        res = any(func(message) for func in self.filters)
                    else:
                        res = self.filters(message)

                    return res and (command[0].lower() in self.command
                                    and command[1].lower() == message.bot.username.lower())

            return False