Example #1
0
def set_warn_strength(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    msg = update.effective_message  # type: Optional[Message]

    if args:
        if args[0].lower() in ("on", "yes"):
            sql.set_warn_strength(chat.id, False)
            msg.reply_text("Too many warns will now result in a ban!")
            return "<b>{}:</b>\n" \
                   "<b>Admin:</b> {}\n" \
                   "Has enabled strong warns. Users will be banned.".format(html.escape(chat.title),
                                                                            mention_html(user.id, user.first_name))

        elif args[0].lower() in ("off", "no"):
            sql.set_warn_strength(chat.id, True)
            msg.reply_text("Too many warns will now result in a kick! Users will be able to join again after.")
            return "<b>{}:</b>\n" \
                   "<b>Admin:</b> {}\n" \
                   "Has disabled strong warns. Users will only be kicked.".format(html.escape(chat.title),
                                                                                  mention_html(user.id,
                                                                                               user.first_name))

        else:
            msg.reply_text("I only understand on/yes/no/off!")
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)
        if soft_warn:
            msg.reply_text("Warns are currently set to *kick* users when they exceed the limits.",
                           parse_mode=ParseMode.MARKDOWN)
        else:
            msg.reply_text("Warns are currently set to *ban* users when they exceed the limits.",
                           parse_mode=ParseMode.MARKDOWN)
    return ""
Example #2
0
def warns(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user_id = extract_user(message, args) or update.effective_user.id
    result = sql.get_warns(user_id, chat.id)

    if result and result[0] != 0:
        num_warns, reasons = result
        limit, soft_warn = sql.get_warn_setting(chat.id)

        if reasons:
            text = "This user has {}/{} warnings, for the following reasons:".format(
                num_warns, limit)
            for reason in reasons:
                text += "\n - {}".format(reason)

            msgs = split_message(text)
            for msg in msgs:
                update.effective_message.reply_text(msg)
        else:
            update.effective_message.reply_text(
                "User has {}/{} warnings, but no reasons for any of them.".
                format(num_warns, limit))
    else:
        update.effective_message.reply_text(
            "This user hasn't got any warnings!")
Example #3
0
def set_warn_limit(update, context) -> str:
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    msg = update.effective_message  # type: Optional[Message]
    args = context.args
    if args:
        if args[0].isdigit():
            if int(args[0]) < 3:
                msg.reply_text("The minimum warn limit is 3!")
            else:
                sql.set_warn_limit(chat.id, int(args[0]))
                msg.reply_text("Updated the warn limit to {}".format(args[0]))
                return (
                    "<b>{}:</b>"
                    "\n#SET_WARN_LIMIT"
                    "\n<b>Admin:</b> {}"
                    "\nSet the warn limit to <code>{}</code>".format(
                        html.escape(chat.title),
                        mention_html(user.id, user.first_name),
                        args[0],
                    )
                )
        else:
            msg.reply_text("Give me a number as an arg!")
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)

        msg.reply_text("The current warn limit is {}".format(limit))
    return ""
Example #4
0
def warn(user: User, chat: Chat, reason: str, message: Message, warner: User = None) -> str:
    if is_user_admin(chat, user.id):
        message.reply_text("Damn admins, can't even be warned!")
        return ""

    if warner:
        warner_tag = mention_html(warner.id, warner.first_name)
    else:
        warner_tag = "Automated warn filter."

    limit, soft_warn = sql.get_warn_setting(chat.id)
    num_warns, reasons = sql.warn_user(user.id, chat.id, reason)
    if num_warns >= limit:
        sql.reset_warns(user.id, chat.id)
        if soft_warn:  # kick
            chat.unban_member(user.id)
            reply = "{} warnings, this user has been kicked!".format(limit)

        else:  # ban
            chat.kick_member(user.id)
            reply = "{} warnings, this user has been banned!".format(limit)

        message.bot.send_sticker(chat.id, BAN_STICKER)  # banhammer marie sticker
        keyboard = []
        reason = "<b>{}:</b>" \
                 "\n#WARN_BAN" \
                 "\n<b>Admin:</b> {}" \
                 "\n<b>User:</b> {}" \
                 "\n<b>Reason:</b> {}".format(html.escape(chat.title),
                                              warner_tag,
                                              mention_html(user.id, user.first_name),
                                              user.id, reason)

    else:
        keyboard = InlineKeyboardMarkup(
            [[InlineKeyboardButton("Remove warn", callback_data="rm_warn({})".format(user.id))]])

        reply = "{} has {}/{} warnings... watch out!".format(mention_markdown(user.id, user.first_name), num_warns,
                                                             limit)
        if reason:
            reply += "\nReason for last warn:\n{}".format(escape_markdown(reason))

        reason = "<b>{}:</b>" \
                 "\n#WARN" \
                 "\n<b>Admin:</b> {}" \
                 "\n<b>User:</b> {}" \
                 "\n<b>Reason:</b> {}".format(html.escape(chat.title),
                                              warner_tag,
                                              mention_html(user.id, user.first_name), reason)

    try:
        message.reply_text(reply, reply_markup=keyboard, parse_mode=ParseMode.MARKDOWN)
    except BadRequest as excp:
        if excp.message == "Reply message not found":
            # Do not reply
            message.reply_text(reply, reply_markup=keyboard, parse_mode=ParseMode.MARKDOWN, quote=False)
        else:
            raise
    return reason
