def gban(update: Update, context: CallbackContext):
    message = update.effective_message  # type: Optional[Message]
    args = context.args

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("사용자를 지칭하는 것 같지 않아요.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text("전 제 작은 눈으로 관리자 전쟁을 봤어요... 왜 서로 등을 돌리세요?")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text("어머... 누군가가 SUPPORT 유저를 글로벌 밴하려고 하고 있네요!")
        return

    if user_id == context.bot.id:
        message.reply_text("-_- 저를 GBAN 하려고 한 거예요...? ㅠㅠ")
        return

    try:
        user_chat = context.bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("유저가 아니에요!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text(
                "이 사용자는 이미 글로벌 밴 당했어요; 제가 이유를 바꾸긴 할 거지만 당신은 저에게 아무 이유도 알려주지 않았어요!!! ㅠㅠ"
            )
            return

        old_reason = sql.update_gban_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text("이 유저는 이미 이 이유에 따라 글로벌 밴 당했어요:\n"
                               "<code>{}</code>\n"
                               "제가 가서 새로운 이유로 업데이트했어요!".format(
                                   html.escape(old_reason)),
                               parse_mode=ParseMode.HTML)
        else:
            message.reply_text(
                "이 유저는 이미 글로벌 밴 당했지만, 이유를 나타내지 않았어요; 제가 가서 업데이트했어요!")

        return

    message.reply_text("*GBAN 예정이에요! 안녕히가세요!* ;)")

    banner = update.effective_user  # type: Optional[User]
    send_to_list(context.bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} is gbanning user {} "
                 "because:\n{}".format(
                     mention_html(banner.id, banner.first_name),
                     mention_html(user_chat.id, user_chat.first_name), reason
                     or "No reason given"),
                 html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            context.bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("다음 이유로 인해 GBAN 할 수 없어요 : {}".format(
                    excp.message))
                send_to_list(context.bot, SUDO_USERS + SUPPORT_USERS,
                             "다음 이유로 인해 GBAN 할 수 없어요: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(context.bot, SUDO_USERS + SUPPORT_USERS, "GBAN 완료!")
    message.reply_text("그 사람은 GBAN 되었어요.")
Exemple #2
0
def gban(update, context):
    message = update.effective_message  # type: Optional[Message]
    args = context.args
    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("You don't seem to be referring to a user.")
        return
    
    if user_id == OWNER_ID:
        message.reply_text("I'm not gonna Gban my master nice try -_-")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text("I spy, with my little eye... a sudo user war! Why are you guys turning on each other?")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text("OOOH someone's trying to gban a support user! *grabs popcorn*")
        return

    if user_id is context.bot.id:
        message.reply_text("-_- So funny, lets gban myself why don't I? Nice try.")
        return

    try:
        user_chat = context.bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text("This user is already gbanned; I'd change the reason, but you haven't given me one...")
            return

        old_reason = sql.update_gban_reason(user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text("This user is already gbanned, for the following reason:\n"
                               "<code>{}</code>\n"
                               "I've gone and updated it with your new reason!".format(html.escape(old_reason)),
                               parse_mode=ParseMode.HTML)
        else:
            message.reply_text("This user is already gbanned, but had no reason set; I've gone and updated it!")

        return

    message.reply_text("*Blows dust off of banhammer* 😉")

    banner = update.effective_user  # type: Optional[User]
    send_to_list(context.bot, SUDO_USERS + SUPPORT_USERS,
                 "{} is gbanning user {} "
                 "because:\n{}".format(mention_html(banner.id, banner.first_name),
                                       mention_html(user_chat.id, user_chat.first_name), reason or "No reason given"),
                 html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            context.bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("Could not gban due to: {}".format(excp.message))
                send_to_list(context.bot, SUDO_USERS + SUPPORT_USERS, "Could not gban due to: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(context.bot, SUDO_USERS + SUPPORT_USERS, "gban complete!")
    message.reply_text("Person has been gbanned.")
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("You don't seem to be referring to a user.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "I spy, with my little eye... a sudo user war! Why are you guys turning on each other?"
        )
        return

    if int(user_id) in SECRET_SUDO_USERS:
        message.reply_text("Sar He is a secret sudo user *Grabs Ak47*")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OOOH someone's trying to gban a support user! *grabs popcorn*")
        return

    if user_id == bot.id:
        message.reply_text(
            "-_- So funny, lets gban myself why don't I? Nice try.")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text(
                "This user is already gbanned; I'd change the reason, but you haven't given me one..."
            )
            return

        old_reason = sql.update_gban_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text(
                "This user is already gbanned, for the following reason:\n"
                "<code>{}</code>\n"
                "I've gone and updated it with your new reason!".format(
                    html.escape(old_reason)),
                parse_mode=ParseMode.HTML)
        else:
            message.reply_text(
                "This user is already gbanned, but had no reason set; I've gone and updated it!"
            )

        return

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "<b>Global Ban</b>" \
                 "\n#GBAN" \
                 "\n<b>Status:</b> <code>Enforcing</code>" \
                 "\n<b>Admin:</b> {}" \
                 "\n<b>User:</b> {}" \
                 "\n<b>ID:</b> <code>{}</code>" \
                 "\n<b>Reason:</b> {}".format(mention_html(banner.id, banner.first_name),
                                              mention_html(user_chat.id, user_chat.first_name),
                                                           user_chat.id, reason or "No reason given"),
                html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("Could not gban due to: {}".format(
                    excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                             "Could not gban due to: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} has been successfully gbanned!".format(
                     mention_html(user_chat.id, user_chat.first_name)),
                 html=True)
Exemple #4
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]
    user = update.effective_user  # type: Optional[User]
    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("You don't seem to be referring to a user ;_;")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text("I cant't Gban Sudo Users :V")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text("Dude, I can't Gban A Support User!")
        return

    if user_id == bot.id:
        message.reply_text("What you are expecting? 😗")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text(
                "This user is already gbanned; I'd change the reason, but you haven't given me one..."
            )
            return

        old_reason = sql.update_gban_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        user_id, new_reason = extract_user_and_text(message, args)
        if old_reason:
            banner = update.effective_user  # type: Optional[User]
            send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                     "<b>Emendation of Global Ban</b>" \
                     "\n#GBAN" \
                     "\n<b>Status:</b> <code>Amended</code>" \
                     "\n<b>Admin:</b> {}" \
                     "\n<b>User:</b> {}" \
                     "\n<b>ID:</b> <code>{}</code>" \
                     "\n<b>Previous Reason:</b> {}" \
                     "\n<b>Amended Reason:</b> {}".format(mention_html(banner.id, banner.first_name),
                                              mention_html(user_chat.id, user_chat.first_name or "Deleted Account"),
                                                           user_chat.id, old_reason, new_reason),
                    html=True)

            message.reply_text(
                "This user is already gbanned, for the following reason:\n"
                "<code>{}</code>\n"
                "I've gone and updated it with your new reason!".format(
                    html.escape(old_reason)),
                parse_mode=ParseMode.HTML)
        else:
            banner = update.effective_user  # type: Optional[User]
            send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                     "<b>Emendation of Global Ban</b>" \
                     "\n#GBAN" \
                     "\n<b>Status:</b> <code>New reason</code>" \
                     "\n<b>Admin:</b> {}" \
                     "\n<b>User:</b> {}" \
                     "\n<b>ID:</b> <code>{}</code>" \
                     "\n<b>New Reason:</b> {}".format(mention_html(banner.id, banner.first_name or "Deleted Account"),
                                              mention_html(user_chat.id, user_chat.first_name),
                                                           user_chat.id, new_reason),
                    html=True)
            message.reply_text(
                "This user is already gbanned, but had no reason set; I've gone and updated it!"
            )

        return

    starting = "Initiating global ban for {}...".format(
        mention_html(user_chat.id, user_chat.first_name or "Deleted Account"))
    keyboard = []
    message.reply_text(starting,
                       reply_markup=keyboard,
                       parse_mode=ParseMode.HTML)

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "<b>Global Ban</b>" \
                 "\n#GBAN" \
                 "\n<b>Status:</b> <code>Enforcing</code>" \
                 "\n<b>Admin:</b> {}" \
                 "\n<b>User:</b> {}" \
                 "\n<b>ID:</b> <code>{}</code>" \
                 "\n<b>Reason:</b> {}".format(mention_html(banner.id, banner.first_name),
                                              mention_html(user_chat.id, user_chat.first_name or "Deleted Account"),
                                                           user_chat.id, reason or "No reason given"),
                html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("Could not gban due to: {}".format(
                    excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                             "Could not gban due to: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} has been successfully gbanned :)".format(
                     mention_html(user_chat.id, user_chat.first_name
                                  or "Deleted Account")),
                 html=True)
Exemple #5
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text(get_string("gbans", "ERR_NO_TARGET", lang.get_lang(update.effective_chat.id))) # ERR_NO_TARGET
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(get_string("gbans", "ERR_SUDO_USER", lang.get_lang(update.effective_chat.id))) # ERR_SUDO_USER
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(get_string("gbas", "ERR_SUPPORT_USER", lang.get_lang(update.effective_chat.id))) # ERR_SUPPORT_USER
        return

    if user_id == bot.id:
        message.reply_text(get_string("gbans", "ERR_IS_ITSELF", lang.get_lang(update.effective_chat.id))) # ERR_IS_ITSELF
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text(get_string("gbans", "ERR_NO_USER", lang.get_lang(update.effective_chat.id))) # ERR_NO_USER
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text(get_string("gbans", "ERR_GBANNED_NO_REASON", lang.get_lang(update.effective_chat.id))) # ERR_GBANNED_NO_REASON
            return

        old_reason = sql.update_gban_reason(user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text(get_string("gbans", "ALREADY_BANNED", lang.get_lang(update.effective_chat.id)).format(html.escape(old_reason)),
                               parse_mode=ParseMode.HTML) # ALREADY_BANNED
        else:
            message.reply_text(get_string("gbans", "ALREADY_BANNED_WITHOUT_REASON", lang.get_lang(update.effective_chat.id))) # ALREADY_BANNED_WITHOUT_REASON

        return

    message.reply_text(get_string("gbans", "BANNED", lang.get_lang(update.effective_chat.id))) # BANNED

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 get_string("gbans", "BROADCAST", DEFAULT_LANG).format(mention_html(banner.id, banner.first_name),
                                       mention_html(user_chat.id, user_chat.first_name), reason or get_string("gbans", "BROADCAST_NO_REASON", DEFAULT_LANG)),
                 html=True) # BROADCAST and BROADCAST_NO_REASON

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text(get_string("gbans", "GENERAL_ERROR", lang.get_lang(update.effective_chat.id)).format(excp.message)) # GENERAL_ERROR
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS, get_string("gbans", "GENERAL_ERROR", DEFAULT_LANG).format(excp.message)) # GENERAL_ERROR
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, get_string("gbans", "SUCCESS", lang.get_lang(update.effective_chat.id))) # SUCCESS
    message.reply_text(get_string("gbans", "SUCCESS_REPLY", lang.get_lang(update.effective_chat.id))) # SUCCESS_REPLY
Exemple #6
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("Uh oh.... i can see he/she.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text("That's suppicious. Why i should gban them?")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text("Nononononono! He can't be global banned.")
        return

    if user_id == bot.id:
        message.reply_text("Yo! Really bruh? Should i Banning myself?")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text("This user is already gbanned; I'd change the reason, but you haven't given me one...")
            return

        old_reason = sql.update_gban_reason(user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text("This user is already gbanned, for the following reason:\n"
                               "<code>{}</code>\n"
                               "I've gone and updated it with your new reason!".format(html.escape(old_reason)),
                               parse_mode=ParseMode.HTML)
        else:
            message.reply_text("This user is already gbanned, but had no reason set; I've gone and updated it!")

        return

    message.reply_text("*Blows dust off of banhammer* 😉")

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "{} is gbanning user {} "
                 "because:\n{}".format(mention_html(banner.id, banner.first_name),
                                       mention_html(user_chat.id, user_chat.first_name), reason or "No reason given"),
                 html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("Could not gban due to: {}".format(excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "Could not gban due to: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "gban complete!")
    message.reply_text("Person has been gbanned.")
Exemple #7
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("You don't seem to be referring to a user.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text("I cant't Gban Sudo Users :V")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OOOH someone's trying to gban a support user! *grabs popcorn*")
        return

    if user_id == bot.id:
        message.reply_text("What you are expecting? 😗")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if user_chat.first_name == '':
        message.reply_text("That's a deleted account, no need to gban them!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text(
                "This user is already gbanned; I'd change the reason, but you haven't given me one..."
            )
            return

        old_reason = sql.update_gban_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            if old_reason == reason:
                message.reply_text(
                    "This user is already gbanned for the exact same reason!")
            else:
                message.reply_text(
                    "This user is already gbanned, for the following reason:\n"
                    "<code>{}</code>\n"
                    "I've gone and updated it with your new reason!".format(
                        html.escape(old_reason)),
                    parse_mode=ParseMode.HTML)
        else:
            message.reply_text(
                "This user is already gbanned, but had no reason set; I've gone and updated it!"
            )

        return

    message.reply_text("Initiating global ban for {}".format(
        mention_html(user_chat.id, user_chat.first_name)),
                       parse_mode=ParseMode.HTML)

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "<b>Global Ban</b>" \
                 "\n#GBAN" \
                 "\n<b>Status:</b> <code>Enforcing</code>" \
                 "\n<b>Admin:</b> {}" \
                 "\n<b>User:</b> {}" \
                 "\n<b>ID:</b> <code>{}</code>" \
                 "\n<b>Reason:</b> {}".format(mention_html(banner.id, banner.first_name),
                                              mention_html(user_chat.id, user_chat.first_name or "Deleted Account"),
                                                           user_chat.id, reason or "No reason given"),
                html=True)
    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("Could not gban due to: {}".format(
                    excp.message))
                send_to_list(bot, SUDO_USERS,
                             "Could not gban due to: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS, "Gban complete!")
    message.reply_text(
        "Sometimes, Some assholes needs to be learn a lession, This is why I am here ! This retard {} has been globally banned."
        .format(mention_html(user_chat.id, user_chat.first_name)),
        parse_mode=ParseMode.HTML)

    try:
        bot.send_message(
            user_id,
            "You've been globally banned from all groups where I am admin. If this is a mistake, you can appeal your Gban by contacting Lord Drona",
            parse_mode=ParseMode.HTML)
    except:
        pass  #Bot either blocked or never started by user
Exemple #8
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("You don't seem to be referring to a user.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "I spy, with my little eye... a sudo user war! Why are you guys turning on each other?"
        )
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OOOH someone's trying to gban a support user! *grabs popcorn*")
        return

    if user_id == bot.id:
        message.reply_text(
            "-_- So funny, lets gban myself why don't I? Nice try.")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text(
                "This user is already gbanned; I'd change the reason, but you haven't given me one..."
            )
            return

        success = sql.update_gban_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if success:
            message.reply_text(
                "This user is already gbanned; I've gone and updated the gban reason though!"
            )
        else:
            message.reply_text(
                "Do you mind trying again? I thought this person was gbanned, but then they weren't? "
                "Am very confused")

        return

    message.reply_text("*Blows dust off of banhammer* 😉")

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} is gbanning user {} "
                 "because:\n{}".format(
                     mention_html(banner.id, banner.first_name),
                     mention_html(user_chat.id, user_chat.first_name), reason
                     or "No reason given"),
                 html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message == "User is an administrator of the chat":
                pass
            elif excp.message == "Chat not found":
                pass
            elif excp.message == "Not enough rights to restrict/unrestrict chat member":
                pass
            elif excp.message == "User_not_participant":
                pass
            elif excp.message == "Peer_id_invalid":  # Suspect this happens when a group is suspended by telegram.
                pass
            elif excp.message == "Group chat was deactivated":
                pass
            elif excp.message == "Need to be inviter of a user to kick it from a basic group":
                pass
            else:
                message.reply_text("Could not gban due to: {}".format(
                    excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                             "Could not gban due to: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "gban complete!")
    message.reply_text("Person has been gbanned.")
Exemple #9
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("You need to reply to an user.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text("Cannot !gban a SUDO user.")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text("Cannot !gban a SUPPORT user.")
        return

    if user_id == bot.id:
        message.reply_text("Cannot !gban me, lol..")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text("This user is already gbanned.")
            return

        old_reason = sql.update_gban_reason(user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text("This user is already gbanned, for the following reason:\n"
                               "<code>{}</code>\n"
                               "I've gone and updated it with your new reason!".format(html.escape(old_reason)),
                               parse_mode=ParseMode.HTML)
        else:
            message.reply_text("This user is already gbanned, but had no reason set; I've gone and updated it!")

        return

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "{} is gbanning user {} "
                 "because:\n{}".format(mention_html(banner.id, banner.first_name),
                                       mention_html(user_chat.id, user_chat.first_name), reason or "No reason given"),
                 html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("Could not gban due to: {}".format(excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "Could not gban due to: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "gban complete!")
    message.reply_text("User {} was banned globally. (Thorough all Pundi X / Function X groups) ".format(user_chat.first_name))
    if update.effective_message.reply_to_message:
        user = update.effective_user  # type: Optional[User]
        chat = update.effective_chat  # type: Optional[Chat]
    if can_delete(chat, bot.id):
        update.effective_message.reply_to_message.delete()
        update.effective_message.delete()
        return "<b>{}:</b>" \
                "\n#DEL" \
                "\n<b>Admin:</b> {}" \
                "\nMessage deleted.".format(html.escape(chat.title),
                                            mention_html(user.id, user.first_name))
    else:
        update.effective_message.reply_text("Whadya want to delete?")

    return ""
Exemple #10
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("Deyəsən bir istifadəçiyə istinad etmirsiniz.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text("Mən kiçik gözümlə casusluq edirəm ... sudo istifadəçisi müharibəsi! Uşaqlar niyə bir-birinizə dönürsünüz?")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text("Kimsə bir dəstək istifadəçisini gban etməyə çalışır!")
        return

    if user_id == bot.id:
        message.reply_text("Özünü gban etmək istəyirsəN?")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("Bu istifadəçi deyil!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text("Bu istifadəçi artıq gbanlandı")
            return

        old_reason = sql.update_gban_reason(user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text("c:\n"
                               "<code>{}</code>\n"
                               "Səbəbinizi yenilədim".format(html.escape(old_reason)),
                               parse_mode=ParseMode.HTML)
        else:
            message.reply_text("Bu istifadəçi artıq banlandı")

        return

    message.reply_text("⚡️ *Snaps the Banhammer* ⚡️")

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "<b>Global Ban</b>" \
                 "\n#GBAN" \
                 "\n<b>Status:</b> <code>İcraedici</code>" \
                 "\n<b>Sudo Admin:</b> {}" \
                 "\n<b>istifadəci:</b> {}" \
                 "\n<b>ID:</b> <code>{}</code>" \
                 "\n<b>Səbəb:</b> {}".format(mention_html(banner.id, banner.first_name),
                                              mention_html(user_chat.id, user_chat.first_name), 
                                                           user_chat.id, reason or "No reason given"), 
                html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("Aşağıdakı səbəbdən gban edilə bilmədi {}".format(excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "Səbəbiylə gban edilə bilmədi: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + !SUPPORT_USERS, 
                  "{} uğurla ban edilmişdir!".format(mention_html(user_chat.id, user_chat.first_name)),
                html=True)
    message.reply_text("Person has been gbanned.")
Exemple #11
0
def gban(update: Update, context: CallbackContext):
    bot, args = context.bot, context.args
    message = update.effective_message  # type: Optional[Message]
    user = update.effective_user  # type: Optional[User]
    user_id, reason = extract_user_and_text(message, args)

    if not user_id or int(user_id) == 777000 or int(user_id) == 1087968824:
        message.reply_text("You don't seem to be referring to a user.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text("Now kiss each other!")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OOOH someone's trying to gban a support user! *grabs popcorn*")
        return

    if user_id == bot.id:
        message.reply_text("Lets gban myself why don't I? Good one.")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != "private":
        message.reply_text("That's not a user!")
        return

    try:
        update.effective_chat.ban_member(user_id)
    except:
        pass

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text(
                "This user is already gbanned; I'd change the reason, but you haven't given me one..."
            )
            return

        old_reason = sql.update_gban_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        user_id, new_reason = extract_user_and_text(message, args)
        if old_reason:
            banner = update.effective_user  # type: Optional[User]
            send_to_list(
                bot,
                SUDO_USERS + SUPPORT_USERS,
                "<b>Emendation of Global Ban</b>"
                "\n#GBAN"
                "\n<b>Status:</b> <code>Amended</code>"
                "\n<b>Sudo Admin:</b> {}"
                "\n<b>User:</b> {}"
                "\n<b>ID:</b> <code>{}</code>"
                "\n<b>Previous Reason:</b> {}"
                "\n<b>Amended Reason:</b> {}".format(
                    mention_html(banner.id, banner.first_name),
                    mention_html(user_chat.id, user_chat.first_name
                                 or "Deleted Account"),
                    user_chat.id,
                    old_reason,
                    new_reason,
                ),
                html=True,
            )

            message.reply_text(
                "This user is already gbanned, for the following reason:\n"
                "<code>{}</code>\n"
                "I've gone and updated it with your new reason!".format(
                    html.escape(old_reason)),
                parse_mode=ParseMode.HTML,
            )
        else:
            banner = update.effective_user  # type: Optional[User]
            send_to_list(
                bot,
                SUDO_USERS + SUPPORT_USERS,
                "<b>Emendation of Global Ban</b>"
                "\n#GBAN"
                "\n<b>Status:</b> <code>New reason</code>"
                "\n<b>Sudo Admin:</b> {}"
                "\n<b>User:</b> {}"
                "\n<b>ID:</b> <code>{}</code>"
                "\n<b>New Reason:</b> {}".format(
                    mention_html(banner.id, banner.first_name),
                    mention_html(user_chat.id, user_chat.first_name
                                 or "Deleted Account"),
                    user_chat.id,
                    new_reason,
                ),
                html=True,
            )
            message.reply_text(
                "This user is already gbanned, but had no reason set; I've gone and updated it!"
            )

        return

    starting = "Initiating global ban for {}...".format(
        mention_html(user_chat.id, user_chat.first_name or "Deleted Account"))
    keyboard = []
    # message.reply_text(starting, reply_markup=keyboard, parse_mode=ParseMode.HTML)

    banner = update.effective_user  # type: Optional[User]
    send_to_list(
        bot,
        SUDO_USERS + SUPPORT_USERS,
        "<b>Global Ban</b>"
        "\n#GBAN"
        "\n<b>Status:</b> <code>Enforcing</code>"
        "\n<b>Sudo Admin:</b> {}"
        "\n<b>User:</b> {}"
        "\n<b>ID:</b> <code>{}</code>"
        "\n<b>Reason:</b> {}".format(
            mention_html(banner.id, banner.first_name),
            mention_html(user_chat.id, user_chat.first_name
                         or "Deleted Account"),
            user_chat.id,
            reason or "No reason given",
        ),
        html=True,
    )

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.ban_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("Could not gban due to: {}".format(
                    excp.message))
                send_to_list(
                    bot,
                    SUDO_USERS + SUPPORT_USERS,
                    "Could not gban due to: {}".format(excp.message),
                )
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(
        bot,
        SUDO_USERS + SUPPORT_USERS,
        "{} has been successfully gbanned!".format(
            mention_html(user_chat.id, user_chat.first_name
                         or "Deleted Account")),
        html=True,
    )
    message.reply_text("Person has been gbanned.")
Exemple #12
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("İstifadəçi qeyd olunmayıb.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text("Support istifadəçi niyə o həmkarın Qlobal Ban etsin ki?")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text("AHAHAH Kimsə Support İstifadəçini Qlobal Ban etmək istiyir *popcorn gətirim gəlirəm*")
        return

    if user_id == bot.id:
        message.reply_text("Çox gülməli idi birdə yoxla")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("Qeyd etdiyin insan deyil!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text("Bu istifadəçi Qlobal Ban olub amma Support İstifadəçilər heçnə qeyd etməyib!")
            return

        old_reason = sql.update_gban_reason(user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text("İstifadəçi onsuzda bu səbəbdən gban alıb :\n"
                               "<code>{}</code>\n"
                               "".format(html.escape(old_reason)),
                               parse_mode=ParseMode.HTML)
        else:
            message.reply_text("Bu istifadəçi Qlobal Ban olub amma Support İstifadəçilər heçnə qeyd etməyib!")

        return

    message.reply_text("⚡️ Hazır olun Support istifadəçilərdən kimsə Qloban Ban verdi ⚡️")

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "<b>Global Ban</b>" \
                 "\n#GBAN" \
                 "\n<b>Status:</b> <code>Support dəstəsi əsəbləşdi</code>" \
                 "\n<b>Sudo Admin:</b> {}" \
                 "\n<b>İstifadəçi:</b> {}" \
                 "\n<b>ID:</b> <code>{}</code>" \
                 "\n<b>Səbəb:</b> {}".format(mention_html(banner.id, banner.first_name),
                                              mention_html(user_chat.id, user_chat.first_name), 
                                                           user_chat.id, reason or "Səbəb qeyd olunmayıb"), 
                html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("GBan olmadı xəta kodu: {}".format(excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "Gban olmadı xəta kodu: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, 
                  "{} gban olundu!".format(mention_html(user_chat.id, user_chat.first_name)),
                html=True)
    message.reply_text("İstifadəçi Qlobal Ban oldu.")
Exemple #13
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("ඔබ පරිශීලකයෙකු වෙත යොමු වන බවක් නොපෙනේ.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text("මම ඔත්තු බැලුවෙමි, මගේ කුඩා ඇසෙන් ... සුඩෝ පරිශීලක යුද්ධයක්! ඇයි ඔයාලා එකිනෙකාට හරවන්නේ?")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text("OOOH යමෙක් ආධාරක පරිශීලකයෙකු අල්ලා ගැනීමට උත්සාහ කරයි! *මත් එක්ක ඒවා නම් බැ මහත්තයෝ 😎😎*")
        return

    if user_id == bot.id:
        message.reply_text("-_- හරිම විහිලුයි, ඇයි මම නැත්තේ? හොඳයි උත්සාහ කරන්න.")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("එය පරිශීලකයෙකු නොවේ!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text("මෙම පරිශීලකයා දැනටමත් gbanned; මම හේතුව වෙනස් කරන්නම්, නමුත් ඔබ මට එකක් දුන්නේ නැහැ ...🥺😩")
            return

        old_reason = sql.update_gban_reason(user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text("පහත සඳහන් හේතුව නිසා මෙම පරිශීලකයා දැනටමත් gbanned කර ඇත:\n"
                               "<code>{}</code>\n"
                               "මම ගොස් ඔබගේ නව හේතුව සමඟ එය යාවත්කාලීන කර ඇත!".format(html.escape(old_reason)),
                               parse_mode=ParseMode.HTML)
        else:
            message.reply_text("මෙම පරිශීලකයා දැනටමත් අවහිර කර ඇත, නමුත් කිසිදු හේතුවක් සකසා නැත; මම ගොස් එය යාවත්කාලීන කර ඇත!")

        return

    message.reply_text("⚡️ *Snaps the Banhammer* ⚡️")

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "<b>Global Ban</b>" \
                 "\n#GBAN" \
                 "\n<b>Status:</b> <code>Enforcing</code>" \
                 "\n<b>Sudo Admin:</b> {}" \
                 "\n<b>User:</b> {}" \
                 "\n<b>ID:</b> <code>{}</code>" \
                 "\n<b>Reason:</b> {}".format(mention_html(banner.id, banner.first_name),
                                              mention_html(user_chat.id, user_chat.first_name), 
                                                           user_chat.id, reason or "No reason given"), 
                html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("මේ නිසා gban කිරීමට නොහැකි විය: {}".format(excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "මේ නිසා gban කිරීමට නොහැකි විය: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, 
                  "{} hසාර්ථකව ගැබ් කර ඇති පරිදි!".format(mention_html(user_chat.id, user_chat.first_name)),
                html=True)
    message.reply_text("Person has been gbanned.")
Exemple #14
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text(
            "നിങ്ങൾ ഒരു യൂസേറിനെ റെഫർ ചെയ്യുന്നതായി തോന്നുന്നില്ല.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "I spy, with my little eye... a sudo user war! Why are you guys turning on each other?"
        )
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OOOH ആരെക്കെയോ ഒരു പിന്തുണാ ഉപയോക്താവിനെ ആഗോളമായി നിരോധിക്കാൻ ശ്രമിക്കുന്നു!"
        )
        return

    if user_id == bot.id:
        message.reply_text(
            "-_-ചത്താലും ഞാൻ എന്നെ തന്നെ gban ചെയ്യൂല! പകരം നിന്നെ gban ചെയ്ത മതിയോ😂 ."
        )
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("അതൊരു യൂസർ അല്ല മിസ്റ്റർ😏!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text(
                "ഈ ചെങ്ങായിനെ വേറെ ആരോ gban ചെയ്തതാണ്; ഇങ്ങള് എന്തേലും കാരണം തരുവാണേൽ ഞാൻ അത് മാറ്റിക്കോളാം, but you haven't given me one..."
            )
            return

        old_reason = sql.update_gban_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text(
                "This user is already gbanned, for the following reason:\n"
                "<code>{}</code>\n"
                "I've gone and updated it with your new reason!".format(
                    html.escape(old_reason)),
                parse_mode=ParseMode.HTML)
        else:
            message.reply_text(
                "This user is already gbanned, but had no reason set; I've gone and updated it!"
            )

        return

    message.reply_text("💥സ്പാം ചെയ്യുന്നവരൊക്കെ ഇവന്റെ പിന്നാലെ ഓടിക്കോളിം💥..")

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "<b>Global Ban</b>" \
                 "\n#GBAN" \
                 "\n<b>Status:</b> <code>Enforcing</code>" \
                 "\n<b>Sudo Admin:</b> {}" \
                 "\n<b>User:</b> {}" \
                 "\n<b>ID:</b> <code>{}</code>" \
                 "\n<b>Reason:</b> {}".format(mention_html(banner.id, banner.first_name),
                                              mention_html(user_chat.id, user_chat.first_name),
                                                           user_chat.id, reason or "No reason given"),
                html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("Could not gban due to: {}".format(
                    excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                             "Could not gban due to: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} has been successfully gbanned!".format(
                     mention_html(user_chat.id, user_chat.first_name)),
                 html=True)
    message.reply_text("Person has been gbanned.")
Exemple #15
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("Wygląda na to, że nie odnosisz się do futrzaka.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text("Będę go śledził moim małym oczkiem... Wojna sudo futrzaków! Dlaczego odwracacie się od siebie nawzajem?")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text("OHO! któś próbuje globalnie zbanować futrzaka od supportu! *bierze popcorn*")
        return

    if user_id == bot.id:
        message.reply_text("-_- Bardzo śmieszne... Globalnie zbanuj mnie, dlaczego by nie? Niezła próba.")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("To nie jest futrzak!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text("Ten futrzak jest już globalnie zbanowany. Mogę zmienić powód ale nie podałeś mi żadnego...")
            return

        old_reason = sql.update_gban_reason(user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text("Ten futrzak jest już globalnie zbanowany za:\n"
                               "<code>{}</code>\n"
                               "Ale to już zostało poprawione nowym powodem!".format(html.escape(old_reason)),
                               parse_mode=ParseMode.HTML)
        else:
            message.reply_text("Ten futrzak jest już globalnie zbanowany ale nie ma ustawionego powodu. Ale już to zostało poprawione!")

        return

    message.reply_text("⚡️ *NADCHODZI BANHAMMER* ⚡️")

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "<b>Globalny Ban</b>" \
                 "\n#GLOBALNY_BAN" \
                 "\n<b>Status:</b> <code>Egzekwowany</code>" \
                 "\n<b>Sudo administrator:</b> {}" \
                 "\n<b>Futrzak:</b> {}" \
                 "\n<b>ID:</b> <code>{}</code>" \
                 "\n<b>Powód:</b> {}".format(mention_html(banner.id, banner.first_name),
                                              mention_html(user_chat.id, user_chat.first_name), 
                                                           user_chat.id, reason or "Nie podano powodu"), 
                html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("Nie mogę globalnie zbanować z powodu: {}".format(excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "Nie mogę globalnie zbanować z powodu: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, 
                  "{} został pomyślnie globalnie zbanowany!".format(mention_html(user_chat.id, user_chat.first_name)),
                html=True)
    message.reply_text("Futrzak został globalnie zbanowany.")
Exemple #16
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("Gelecek sefer birisini hedef almaya çalış.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text("Sakin ol adamım, böyle bir şey olmayacak.")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text("OOOH Birisi destek kullanıcımı gbanlamaya çalışıyor!")
        return

    if user_id == bot.id:
        message.reply_text("Ölmek mi istiyorsun?")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("Bu bir kullanıcı değil!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text("Bu kullanıcı zaten gbanlı; Sebebini değiştirebilirdim ama, ama bana sebep vermedin...")
            return

        old_reason = sql.update_gban_reason(user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text("Bu kullanıcı zaten aşağıdaki sebepten dolayı gbanlı:\n"
                               "<code>{}</code>\n"
                               "Yeni sebebini güncelledim!".format(html.escape(old_reason)),
                               parse_mode=ParseMode.HTML)
        else:
            message.reply_text("Bu kullanıcı zaten gbanlı, ama daha önce sebebi yoktu. Şimdi gidip ekledim!")

        return

    message.reply_text("Şimdi öldün ! 👉😎👉")

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "<b>Global Ban</b>" \
                 "\n#GBAN" \
                 "\n<b>Durum:</b> <code>Etkin</code>" \
                 "\n<b>Sudo Admin:</b> {}" \
                 "\n<b>Kullanıcı:</b> {}" \
                 "\n<b>ID:</b> <code>{}</code>" \
                 "\n<b>Sebep:</b> {}".format(mention_html(banner.id, banner.first_name),
                                              mention_html(user_chat.id, user_chat.first_name), 
                                                           user_chat.id, reason or "Sebep belirtmedi"), 
                html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("Şu sebepten dolayı gbanlanamadı: {}".format(excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "Şu sebepten dolayı gbanlanamadı: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                   "{} Başarıyla gbanlandı!".format(mention_html(user_chat.id, user_chat.first_name)),
                   html=True)  
    message.reply_text("Kullanıcı yaptıklarıyla \"yüzleşti\".")
Exemple #17
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("You don't seem to be referring to a user.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "aye laudiya dono yana randapa nhi krne ka sudo laudo?")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OOOH someone's trying to gban a support user! *grabs popcorn*")
        return

    if user_id == bot.id:
        message.reply_text(
            "-_- banti ko ban krega apun tere gand me chhata dalega.")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text(
                "iske gand me chhata gus chuka re; I'd change the reason, but you haven't given me one..."
            )
            return

        old_reason = sql.update_gban_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text(
                "This user is already gbanned, for the following reason:\n"
                "<code>{}</code>\n"
                "I've gone and updated it with your new reason!".format(
                    html.escape(old_reason)),
                parse_mode=ParseMode.HTML)
        else:
            message.reply_text(
                "This user is already gbanned, but had no reason set; I've gone and updated it!"
            )

        return

    message.reply_text("*Gya iske gand Me chhtta😈* 👿")

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} is gbanning user {} "
                 "because:\n{}".format(
                     mention_html(banner.id, banner.first_name),
                     mention_html(user_chat.id, user_chat.first_name), reason
                     or "No reason given"),
                 html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("Could not gban due to: {}".format(
                    excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                             "Could not gban due to: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "gban complete!")
    message.reply_text("No Panga with bunty.")
Exemple #18
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("Bir istifadəçi versən gban edə bilərəm.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text("Mən öz balaca gözlərim ilə ağlayıram... sudo istifadəçi müharibəsi! Siz niyə bir-birinizə bunu edirsiniz?")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text("OOOH kimsə Support istifadəçisini gban edir! *popcorn alıb izləyirəm*")
        return

    if user_id == bot.id:
        message.reply_text("-_- Çox əyləncəlidir, gəl özümü gban edim! pf")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("Bu bir istifadəçi deyil!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text("Bu istifadəçi onsuzda gbanlıdır; Səbəbi dəyişərdim, amma bir səbəb verməmisən...")
            return

        old_reason = sql.update_gban_reason(user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text("Bu istifadəçi onsuzda gbanlıdır, reason:\n"
                               "<code>{}</code>\n"
                               "Və mən köhnə səbəbi yenisi ilə əvəz etdim!".format(html.escape(old_reason)),
                               parse_mode=ParseMode.HTML)
        else:
            message.reply_text("Bu istifadəçi onsuzda gbanlıdır, amma bir səbəb verilməyib; Mən səbəbi güncəllədim!")

        return

    message.reply_text("OHA SƏN GBAN ALDIN😳 TƏƏSÜFKİ GBAN VERƏN ŞƏXS SƏNİ BAĞIŞLAMASA MƏNDƏ SƏNİ BAĞIŞLAYA Bİlmərəm🤕")

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "<b>Global Ban</b>" \
                 "\n#GBAN" \
                 "\n<b>Status:</b> <code>Enforcing</code>" \
                 "\n<b>Sudo Admin:</b> {}" \
                 "\n<b>User:</b> {}" \
                 "\n<b>ID:</b> <code>{}</code>" \
                 "\n<b>Səbəb:</b> {}".format(mention_html(banner.id, banner.first_name),
                                              mention_html(user_chat.id, user_chat.first_name), 
                                                           user_chat.id, reason or "Səbəb verilməyib"), 
                html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("Gban etmək mümkün olmadı. Xəta: `{}`".format(excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "Gban etmək mümkün olmadı. Xəta: `{}`".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, 
                  "{} uğurla gban edildi!".format(mention_html(user_chat.id, user_chat.first_name)),
                html=True)
    message.reply_text("İstifadəçi gban edildi.")
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("You don't seem to be referring to a user.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "I spy, with my little eye... a sudo user war! Why are you guys turning on each other?"
        )
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OOOH someone's trying to gban a support user! *grabs popcorn*")
        return

    if int(user_id) in WHITELIST_USERS:
        message.reply_text("Yeah... I'm not gonna gban a whitelisted user.")
        return

    if int(user_id) == bot.id:
        message.reply_text("Nice try but I ain't gonna gban myself!")
        return

    if int(user_id) in (777000, 1087968824):
        message.reply_text("Huh, why would I gban Telegram bots?")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != "private":
        message.reply_text("That's not a user!")
        return

    if user_chat.first_name == "":
        message.reply_text("That's a deleted account, no need to gban them!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text(
                "This user is already gbanned; I'd change the reason, but you haven't given me one..."
            )
            return

        old_reason = sql.update_gban_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            if old_reason == reason:
                message.reply_text(
                    "This user is already gbanned for the exact same reason!")
                return
            else:
                message.reply_text(
                    "This user is already gbanned, for the following reason:\n"
                    "<code>{}</code>\n"
                    "I've gone and updated it with your new reason!".format(
                        html.escape(old_reason)),
                    parse_mode=ParseMode.HTML,
                )
        else:
            message.reply_text(
                "This user is already gbanned, but had no reason set; I've gone and updated it!"
            )

        return

    message.reply_text(
        "Starting a global ban for {}".format(
            mention_html(user_chat.id, user_chat.first_name)),
        parse_mode=ParseMode.HTML,
    )

    banner = update.effective_user  # type: Optional[User]
    send_to_list(
        bot,
        SUDO_USERS,
        "{} is gbanning user {} "
        "because:\n{}".format(
            mention_html(banner.id, banner.first_name),
            mention_html(user_chat.id, user_chat.first_name),
            reason or "No reason given",
        ),
        html=True,
    )

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_user_com_chats(user_id)
    if not chats:
        message.reply_text(
            "No common chats with this user! Will yeet them once I see them though!"
        )
        return
    for chat in chats:
        chat_id = int(chat)

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        gbanned_chats = 0

        try:
            bot.kick_chat_member(chat_id, user_id)
            gbanned_chats += 1
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("Could not gban due to: {}".format(
                    excp.message))
                send_to_list(bot, SUDO_USERS,
                             "Could not gban due to: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS, "Gban complete!")
    if gbanned_chats:
        message.reply_text(
            "Done! {} has been globally banned in <code>{}</code> common chats."
            .format(mention_html(user_chat.id, user_chat.first_name),
                    gbanned_chats),
            parse_mode=ParseMode.HTML,
        )
    else:
        message.reply_text(
            f"Done! {mention_html(user_chat.id, user_chat.first_name)} has been added to the gbans database!",
            parse_mode=ParseMode.HTML,
        )

    try:
        bot.send_message(
            user_id,
            "You've been globally banned from all groups where I am admin. If this is a mistake, you can appeal your ban @PhoenixSupport",
            parse_mode=ParseMode.HTML,
        )
    except BaseException:
        pass  # Bot either blocked or never started by user
Exemple #20
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]
    banner = update.effective_user
    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("You don't seem to be referring to a user.")
        return

    if int(user_id) == OWNER_ID:
        message.reply_text(
            "Well, RiP yourself. He's my owner, and I am never ever gonna stab him, you idiot!!"
        )
        return
    if int(user_id) in SUDO_USERS and banner.id == OWNER_ID:
        message.reply_text(
            "Hey master, I can't gban a sudo user! Please remove him from sudo user list, and try again!"
        )
        return
    if int(user_id) in SUDO_USERS and banner.id != OWNER_ID:
        message.reply_text("F**k off! He is one of my sudo users.")
        return
    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OOOH someone's trying to gban a support user! *grabs popcorn*")
        return
    if user_id == bot.id:
        message.reply_text(" -_-So funny! I won't be globally banning myself")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text(
                "This user is already gbanned; I'd change the reason, but you haven't given me one..."
            )
            return

        old_reason = sql.update_gban_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text(
                "This user is already gbanned, for the following reason:\n"
                "<code>{}</code>\n"
                "I've gone and updated it with your new reason!".format(
                    html.escape(old_reason)),
                parse_mode=ParseMode.HTML)
        else:
            message.reply_text(
                "This user is already gbanned, but had no reason set; I've gone and updated it!"
            )

        return

    message.reply_text("*Blows dust off of banhammer* 😉")
    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} is gbanning user {} "
                 "because:\n{}".format(
                     mention_html(banner.id, banner.first_name),
                     mention_html(user_chat.id, user_chat.first_name), reason
                     or "No reason given"),
                 html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)
    ban_in_all_group(bot, user_id)
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "gban complete!")
    message.reply_text("Person has been Globally banned.")
Exemple #21
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("You don't seem to be referring to a user.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "I spy, with my little eye... a sudo user war! Why are you guys turning on each other?"
        )
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OOOH someone's trying to gban a support user! *grabs popcorn*")
        return

    if user_id == bot.id:
        message.reply_text("Nice try but I ain't gonna gban myself!")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if user_chat.first_name == '':
        message.reply_text("That's a deleted account, no need to gban them!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text(
                "This user is already gbanned; I'd change the reason, but you haven't given me one..."
            )
            return

        old_reason = sql.update_gban_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            if old_reason == reason:
                message.reply_text(
                    "This user is already gbanned for the exact same reason!")
            else:
                message.reply_text(
                    "This user is already gbanned, for the following reason:\n"
                    "<code>{}</code>\n"
                    "I've gone and updated it with your new reason!".format(
                        html.escape(old_reason)),
                    parse_mode=ParseMode.HTML)
        else:
            message.reply_text(
                "This user is already gbanned, but had no reason set; I've gone and updated it!"
            )

        return

    message.reply_text("Starting a global ban for {}".format(
        mention_html(user_chat.id, user_chat.first_name)),
                       parse_mode=ParseMode.HTML)

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot,
                 SUDO_USERS,
                 "{} is gbanning user {} "
                 "because:\n{}".format(
                     mention_html(banner.id, banner.first_name),
                     mention_html(user_chat.id, user_chat.first_name), reason
                     or "No reason given"),
                 html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("Could not gban due to: {}".format(
                    excp.message))
                send_to_list(bot, SUDO_USERS,
                             "Could not gban due to: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS, "Gban complete!")
    message.reply_text("Done! {} has been globally banned.".format(
        mention_html(user_chat.id, user_chat.first_name)),
                       parse_mode=ParseMode.HTML)

    try:
        bot.send_message(
            user_id,
            "You've been globally banned from all groups where I am admin. If this is a mistake, you can appeal your ban @GraveyardDwellers or PM @TheRealPhoenix",
            parse_mode=ParseMode.HTML)
    except:
        pass  #Bot either blocked or never started by user
Exemple #22
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("You don't seem to be referring to a user.")
        return

    if int(user_id) in DEV_USERS:
        message.reply_text("There is no way I can gban my developers")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "I spy, with my little eye... a sudo user war! Why are you guys turning on each other?"
        )
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OOOH someone's trying to gban a support user! *grabs popcorn*")
        return

    if user_id == bot.id:
        message.reply_text("You uhh...want me to punch myself?")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text(
                "This user is already gbanned; I'd change the reason, but you haven't given me one..."
            )
            return

        old_reason = sql.update_gban_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text(
                "This user is already gbanned, for the following reason:\n"
                "<code>{}</code>\n"
                "I've gone and updated it with your new reason!".format(
                    html.escape(old_reason)),
                parse_mode=ParseMode.HTML)
        else:
            message.reply_text(
                "This user is already gbanned, but had no reason set; I've gone and updated it!"
            )

        return

    message.reply_text("Already on it!")

    banner = update.effective_user  # type: Optional[User]
    messagerep = "{} is gbanning user {} "\
                 "because:\n{}".format(mention_html(banner.id, banner.first_name),
                                       mention_html(user_chat.id, user_chat.first_name), reason or "No reason given")
    if GBAN_LOGS:
        bot.send_message(GBAN_LOGS, messagerep, parse_mode=ParseMode.HTML)
    else:
        send_to_list(bot, SUDO_USERS + SUPPORT_USERS, messagerep, html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    gbanned_chats = 0
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
            gbanned_chats += 1
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("Could not gban due to: {}".format(
                    excp.message))
                if GBAN_LOGS:
                    bot.send_message(GBAN_LOGS,
                                     "Could not gban due to {}".format(
                                         excp.message),
                                     parse_mode=ParseMode.HTML)
                else:
                    send_to_list(
                        bot, SUDO_USERS + SUPPORT_USERS,
                        "Could not gban due to: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    if GBAN_LOGS:
        bot.send_message(
            GBAN_LOGS,
            "gban complete! (User banned in {} chats)".format(gbanned_chats),
            parse_mode=ParseMode.HTML)
    else:
        send_to_list(
            bot, SUDO_USERS + SUPPORT_USERS,
            "gban complete! (User banned in {} chats)".format(gbanned_chats))
    message.reply_text(
        "Done - Poof, The user was banned in {} chats".format(gbanned_chats))
    try:
        bot.send_message(
            user_id,
            "You have been globally banned from all groups where I have administrative permissions. If you think that this was a mistake, you may appeal your ban here: @onepunchsupport",
            parse_mode=ParseMode.HTML)
    except:
        pass  # bot probably blocked by user
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("Non ti stai riferendo ad un utente.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "Vi spio.. con i miei piccoli occhi.. una guarra tra sudo user! Perchè state cercando di bannarvi a vicenda?"
        )
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OOOH qualcuno sta cercando di effettuare un gban ad un support user! *grabs popcorn*"
        )
        return

    if user_id == bot.id:
        message.reply_text(
            "-_- Divertente, ora mi auto gban, no? Complimenti.")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != "private":
        message.reply_text("Questo non è un utente!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text(
                "Questo utente è gia in gban. Cambierei il motivo se solo me ne avessi dato uno.."
            )
            return

        old_reason = sql.update_gban_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text(
                "Questo utente è già in gban, per la seguente ragione:\n"
                "<code>{}</code>\n"
                "Ho aggiornato il mio sistema con la nuova motivazione!".
                format(html.escape(old_reason)),
                parse_mode=ParseMode.HTML,
            )
        else:
            message.reply_text(
                "Questo utente è già in gban, ma senza ragione. Ho appena aggiornato i miei sistemi!"
            )

        return

    message.reply_text("*Blows dust off of banhammer* 😉")

    banner = update.effective_user  # type: Optional[User]
    send_to_list(
        bot,
        SUDO_USERS + SUPPORT_USERS,
        "{} sta effettuando un gban all'utente {} "
        "per il seguente motivo:\n{}".format(
            mention_html(banner.id, banner.first_name),
            mention_html(user_chat.id, user_chat.first_name),
            reason or "senza una ragione specifica.",
        ),
        html=True,
    )

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text(
                    "Non posso gbannare per il seguente motivo: {}".format(
                        excp.message))
                send_to_list(
                    bot,
                    SUDO_USERS + SUPPORT_USERS,
                    "Non posso gbannare per il seguente motivo: {}".format(
                        excp.message),
                )
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "gban completato!")
    message.reply_text("Utente gbannato!")
Exemple #24
0
def gban(update, context):
    message = update.effective_message
    chat = update.effective_chat
    args = context.args
    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("You don't seem to be referring to a user.")
        return

    if user_id == OWNER_ID:
        message.reply_text("Nice try -_- but I'm never gonna gban him.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "I spy, with my little eye... a sudo user war! Why are you guys turning on each other?"
        )
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OOOH someone's trying to gban a support user! *grabs popcorn*")
        return

    if user_id == context.bot.id:
        message.reply_text(
            "-_- So funny, lets gban myself why don't I? Nice try.")
        return

    try:
        user_chat = context.bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != "private":
        message.reply_text("That's not a user!")
        return

    if user_chat.first_name == "":
        message.reply_text(
            "This is a deleted account! no point to gban them...")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text(
                "This user is already gbanned; I'd change the reason, but you haven't given me one..."
            )
            return

        old_reason = sql.update_gban_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        user_id, new_reason = extract_user_and_text(message, args)

        if old_reason:
            banner = update.effective_user  # type: Optional[User]
            bannerid = banner.id
            bannername = banner.first_name
            new_reason = (
                f"{new_reason} // GBanned by {bannername} banner id: {bannerid}"
            )

            context.bot.sendMessage(
                MESSAGE_DUMP,
                "<b>Global Ban Reason Update</b>"
                "\n<b>Sudo Admin:</b> {}"
                "\n<b>User:</b> {}"
                "\n<b>ID:</b> <code>{}</code>"
                "\n<b>Previous Reason:</b> {}"
                "\n<b>New Reason:</b> {}".format(
                    mention_html(banner.id, banner.first_name),
                    mention_html(user_chat.id, user_chat.first_name
                                 or "Deleted Account"),
                    user_chat.id,
                    old_reason,
                    new_reason,
                ),
                parse_mode=ParseMode.HTML,
            )

            message.reply_text(
                "This user is already gbanned, for the following reason:\n"
                "<code>{}</code>\n"
                "I've gone and updated it with your new reason!".format(
                    html.escape(old_reason)),
                parse_mode=ParseMode.HTML,
            )

        else:
            message.reply_text(
                "This user is already gbanned, but had no reason set; I've gone and updated it!"
            )

        return

    message.reply_text(
        f"<b>Beginning of Global Ban for</b> {mention_html(user_chat.id, user_chat.first_name)}"
        f"\n<b>With ID</b>: <code>{user_chat.id}</code>"
        f"\n<b>Reason</b>: <code>{reason or 'No reason given'}</code>",
        parse_mode=ParseMode.HTML,
    )

    banner = update.effective_user
    bannerid = banner.id
    bannername = banner.first_name
    reason = f"{reason} // GBanned by {bannername} banner id: {bannerid}"

    context.bot.sendMessage(
        MESSAGE_DUMP,
        "<b>New Global Ban</b>"
        "\n#GBAN"
        "\n<b>Status:</b> <code>Enforcing</code>"
        "\n<b>Sudo Admin:</b> {}"
        "\n<b>User:</b> {}"
        "\n<b>ID:</b> <code>{}</code>"
        "\n<b>Reason:</b> {}".format(
            mention_html(banner.id, banner.first_name),
            mention_html(user_chat.id, user_chat.first_name),
            user_chat.id,
            reason or "No reason given",
        ),
        parse_mode=ParseMode.HTML,
    )

    try:
        context.bot.kick_chat_member(chat.id, user_chat.id)
    except BadRequest as excp:
        if excp.message in GBAN_ERRORS:
            pass

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)
Exemple #25
0
def gban(update: Update, context: CallbackContext):
    bot, args = context.bot, context.args
    message = update.effective_message
    user = update.effective_user
    chat = update.effective_chat
    log_message = ""

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text(
            "You don't seem to be referring to a user or the ID specified is incorrect.."
        )
        return

    if int(user_id) in DEV_USERS:
        message.reply_text(
            "That user is part of the Union\nI can't act against our own.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "I spy, with my little eye... a nation! Why are you guys turning on each other?"
        )
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "OOOH someone's trying to gban a Sakura Nation! *grabs popcorn*")
        return

    if int(user_id) in SARDEGNA_USERS:
        message.reply_text("That's a Sardegna! They cannot be banned!")
        return

    if int(user_id) in WHITELIST_USERS:
        message.reply_text("That's a Neptunia! They cannot be banned!")
        return

    if int(user_id) in (777000, 1087968824):
        message.reply_text("Huh, why would I gban Telegram bots?")
        return

    if user_id == bot.id:
        message.reply_text("You uhh...want me to kill myself?")
        return

    try:
        user_chat = 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:
            return

    if user_chat.type != "private":
        message.reply_text("That's not a user!")
        return

    if sql.is_user_gbanned(user_id):

        if not reason:
            message.reply_text(
                "This user is already gbanned; I'd change the reason, but you haven't given me one..."
            )
            return

        old_reason = sql.update_gban_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text(
                "This user is already gbanned, for the following reason:\n"
                "<code>{}</code>\n"
                "I've gone and updated it with your new reason!".format(
                    html.escape(old_reason)),
                parse_mode=ParseMode.HTML,
            )

        else:
            message.reply_text(
                "This user is already gbanned, but had no reason set; I've gone and updated it!"
            )

        return

    message.reply_text("On it!")

    start_time = time.time()
    datetime_fmt = "%Y-%m-%dT%H:%M"
    current_time = datetime.utcnow().strftime(datetime_fmt)

    if chat.type != "private":
        chat_origin = "<b>{} ({})</b>\n".format(html.escape(chat.title),
                                                chat.id)
    else:
        chat_origin = "<b>{}</b>\n".format(chat.id)

    log_message = (
        f"#GBANNED\n"
        f"<b>Originated from:</b> <code>{chat_origin}</code>\n"
        f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
        f"<b>Banned User:</b> {mention_html(user_chat.id, user_chat.first_name)}\n"
        f"<b>Banned User ID:</b> <code>{user_chat.id}</code>\n"
        f"<b>Event Stamp:</b> <code>{current_time}</code>")

    if reason:
        if chat.type == chat.SUPERGROUP and chat.username:
            log_message += f'\n<b>Reason:</b> <a href="https://telegram.me/{chat.username}/{message.message_id}">{reason}</a>'
        else:
            log_message += f"\n<b>Reason:</b> <code>{reason}</code>"

    if GBAN_LOGS:
        try:
            log = bot.send_message(GBAN_LOGS,
                                   log_message,
                                   parse_mode=ParseMode.HTML)
        except BadRequest as excp:
            log = bot.send_message(
                GBAN_LOGS,
                log_message +
                "\n\nFormatting has been disabled due to an unexpected error.",
            )

    else:
        send_to_list(bot, SUDO_USERS + SUPPORT_USERS, log_message, html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_user_com_chats(user_id)
    gbanned_chats = 0

    for chat in chats:
        chat_id = int(chat)

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
            gbanned_chats += 1

        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text(f"Could not gban due to: {excp.message}")
                if GBAN_LOGS:
                    bot.send_message(
                        GBAN_LOGS,
                        f"Could not gban due to {excp.message}",
                        parse_mode=ParseMode.HTML,
                    )
                else:
                    send_to_list(
                        bot,
                        SUDO_USERS + SUPPORT_USERS,
                        f"Could not gban due to: {excp.message}",
                    )
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    if GBAN_LOGS:
        log.edit_text(
            log_message +
            f"\n<b>Chats affected:</b> <code>{gbanned_chats}</code>",
            parse_mode=ParseMode.HTML,
        )
    else:
        send_to_list(
            bot,
            SUDO_USERS + SUPPORT_USERS,
            f"Gban complete! (User banned in <code>{gbanned_chats}</code> chats)",
            html=True,
        )

    end_time = time.time()
    gban_time = round((end_time - start_time), 2)

    if gban_time > 60:
        gban_time = round((gban_time / 60), 2)
        message.reply_text("Done! Gbanned.", parse_mode=ParseMode.HTML)
    else:
        message.reply_text("Done! Gbanned.", parse_mode=ParseMode.HTML)

    try:
        bot.send_message(
            user_id,
            "#GBAN"
            "You have been marked as Malicious and as such have been banned from any future groups we manage."
            f"\n<b>Reason:</b> <code>{html.escape(user.reason)}</code>"
            f"</b>Appeal Chat:</b> @YorkTownEagleUnion",
            parse_mode=ParseMode.HTML,
        )
    except:
        pass  # bot probably blocked by user
Exemple #26
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("Bir kullanıcıya atıfta bulunmuyorsunuz.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "Küçük gözlerimden kaçmıyor ... bir yönetici savaşı! Neden birbirinizle uğraşıyorsunuz kardeşim?"
        )
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "Haaha birisi bir destek kullanıcısını yasaklamaya çalışıyor! Patlamış mısır kapıp geliyorum"
        )
        return

    if user_id == bot.id:
        message.reply_text(
            "-_- Çok komik, Beni yasaklayacak adam daha anasının karnından doğmadı? İyi deneme."
        )
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("Kullanıcı yok!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text(
                "Bu kullanıcı zaten yasaklanmış; Sebebi yok, sen de bana yenisini söylemedin..."
            )
            return

        old_reason = sql.update_gban_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text("Zaten yasaklanmış, Sebebi de şu:\n"
                               "<code>{}</code>\n"
                               "Gittim ve yeni sebebinle güncelledim!".format(
                                   html.escape(old_reason)),
                               parse_mode=ParseMode.HTML)
        else:
            message.reply_text(
                "Bu kullanıcı zaten yasaklanmış, ancak herhangi bir neden belirlenmemiş; Gittim ve güncelledim!"
            )

        return

    message.reply_text("*Yasak tokmağı kafaya iner* 😉")

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{}, şu kullanıcıyı yasakladı {} "
                 "Çünkü:\n{}".format(
                     mention_html(banner.id, banner.first_name),
                     mention_html(user_chat.id, user_chat.first_name), reason
                     or "No reason given"),
                 html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("{} nedeniyle yasak yapılamadı".format(
                    excp.message))
                send_to_list(
                    bot, SUDO_USERS + SUPPORT_USERS,
                    "{} nedeniyle yasak yapılamadı".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "Yasaklama tamam!")
    message.reply_text("Kişi yasaklandı.")
Exemple #27
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message
    user = update.effective_user
    chat = update.effective_chat
    log_message = ""

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("You don't seem to be referring to a user or the ID specified is incorrect..")
        return

    if int(user_id) in DEV_USERS:
        message.reply_text("That user is part of the Association\nI can't act against our own.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text("I spy, with my little eye... a disaster! Why are you guys turning on each other?")
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text("OOOH someone's trying to gban a Demon Disaster! *grabs popcorn*")
        return

    if int(user_id) in TIGER_USERS:
        message.reply_text("That's a Tiger! They cannot be banned!")
        return

    if int(user_id) in WHITELIST_USERS:
        message.reply_text("That's a Wolf! They cannot be banned!")
        return

    if user_id == bot.id:
        message.reply_text("You uhh...want me to punch myself?")
        return

    try:
        user_chat = 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:
            return

    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if sql.is_user_gbanned(user_id):

        if not reason:
            message.reply_text("This user is already gbanned; I'd change the reason, but you haven't given me one...")
            return

        old_reason = sql.update_gban_reason(user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text("This user is already gbanned, for the following reason:\n"
                               "<code>{}</code>\n"
                               "I've gone and updated it with your new reason!".format(html.escape(old_reason)),
                               parse_mode=ParseMode.HTML)

        else:
            message.reply_text("This user is already gbanned, but had no reason set; I've gone and updated it!")

        return

    message.reply_text("On it!")

    start_time = time.time()
    datetime_fmt = "%H:%M - %d-%m-%Y"
    current_time = datetime.utcnow().strftime(datetime_fmt)

    if chat.type != 'private':
        chat_origin = "<b>{} ({})</b>\n".format(html.escape(chat.title), chat.id)
    else:
        chat_origin = "<b>{}</b>\n".format(chat.id)

    log_message = (f"#GBANNED\n"
                   f"<b>Originated from:</b> {chat_origin}\n"
                   f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
                   f"<b>Banned User:</b> {mention_html(user_chat.id, user_chat.first_name)}\n"
                   f"<b>Banned User ID:</b> {user_chat.id}\n"
                   f"<b>Event Stamp:</b> {current_time}")

    if reason:
        if chat.type == chat.SUPERGROUP and chat.username:
            log_message += f"\n<b>Reason:</b> <a href=\"http://telegram.me/{chat.username}/{message.message_id}\">{reason}</a>"
        else:
            log_message += f"\n<b>Reason:</b> {reason}"

    if GBAN_LOGS:
        try:
            log = bot.send_message(GBAN_LOGS, log_message, parse_mode=ParseMode.HTML)
        except BadRequest as excp:
            log = bot.send_message(GBAN_LOGS,
                                   log_message + "\n\nFormatting has been disabled due to an unexpected error.")

    else:
        send_to_list(bot, SUDO_USERS + SUPPORT_USERS, log_message, html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    gbanned_chats = 0

    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
            gbanned_chats += 1

        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text(f"Could not gban due to: {excp.message}")
                if GBAN_LOGS:
                    bot.send_message(GBAN_LOGS, f"Could not gban due to {excp.message}",
                                     parse_mode=ParseMode.HTML)
                else:
                    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, f"Could not gban due to: {excp.message}")
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    if GBAN_LOGS:
        log.edit_text(log_message + f"\n<b>Chats affected:</b> {gbanned_chats}", parse_mode=ParseMode.HTML)
    else:
        send_to_list(bot, SUDO_USERS + SUPPORT_USERS, f"Gban complete! (User banned in {gbanned_chats} chats)")

    end_time = time.time()
    gban_time = round((end_time - start_time), 2)

    if gban_time > 60:
        gban_time = round((gban_time / 60), 2)
        message.reply_text(f"Done! This gban affected {gbanned_chats} chats, Took {gban_time} min")
    else:
        message.reply_text(f"Done! This gban affected {gbanned_chats} chats, Took {gban_time} sec")

    try:
        bot.send_message(user_id,
                         "You have been globally banned from all groups where I have administrative permissions."
                         f"If you think that this was a mistake, you may appeal your ban here: {SUPPORT_CHAT}",
                         parse_mode=ParseMode.HTML)
    except:
        pass  # bot probably blocked by user
Exemple #28
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("आप किसी यूजर की बात नहीं कर रहे हैं")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "एक अमीर आदमी दूसरे अमीर लड़के को नहीं निकाल सकता, दोनों मेरे के सूडो हैं"
        )
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "क्यों मेरे निर्माताओं को हटाने की कोशिश कर रहे हैं!")
        return

    if user_id == bot.id:
        message.reply_text(
            "-_- इतना मज़ेदार, मैं अपने आप को gban दूं? अच्छा प्रयासI.")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("यह एक यूजर नहीं है!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text(
                "यह यूजर पहले से ही gbanned है; मैं कारण बदल सकता हूं, लेकिन आपने मुझे दिया नहीं..."
            )
            return

        old_reason = sql.update_gban_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if old_reason:
            message.reply_text(
                "यह यूजर पहले से ही gbanned है, कारण:\n"
                "<code>{}</code>\n"
                "मैंने आपके नए कारण से इसे अपडेट किया है!".format(
                    html.escape(old_reason)),
                parse_mode=ParseMode.HTML)
        else:
            message.reply_text(
                "यह यूजर पहले से ही gbanned है; मैंने आपके नए कारण से इसे अपडेट किया है!!"
            )

        return

    message.reply_text("⚡️ *मैंने उसकी पसलियाँ तोड़ दीं* ⚡️")

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "<b>Global Ban</b>" \
                 "\n#GBAN" \
                 "\n<b>Status:</b> <code>Enforcing</code>" \
                 "\n<b>Sudo Admin:</b> {}" \
                 "\n<b>User:</b> {}" \
                 "\n<b>ID:</b> <code>{}</code>" \
                 "\n<b>Reason:</b> {}".format(mention_html(banner.id, banner.first_name),
                                              mention_html(user_chat.id, user_chat.first_name),
                                                           user_chat.id, reason or "No reason given"),
                html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("Could not gban due to: {}".format(
                    excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                             "Could not gban due to: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} Successfully Gbanned!".format(
                     mention_html(user_chat.id, user_chat.first_name)),
                 html=True)
    message.reply_text("सफलतापूर्वक gbanned किया गया.")
Exemple #29
0
def gban(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]

    user_id, reason = extract_user_and_text(message, args)

    if not user_id:
        message.reply_text("You don't seem to be referring to a user.")
        return

    if int(user_id) in SUDO_USERS:
        message.reply_text(
            "അയ്യേ, നിങ്ങളിങ്ങനെ കൊച്ചു കുട്ടികളെപ്പോലെ വഴക്കിടാൻ തുടങ്ങിയാലോ 😐"
        )
        return

    if int(user_id) in SUPPORT_USERS:
        message.reply_text(
            "വേണ്ടപ്പെട്ട ആളാണ്. gban ചെയ്യാനൊന്നും പറ്റില്ല! 😁")
        return

    if user_id == bot.id:
        message.reply_text(
            "-_- So funny, lets gban myself why don't I? Nice try.")
        return

    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return

    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return

    if sql.is_user_gbanned(user_id):
        if not reason:
            message.reply_text(
                "This user is already gbanned; I'd change the reason, but you haven't given me one..."
            )
            return

        success = sql.update_gban_reason(
            user_id, user_chat.username or user_chat.first_name, reason)
        if success:
            message.reply_text(
                "This user is already gbanned; I've gone and updated the gban reason though!"
            )
        else:
            message.reply_text(
                "Do you mind trying again? I thought this person was gbanned, but then they weren't? "
                "Am very confused")

        return

    message.reply_text("*Blows dust off of banhammer* 😉")

    banner = update.effective_user  # type: Optional[User]
    send_to_list(bot,
                 SUDO_USERS + SUPPORT_USERS,
                 "{} is gbanning user {} "
                 "because:\n{}".format(
                     mention_html(banner.id, banner.first_name),
                     mention_html(user_chat.id, user_chat.first_name), reason
                     or "No reason given"),
                 html=True)

    sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

    chats = get_all_chats()
    for chat in chats:
        chat_id = chat.chat_id

        # Check if this group has disabled gbans
        if not sql.does_chat_gban(chat_id):
            continue

        try:
            bot.kick_chat_member(chat_id, user_id)
        except BadRequest as excp:
            if excp.message in GBAN_ERRORS:
                pass
            else:
                message.reply_text("Could not gban due to: {}".format(
                    excp.message))
                send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                             "Could not gban due to: {}".format(excp.message))
                sql.ungban_user(user_id)
                return
        except TelegramError:
            pass

    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "gban complete!")
    message.reply_text("Person has been gbanned.")
Exemple #30
0
def mban(bot, update):
    my_string = update.message.text  # gets the sender text
    user_string = my_string.replace("/mban", "")    # removes command from the string
    mylist = user_string.replace(' ','').split(',') # seperates the string based on , each gets own place
    counter = 0

    for x in mylist:    # goes trough the list, element by element
        user_id = x
        reason = ""
        if not user_id:
            update.message.reply_text("You don't seem to be referring to a user.")
            return

        if int(user_id) in SUDO_USERS:
            update.message.reply_text("I spy, with my little eye... a sudo user war! You supposed to keep this shit together=(")
            return

        if int(user_id) in SUPPORT_USERS:
            update.message.reply_text("OOOH someone's trying to gban a support user, seriously?")
            eturn

        if user_id == bot.id:
            update.message.reply_text("-_- So funny, lets gban myself why don't I? Nice try.")
            return

        try:
            user_chat = bot.get_chat(user_id)
        except BadRequest as excp:
            update.message.reply_text(excp.message)
            return

        if user_chat.type != 'private':
            update.message.reply_text("That's not a user!")
            return

        if sql.is_user_gbanned(user_id):
            if not reason:
                update.message.reply_text("This user is already gbanned; I'd change the reason, but you haven't given me one...")
                return

            success = sql.update_gban_reason(user_id, user_chat.username or user_chat.first_name, reason)
            if success:
                update.message.reply_text("This user is already gbanned; I've gone and updated the gban reason though!")
            else:
                update.message.reply_text("Do you mind trying again? I thought this person was gbanned, but then they weren't? "
                               "Am very confused")
                return
        
        update.message.reply_text("*Blows dust off of banhammer* 😉")
            
        banner = update.effective_user  # type: Optional[User]
        send_to_list(bot, SUDO_USERS + SUPPORT_USERS,
                 "{} is gbanning user {} "
                 "because:\n{}".format(mention_html(banner.id, banner.first_name),
                                       mention_html(user_chat.id, user_chat.first_name), reason or "Nothing to say"),
                 html=True)

        sql.gban_user(user_id, user_chat.username or user_chat.first_name, reason)

        chats = get_all_chats()
        for chat in chats:
            chat_id = chat.chat_id

            # Check if this group has disabled gbans
            if not sql.does_chat_gban(chat_id):
                continue

            try:
                bot.kick_chat_member(chat_id, user_id)
            except BadRequest as excp:
                if excp.message == "User is an administrator of the chat":
                    pass
                elif excp.message == "Chat not found":
                    pass
                elif excp.message == "Not enough rights to restrict/unrestrict chat member":
                    pass
                elif excp.message == "User_not_participant":
                    pass
                elif excp.message == "Peer_id_invalid":  # Suspect this happens when a group is suspended by telegram.
                    pass
                elif excp.message == "Group chat was deactivated":
                    pass
                elif excp.message == "Need to be inviter of a user to kick it from a basic group":
                    pass
                elif excp.message == "Chat_admin_required":
                    pass
                elif excp.message == "Only the creator of a basic group can kick group administrators":
                    pass
                else:
                    update.message.reply_text("Could not gban due to: {}".format(excp.message))
                    send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "Could not gban due to: {}".format(excp.message))
                    sql.ungban_user(user_id)
                    return
            except TelegramError:
                pass

        send_to_list(bot, SUDO_USERS + SUPPORT_USERS, "gban complete!")
        update.message.reply_text("Person has been gbanned.")