Example #5
0
def __chat_settings__(chat_id, user_id):
    num_warn_filters = sql.num_warn_chat_filters(chat_id)
    limit, soft_warn = sql.get_warn_setting(chat_id)
    return (
        "This chat has `{}` warn filters. It takes `{}` warns "
        "before the user gets *{}*.".format(
            num_warn_filters, limit, "kicked" if soft_warn else "banned"
        )
    )
Example #6
0
def __chat_settings__(chat_id, user_id):
    num_warn_filters = sql.num_warn_chat_filters(chat_id)
    limit, soft_warn = sql.get_warn_setting(chat_id)
    return (
        "Questa chat ha `{}` filtri di ammonimento. Ci vogliono `{}` ammonimenti "
        "prima che l'utente venga *{}*.".format(
            num_warn_filters, limit, "cacciato" if soft_warn else "bandito"
        )
    )
Example #7
0
def set_warn_strength(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    msg = update.effective_message  # type: Optional[Message]

    if args:
        if args[0].lower() in ("on", "yes"):
            sql.set_warn_strength(chat.id, False)
            msg.reply_text(
                "Troppi ammonimenti comporteranno l'espulsione permanente (ban)."
            )
            return (
                "<b>{}:</b>\n"
                "<b>Admin:</b> {}\n"
                "Ha abilitato gli ammonimenti rigidi. Gli utenti saranno banditi.".format(
                    html.escape(chat.title), mention_html(user.id, user.first_name)
                )
            )

        elif args[0].lower() in ("off", "no"):
            sql.set_warn_strength(chat.id, True)
            msg.reply_text(
                "Troppi ammonimenti comporteranno l'uscita forzata. Gli utenti potranno unirsi nuovamente."
            )
            return (
                "<b>{}:</b>\n"
                "<b>Admin:</b> {}\n"
                "Ha disabilitato gli ammonimenti rigidi. Gli utenti saranno solo momentaneamente rimossi.".format(
                    html.escape(chat.title), mention_html(user.id, user.first_name)
                )
            )

        else:
            msg.reply_text("Capisco solo on/yes/no/off!")
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)
        if soft_warn:
            msg.reply_text(
                "Gli ammonimenti sono impostati per *rimuovere* (kick) gli utenti quando superano il limite.",
                parse_mode=ParseMode.MARKDOWN,
            )
        else:
            msg.reply_text(
                "Gli ammonimenti sono impostati per *bandire* (ban) gli utenti quando superano il limite.",
                parse_mode=ParseMode.MARKDOWN,
            )
    return ""
Example #8
0
def set_warn_strength(bot: Bot, update: Update, args: List[str]):
    chat: Optional[Chat] = update.effective_chat
    user: Optional[User] = update.effective_user
    msg: Optional[Message] = update.effective_message

    if args:
        if args[0].lower() in ("on", "yes"):
            sql.set_warn_strength(chat.id, False)
            msg.reply_text(
                "Terlalu banyak peringatan sekarang akan mengakibatkan Ban!")
            return (
                f"<b>{html.escape(chat.title)}:</b>\n"
                f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
                f"Telah mengaktifkan peringatan yang kuat. Pengguna akan saya tendang keluar.(banned)"
            )

        elif args[0].lower() in ("off", "no"):
            sql.set_warn_strength(chat.id, True)
            msg.reply_text(
                "TTelah mengaktifkan peringatan yang kuat. Pengguna akan ditendang dengan serius"
            )
            return (
                f"<b>{html.escape(chat.title)}:</b>\n"
                f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
                f"Telah menonaktifkan. Saya akan menendang bokong pada pengguna."
            )

        else:
            msg.reply_text("Saya hanya mengert on/yes/no/off!")
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)
        if soft_warn:
            msg.reply_text(
                "Peringatan saat ini disetel untuk *ditendang* pengguna saat mereka melebihi batas.",
                parse_mode=ParseMode.MARKDOWN,
            )
        else:
            msg.reply_text(
                "Peringatan saat ini disetel ke *DiCekal* pengguna saat mereka melebihi batas.",
                parse_mode=ParseMode.MARKDOWN,
            )
    return ""
Example #9
0
def set_warn_strength(update: Update, context: CallbackContext):
    args = context.args
    chat: Optional[Chat] = update.effective_chat
    user: Optional[User] = update.effective_user
    msg: Optional[Message] = update.effective_message

    if args:
        if args[0].lower() in ("on", "yes"):
            sql.set_warn_strength(chat.id, False)
            msg.reply_text("Too many warns will now result in a Ban!")
            return (
                f"<b>{html.escape(chat.title)}:</b>\n"
                f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
                f"Has enabled strong warns. Users will be banned"
            )

        elif args[0].lower() in ("off", "no"):
            sql.set_warn_strength(chat.id, True)
            msg.reply_text(
                "Too many warns will now result in a kick! Users will be able to join again after."
            )
            return (
                f"<b>{html.escape(chat.title)}:</b>\n"
                f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
                f"Has disabled bans. I will just kick users."
            )

        else:
            msg.reply_text("I only understand on/yes/no/off!")
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)
        if soft_warn:
            msg.reply_text(
                "Warns are currently set to *kick* users when they exceed the limits.",
                parse_mode=ParseMode.MARKDOWN,
            )
        else:
            msg.reply_text(
                "Warns are currently set to *Ban* users when they exceed the limits.",
                parse_mode=ParseMode.MARKDOWN,
            )
    return ""
Example #10
0
def set_warn_strength(bot: Bot, update: Update, args: List[str]):
    chat: Optional[Chat] = update.effective_chat
    user: Optional[User] = update.effective_user
    msg: Optional[Message] = update.effective_message

    if args:
        if args[0].lower() in ("on", "yes"):
            sql.set_warn_strength(chat.id, False)
            msg.reply_text("Too many warns will now result in a Ban!")
            return (
                f"<b>{html.escape(chat.title)}:</b>\n"
                f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
                f"Has enabled strong warns. Users will be seriously punched.(banned)"
            )

        elif args[0].lower() in ("off", "no"):
            sql.set_warn_strength(chat.id, True)
            msg.reply_text(
                "Too many warns will now result in a normal punch! Users will be able to join again after."
            )
            return (
                f"<b>{html.escape(chat.title)}:</b>\n"
                f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
                f"Has disabled strong punches. I will use normal punch on users."
            )

        else:
            msg.reply_text("I only understand on/yes/no/off!")
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)
        if soft_warn:
            msg.reply_text(
                "Warns are currently set to *punch* users when they exceed the limits.",
                parse_mode=ParseMode.MARKDOWN,
            )
        else:
            msg.reply_text(
                "Warns are currently set to *Ban* users when they exceed the limits.",
                parse_mode=ParseMode.MARKDOWN,
            )
    return ""
Example #11
0
def set_warn_strength(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    msg = update.effective_message  # type: Optional[Message]

    if args:
        if args[0].lower() in ("روشن", "on"):
            sql.set_warn_strength(chat.id, False)
            msg.reply_text(
                "وقتی اخطار ها زیاد بشن . مقصر هاشون از گروه بن میشن!")
            return "<b>{}:</b>\n" \
                   "<b>توسط:</b> {}\n" \
                   "حالت بیرحمی روشن شد! کاربرهای مقصر از گپ بن خواهند شد".format(html.escape(chat.title),
                                                                            mention_html(user.id, user.first_name))

        elif args[0].lower() in ("خاموش", "off"):
            sql.set_warn_strength(chat.id, True)
            msg.reply_text(
                "وقتی اخطار هاشون زیاد بشه ، از گپ کیک میشن! ولی باز میتونن اگه بخوان به گروه برگردن."
            )
            return "<b>{}:</b>\n" \
                   "<b>توسط:</b> {}\n" \
                   "حالت بیرحمی خاموش شد! کاربرهای مقصر فقط اخراج خواهند شد".format(html.escape(chat.title),
                                                                                  mention_html(user.id,
                                                                                               user.first_name))

        else:
            msg.reply_text(
                "توی حالت بیرحمی فقط میتونی به من دستورات on/روشن یا off/خاموش رو بدی😶"
            )
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)
        if soft_warn:
            msg.reply_text(
                "من بیرحم نیستم! اخطارهای شخصی به حدش برسه فقط اخراج میشه😊",
                parse_mode=ParseMode.MARKDOWN)
        else:
            msg.reply_text("من بیرحمم ! اخطار های شخصی به حدش برسه بنش میکنم😡",
                           parse_mode=ParseMode.MARKDOWN)
    return ""
Example #12
0
def set_warn_strength(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    msg = update.effective_message  # type: Optional[Message]

    if args:
        if args[0].lower() in ("ac", "evet"):
            sql.set_warn_strength(chat.id, False)
            msg.reply_text(
                "Çok fazla uyarı, artık gruptan atılıp yasaklanma ile sonuçlanacak!"
            )
            return "<b>{}:</b>\n" \
                   "<b>Admin:</b> {}\n" \
                   "Sert uyarı ayarlandı. Kullanıcılar kovulup yasaklanacak.".format(html.escape(chat.title),
                                                                            mention_html(user.id, user.first_name))

        elif args[0].lower() in ("kapat", "hayir"):
            sql.set_warn_strength(chat.id, True)
            msg.reply_text(
                "Artık çok fazla uyarı gruptan atılma ile sonuçlanacak! Kullanıcılar daha sonra tekrar gruba katılabilecekler."
            )
            return "<b>{}:</b>\n" \
                   "<b>Admin:</b> {}\n" \
                   "Güçlü uyarı ayarlandı. Kullanıcılar atılacak".format(html.escape(chat.title),
                                                                                  mention_html(user.id,
                                                                                               user.first_name))

        else:
            msg.reply_text("Sadece evet/hayir/ac/kapat demenden anlıyorum!")
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)
        if soft_warn:
            msg.reply_text("Şuan uyarılan kullanıcılar gruptan atılacaktır.",
                           parse_mode=ParseMode.MARKDOWN)
        else:
            msg.reply_text(
                "Şuan uyarılan kullanıcılar gruptan atılacak, bir daha girmesi yasaklanacaktır.",
                parse_mode=ParseMode.MARKDOWN)
    return ""
Example #13
0
def set_warn_strength(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    msg = update.effective_message  # type: Optional[Message]

    if args:
        if args[0].lower() in ("on", "yes"):
            sql.set_warn_strength(chat.id, False)
            msg.reply_text(
                "وقتی اخطار ها زیاد بشن . مقصر هاشون از گروه بن میشن!")
            return "<b>{}:</b>\n" \
                   "<b>Admin:</b> {}\n" \
                   "Has enabled strong warns. Users will be banned.".format(html.escape(chat.title),
                                                                            mention_html(user.id, user.first_name))

        elif args[0].lower() in ("off", "no"):
            sql.set_warn_strength(chat.id, True)
            msg.reply_text(
                "وقتی اخطار هاشون زیاد بشه ، از گپ کیک میشن! ولی باز میتونن اگه بخوان به گروه برگردن."
            )
            return "<b>{}:</b>\n" \
                   "<b>Admin:</b> {}\n" \
                   "Has disabled strong warns. Users will only be kicked.".format(html.escape(chat.title),
                                                                                  mention_html(user.id,
                                                                                               user.first_name))

        else:
            msg.reply_text("من فقط دستورات  on/yes/no/off رو میفهمم!")
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)
        if soft_warn:
            msg.reply_text(
                "حالت سخت گیرانه خاموشه، کسایی که خیلی اخطار بگیرن فقط اخراج میشن.",
                parse_mode=ParseMode.MARKDOWN)
        else:
            msg.reply_text(
                "حالت سختگیرانه خاموشه ، کسایی که خیلی اخطار بگیرن اخراج و بن میشن.",
                parse_mode=ParseMode.MARKDOWN)
    return ""
Example #14
0
def warns(bot: Bot, update: Update, args: List[str]):
    message: Optional[Message] = update.effective_message
    chat: Optional[Chat] = update.effective_chat
    user_id = extract_user(message, args) or update.effective_user.id
    result = sql.get_warns(user_id, chat.id)

    if result and result[0] != 0:
        num_warns, reasons = result
        limit, soft_warn = sql.get_warn_setting(chat.id)

        if reasons:
            text = f"This user has {num_warns}/{limit} warns, for the following reasons:"
            for reason in reasons:
                text += f"\n - {reason}"

            msgs = split_message(text)
            for msg in msgs:
                update.effective_message.reply_text(msg)
        else:
            update.effective_message.reply_text(f"User has {num_warns}/{limit} warns, but no reasons for any of them.")
    else:
        update.effective_message.reply_text("This user doesn't have any warns!")
Example #15
0
def set_warn_strength(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    msg = update.effective_message  # type: Optional[Message]

    if args:
        if args[0].lower() in ("on", "yes"):
            sql.set_warn_strength(chat.id, False)
            msg.reply_text("Artık çok fazla uyarı yasaklanacak!")
            return "<b>{}:</b>\n" \
                   "<b>Admin:</b> {}\n" \
                   "Güçlü uyarılar sağlamıştır. Kullanıcılar yasaklanacak.".format(html.escape(chat.title),
                                                                            mention_html(user.id, user.first_name))

        elif args[0].lower() in ("off", "no"):
            sql.set_warn_strength(chat.id, True)
            msg.reply_text(
                "Too many warns will now result in a kick! Users will be able to join again after."
            )
            return "<b>{}:</b>\n" \
                   "<b>Admin:</b> {}\n" \
                   "Güçlü uyarılar devre dışı bıraktı. Kullanıcılar sadece tekmelenecek.".format(html.escape(chat.title),
                                                                                  mention_html(user.id,
                                                                                               user.first_name))

        else:
            msg.reply_text("anlamadım bunlardan birini kullan on/yes/no/off!")
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)
        if soft_warn:
            msg.reply_text(
                "Uyarılar şu anda kullanıcıları sınırlarını aştıklarında * tekme * olarak ayarlanmış.",
                parse_mode=ParseMode.MARKDOWN)
        else:
            msg.reply_text(
                "Uyarıları şu anda kullanıcıları sınırları aştıklarında * yasaklama * olarak ayarladınız.",
                parse_mode=ParseMode.MARKDOWN)
    return ""
Example #16
0
def set_warn_strength(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    msg = update.effective_message  # type: Optional[Message]

    if args:
        if args[0].lower() in ("on", "yes"):
            sql.set_warn_strength(chat.id, False)
            msg.reply_text("Çok fazla uyarı, artık yasakla sonuçlanacak!")
            return "<b>{}:</b>\n" \
                   "<b>Admin:</b> {}\n" \
                   "Has enabled strong warns. Users will be banned.".format(html.escape(chat.title),
                                                                            mention_html(user.id, user.first_name))

        elif args[0].lower() in ("off", "no"):
            sql.set_warn_strength(chat.id, True)
            msg.reply_text(
                "Çok fazla uyarı artık gruptan atılma ile sonuçlanacak! Kullanıcılar sonra tekrar katılabilecektir."
            )
            return "<b>{}:</b>\n" \
                   "<b>Admin:</b> {}\n" \
                   "Has disabled strong warns. Users will only be kicked.".format(html.escape(chat.title),
                                                                                  mention_html(user.id,
                                                                                               user.first_name))

        else:
            msg.reply_text("ben sadece on/yes/no/off komutlarını anlıyorum!")
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)
        if soft_warn:
            msg.reply_text(
                "Uyarılar şu anda limitleri aştığında *gruptan at* olarak ayarlandı.",
                parse_mode=ParseMode.MARKDOWN)
        else:
            msg.reply_text(
                "Uyarılar şu anda limitleri aştığında *gruptan yasakla* olarak ayarlandı.",
                parse_mode=ParseMode.MARKDOWN)
    return ""
Example #17
0
def set_warn_strength(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    msg = update.effective_message  # type: Optional[Message]

    if args:
        if args[0].lower() in ("on", "yes"):
            sql.set_warn_strength(chat.id, False)
            msg.reply_text("الكثير من التحذر سيؤدي الآن إلى حظر!")
            return "<b>{}:</b>\n" \
                   "<b>Admin:</b> {}\n" \
                   "وقد مكن تحذيرات قوية. سيتم حظر المستخدمين.".format(html.escape(chat.title),
                                                                            mention_html(user.id, user.first_name))

        elif args[0].lower() in ("off", "no"):
            sql.set_warn_strength(chat.id, True)
            msg.reply_text(
                "الكثير من التحذر سيؤدي الآن إلى ركلة! سيتمكن المستخدمون من الانضمام مرة أخرى بعد."
            )
            return "<b>{}:</b>\n" \
                   "<b>Admin:</b> {}\n" \
                   "قد تعطيل تحذيرات قوية. سيتم ركل المستخدمين فقط.".format(html.escape(chat.title),
                                                                                  mention_html(user.id,
                                                                                               user.first_name))

        else:
            msg.reply_text("أنا أفهم فقط on/yes/no/off!")
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)
        if soft_warn:
            msg.reply_text(
                "تحذر حاليا على * ركلة * للمستخدمين عندما تتجاوز الحدود.",
                parse_mode=ParseMode.MARKDOWN)
        else:
            msg.reply_text(
                "تحذر حاليا من إعداد * المستخدمين * على المستخدمين عندما تتجاوز الحدود.",
                parse_mode=ParseMode.MARKDOWN)
    return ""
Example #18
0
def set_warn_strength(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    msg = update.effective_message  # type: Optional[Message]

    if args:
        if args[0].lower() in ("on", "yes"):
            sql.set_warn_strength(chat.id, False)
            msg.reply_text("අනතුරු ඇඟවීම් ඕනෑවට වඩා දැන් තහනමක් වනු ඇත!")
            return "<b>{}:</b>\n" \
                   "<b>Admin:</b> {}\n" \
                   "දැඩි අනතුරු ඇඟවීම් සක්‍රීය කර ඇත. පරිශීලකයින් තහනම් කරනු ලැබේ.".format(html.escape(chat.title),
                                                                            mention_html(user.id, user.first_name))

        elif args[0].lower() in ("off", "no"):
            sql.set_warn_strength(chat.id, True)
            msg.reply_text(
                "අනතුරු ඇඟවීම් ඕනෑවට වඩා දැන් පයින් ගසනු ඇත! පරිශීලකයින්ට පසුව නැවත සම්බන්ධ වීමට හැකි වනු ඇත."
            )
            return "<b>{}:</b>\n" \
                   "<b>Admin:</b> {}\n" \
                   "දැඩි අනතුරු ඇඟවීම් අක්‍රීය කර ඇත. පරිශීලකයින්ට පයින් ගසනු ලැබේ.".format(html.escape(chat.title),
                                                                                  mention_html(user.id,
                                                                                               user.first_name))

        else:
            msg.reply_text("I only understand on/yes/no/off!")
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)
        if soft_warn:
            msg.reply_text(
                "Warns are currently set to *kick* users when they exceed the limits.",
                parse_mode=ParseMode.MARKDOWN)
        else:
            msg.reply_text(
                "Warns are currently set to *ban* users when they exceed the limits.",
                parse_mode=ParseMode.MARKDOWN)
    return ""
Example #19
0
def set_warn_strength(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    msg = update.effective_message  # type: Optional[Message]

    if args:
        if args[0].lower() in ("on", "yes"):
            sql.set_warn_strength(chat.id, False)
            msg.reply_text("Muitos warns resultarão em banimento!")
            return "<b>{}:</b>\n" \
                   "<b>Admin:</b> {}\n" \
                   "Ativou warns fortes. Usuários serão banidos.".format(html.escape(chat.title),
                                                                            mention_html(user.id, user.first_name))

        elif args[0].lower() in ("off", "no"):
            sql.set_warn_strength(chat.id, True)
            msg.reply_text(
                "Muitos warns agora resultarão em kick! Usuários poderão entrar novamente depois."
            )
            return "<b>{}:</b>\n" \
                   "<b>Admin:</b> {}\n" \
                   "Has disabled strong warns. Users will only be kicked.".format(html.escape(chat.title),
                                                                                  mention_html(user.id,
                                                                                               user.first_name))

        else:
            msg.reply_text("Eu só entendo on/yes/no/off!")
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)
        if soft_warn:
            msg.reply_text(
                "Warns estão definidos para *kickar* usuários quando eles passam dos limites.",
                parse_mode=ParseMode.MARKDOWN)
        else:
            msg.reply_text(
                "Warns estão definidos para *banir* usuários quando eles passam dos limites.",
                parse_mode=ParseMode.MARKDOWN)
    return ""
Example #20
0
def warns(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user_id = extract_user(message, args) or update.effective_user.id
    result = sql.get_warns(user_id, chat.id)

    if result and result[0] != 0:
        num_warns, reasons = result
        limit, soft_warn = sql.get_warn_setting(chat.id)

        if reasons:
            text = "이 사용자의 경고 횟수는 {}/{} 예요. 이유:".format(num_warns, limit)
            for reason in reasons:
                text += "\n - {}".format(reason)

            msgs = split_message(text)
            for msg in msgs:
                update.effective_message.reply_text(msg)
        else:
            update.effective_message.reply_text(
                "이 사용자의 경고 횟수는 {}/{} 예요. 하지만 아무 이유가 없네요.".format(num_warns, limit))
    else:
        update.effective_message.reply_text("이 사용자에게 경고가 없어요!")
Example #21
0
def warns(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user_id = extract_user(message, args) or update.effective_user.id
    result = sql.get_warns(user_id, chat.id)

    if result and result[0] != 0:
        num_warns, reasons = result
        limit, soft_warn = sql.get_warn_setting(chat.id)

        if reasons:
            text = "Questo utente ha {}/{} ammonimenti, per le seguenti ragioni:".format(num_warns, limit)
            for reason in reasons:
                text += "\n - {}".format(reason)

            msgs = split_message(text)
            for msg in msgs:
                update.effective_message.reply_text(msg)
        else:
            update.effective_message.reply_text(
                "Questo utente ha {}/{} ammonimenti ma per nessuno di essi è indicata una ragione.".format(num_warns, limit))
    else:
        update.effective_message.reply_text("Questo utente non ha ricevuto alcun ammonimento!")
Example #22
0
def warns(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user_id = extract_user(message, args) or update.effective_user.id
    result = sql.get_warns(user_id, chat.id)

    if result and result[0] != 0:
        num_warns, reasons = result
        limit, soft_warn = sql.get_warn_setting(chat.id)

        if reasons:
            text = "Bu Kullanıcının Aşağıdaki Nedenlerden Dolayı {}/{} Uyarısı Var:".format(num_warns, limit)
            for reason in reasons:
                text += "\n - {}".format(reason)

            msgs = split_message(text)
            for msg in msgs:
                update.effective_message.reply_text(msg)
        else:
            update.effective_message.reply_text(
                "Kullanıcının {}/{} Uyarısı Var, Ancak Bunların Hiçbirinin Nedeni Yok.".format(num_warns, limit))
    else:
        update.effective_message.reply_text("Bu Kullanıcının Herhangi Bir Uyarısı Yok!")
Example #23
0
def warns(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user_id = extract_user(message, args) or update.effective_user.id
    result = sql.get_warns(user_id, chat.id)

    if result and result[0] != 0:
        num_warns, reasons = result
        limit, soft_warn = sql.get_warn_setting(chat.id)

        if reasons:
            text = "Ten futrzak posiada {}/{} otrzeżeń z następujących powodów:".format(num_warns, limit)
            for reason in reasons:
                text += "\n - {}".format(reason)

            msgs = split_message(text)
            for msg in msgs:
                update.effective_message.reply_text(msg)
        else:
            update.effective_message.reply_text(
                "Ten futrzak posiada {}/{} otrzeżen, ale nie ma podanego powodu dla żadnego z nich.".format(num_warns, limit))
    else:
        update.effective_message.reply_text("Ten futrzak nie ma żadnych ostrzeżeń!")
Example #24
0
def set_warn_limit(bot: Bot, update: Update, args: List[str]) -> str:
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    message = update.effective_message  # type: Optional[Message]

    if args:
        if args[0].isdigit():
            if int(args[0]) < 3:
                message.reply_text("The minimum warn limit is 3!")
            else:
                sql.set_warn_limit(chat.id, int(args[0]))
                message.reply_text(f"Updated the warn limit to {args[0]}")
                return f"<b>{html.escape(chat.title)}:</b>" \
                       f"\n#SET_WARN_LIMIT" \
                       f"\n<b>Admin:</b> {mention_html(user.id, user.first_name)}" \
                       f"\nSet the warn limit to <code>{args[0]}</code>"
        else:
            message.reply_text("Give me a number as an argument!")
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)

        message.reply_text(f"The current warn limit is {limit}")
    return ""
Example #25
0
def warns(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user_id = extract_user(message, args) or update.effective_user.id
    result = sql.get_warns(user_id, chat.id)

    if result and result[0] != 0:
        num_warns, reasons = result
        limit, soft_warn = sql.get_warn_setting(chat.id)

        if reasons:
            text = "ഇയാൾക്ക് {}/{} warnings ഉണ്ട്, കാരണങ്ങൾ താഴെ പറയുന്നു:".format(num_warns, limit)
            for reason in reasons:
                text += "\n - {}".format(reason)

            msgs = split_message(text)
            for msg in msgs:
                update.effective_message.reply_text(msg)
        else:
            update.effective_message.reply_text(
                "ഇയാൾക്ക് {}/{} warnings ഉണ്ട്, കാരണം ലഭ്യമല്ല.".format(num_warns, limit))
    else:
        update.effective_message.reply_text("ഇയാൾക്ക് warnings ഒന്നും കിട്ടിയിട്ടില്ല!")
Example #26
0
def warns(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user_id = extract_user(message, args) or update.effective_user.id
    result = sql.get_warns(user_id, chat.id)

    P = 1

    if result and result[0] != 0:
        num_warns, reasons = result
        limit, soft_warn = sql.get_warn_setting(chat.id)

        text = "This user has {}/{} warnings, for the following reasons:".format(num_warns, limit)
        for reason in reasons:
            text += "\n {}. `{}`".format(P, reason)
            P = P + 1

        msgs = split_message(text)
        for msg in msgs:
            update.effective_message.reply_text(msg, parse_mode=ParseMode.MARKDOWN)

    else:
        update.effective_message.reply_text("This user hasn't got any warnings!")
Example #27
0
def warns(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user_id = extract_user(message, args) or update.effective_user.id
    result = sql.get_warns(user_id, chat.id)

    if result and result[0] != 0:
        num_warns, reasons = result
        limit, soft_warn = sql.get_warn_setting(chat.id)

        if reasons:
            text = "Pengguna ini memiliki {}/3 SP, dengan daftar pelanggaran:".format(num_warns)
            for reason in reasons:
                text += "\n - {}".format(reason)

            msgs = split_message(text)
            for msg in msgs:
                update.effective_message.reply_text(msg)
        else:
            update.effective_message.reply_text(
                "Pengguna ini memiliki {}/3 SP".format(num_warns))
    else:
        update.effective_message.reply_text("Pengguna ini tidak memiliki SP")
Example #28
0
def warns(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user_id = extract_user(message, args) or update.effective_user.id
    result = sql.get_warns(user_id, chat.id)

    if result and result[0] != 0:
        num_warns, reasons = result
        limit, soft_warn = sql.get_warn_setting(chat.id)

        if reasons:
            text = "ഈ ഉപഭോക്താവിന്  {}/{} താക്കീതുകൾ ഉണ്ട് , ഇതാണ് അതിന്റെ കാരണങ്ങൾ:".format(num_warns, limit)
            for reason in reasons:
                text += "\n - {}".format(reason)

            msgs = split_message(text)
            for msg in msgs:
                update.effective_message.reply_text(msg)
        else:
            update.effective_message.reply_text(
                "ഉപഭോക്താവിന് {}/{} താക്കീതുകൾ ഉണ്ട് പക്ഷെ ഒന്നിനും കാരണം രേഖപ്പെടുത്തിയിട്ടില്ല .".format(num_warns, limit))
    else:
        update.effective_message.reply_text("ഇദ്ദേഹത്തിന് ഇതുവരെ താക്കീതുകൾ ഒന്നും ലഭിച്ചിട്ടില്ല!")
Example #29
0
def set_warn_limit(bot: Bot, update: Update, args: List[str]) -> str:
    chat: Optional[Chat] = update.effective_chat
    user: Optional[User] = update.effective_user
    msg: Optional[Message] = update.effective_message

    if args:
        if args[0].isdigit():
            if int(args[0]) < 3:
                msg.reply_text("The minimum warn limit is 3!")
            else:
                sql.set_warn_limit(chat.id, int(args[0]))
                msg.reply_text("Updated the warn limit to {}".format(args[0]))
                return (f"<b>{html.escape(chat.title)}:</b>\n"
                        f"#SET_WARN_LIMIT\n"
                        f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
                        f"Set the warn limit to <code>{args[0]}</code>")
        else:
            msg.reply_text("Give me a number as an arg!")
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)

        msg.reply_text("The current warn limit is {}".format(limit))
    return ""
Example #30
0
def warns(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user_id = extract_user(message, args) or update.effective_user.id
    result = sql.get_warns(user_id, chat.id)

    if result and result[0] != 0:
        num_warns, reasons = result
        limit, soft_warn = sql.get_warn_setting(chat.id)

        if reasons:
            text = "İstifadəçinin {}/{} xəbərdarlığı var səbəblər:".format(num_warns, limit)
            for reason in reasons:
                text += "\n - {}".format(reason)

            msgs = split_message(text)
            for msg in msgs:
                update.effective_message.reply_text(msg)
        else:
            update.effective_message.reply_text(
                "İstifadəçinin {}/{} xəbərdarlığı var, lakin heç bir səbəb qeyd olunmayıb.".format(num_warns, limit))
    else:
        update.effective_message.reply_text("Bu istifadəçinin heç bir xəbərdarlığı yoxdur!")