예제 #1
0
def remove_warns(update: Update, context: CallbackContext) -> str:
    if not check_perms(update, 1):
        return
    bot, args = context.bot, context.args
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]

    user_id = extract_user(message, args)

    if user_id:
        sql.remove_warn(user_id, chat.id)
        message.reply_text("Last warn has been removed!")
        warned = chat.get_member(user_id).user
        return ("<b>{}:</b>"
                "\n#UNWARN"
                "\n<b>• Admin:</b> {}"
                "\n<b>• User:</b> {}"
                "\n<b>• ID:</b> <code>{}</code>".format(
                    html.escape(chat.title),
                    mention_html(user.id, user.first_name),
                    mention_html(warned.id, warned.first_name),
                    warned.id,
                ))
    message.reply_text("No user has been designated!")
    return ""
예제 #2
0
파일: warns.py 프로젝트: freak1151/tgbot-1
def button(bot: Bot, update: Update) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        if not is_user_admin(chat, int(user.id)):
            query.answer(
                text=
                "You are not authorized to remove this warn! Only administrators may remove warns.",
                show_alert=True)
            return ""
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text("Warn removed by {}.".format(
                mention_html(user.id, user.first_name)),
                                               parse_mode=ParseMode.HTML)
            user_member = chat.get_member(user_id)
            return "<b>{}:</b>" \
                   "\n#UNWARN" \
                   "\n<b>Admin:</b> {}" \
                   "\n<b>User:</b> {}".format(html.escape(chat.title),
                                              mention_html(user.id, user.first_name),
                                              mention_html(user_member.user.id, user_member.user.first_name))
        else:
            update.effective_message.edit_text(
                "User has already has no warns.".format(
                    mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)

    return ""
예제 #3
0
def button(update: Update, context: CallbackContext) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text("{} 님에 의해 경고가 제거되었어요.".format(
                mention_html(user.id, user.first_name)),
                                               parse_mode=ParseMode.HTML)
            user_member = chat.get_member(user_id)
            return "<b>{}:</b>" \
                   "\n#경고_해제" \
                   "\n<b>관리자:</b> {}" \
                   "\n<b>사용자:</b> {} (<code>{}</code>)".format(html.escape(chat.title),
                                                                mention_html(user.id, user.first_name),
                                                                mention_html(user_member.user.id, user_member.user.first_name),
                                                                user_member.user.id)
        else:
            update.effective_message.edit_text("해당 사용자는 이미 경고가 없어요.".format(
                mention_html(user.id, user.first_name)),
                                               parse_mode=ParseMode.HTML)

    return ""
예제 #4
0
def button(bot: Bot, update: Update) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text("{} द्वारा हटा दिया गया".format(
                mention_html(user.id, user.first_name)),
                                               parse_mode=ParseMode.HTML)
            user_member = chat.get_member(user_id)
            return "<b>{}:</b>" \
                   "\n#UNWARN" \
                   "\n<b>Admin:</b> {}" \
                   "\n<b>User:</b> {}".format(html.escape(chat.title),
                                              mention_html(user.id, user.first_name),
                                              mention_html(user_member.user.id, user_member.user.first_name))
        else:
            update.effective_message.edit_text(
                "यूजर के पास पहले से कोई चेतावनी नहीं है".format(
                    mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)

    return ""
예제 #5
0
def button(bot: Bot, update: Update) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text("Uyarıyı kaldıran {}.".format(
                mention_html(user.id, user.first_name)),
                                               parse_mode=ParseMode.HTML)
            user_member = chat.get_member(user_id)
            return "<b>{}:</b>" \
                   "\n#UYARILAMAYAN" \
                   "\n<b>Admin:</b> {}" \
                   "\n<b>Kullanıcı:</b> {} (<code>{}</code>)".format(html.escape(chat.title),
                                                                mention_html(user.id, user.first_name),
                                                                mention_html(user_member.user.id, user_member.user.first_name),
                                                                user_member.user.id)
        else:
            update.effective_message.edit_text(
                "Kullanıcının zaten hiçbir uyarısı yok.".format(
                    mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)

    return ""
예제 #6
0
def button(bot: Bot, update: Update) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        if not is_user_admin(chat, int(user.id)):
            query.answer(
                text=
                "р┤Ър╡Ар┤│р╡Н р┤кр┤┐р┤│р╡Нр┤│р╡Зр╡╝р┤╕р╡Н ADMIN р┤Ер┤▓р╡Нр┤▓ р┤Ор┤ир╡Нр┤ир┤┐р┤Яр╡Нр┤Яр╡Н REMOVE WARN р┤Ер┤ор╡╝р┤др╡Нр┤др┤╛р╡╗ р┤╡р┤ир╡Нр┤ир┤┐р┤░р┤┐р┤Хр╡Нр┤Хр╡Бр┤ир╡Нр┤ир╡Б",
                show_alert=True)
            return ""
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text("Warn removed by {}.".format(
                mention_html(user.id, user.first_name)),
                                               parse_mode=ParseMode.HTML)
            user_member = chat.get_member(user_id)
            return "<b>{}:</b>" \
                   "\n#UNWARN" \
                   "\n<b>Admin:</b> {}" \
                   "\n<b>User:</b> {} (<code>{}</code>)".format(html.escape(chat.title),
                                                                mention_html(user.id, user.first_name),
                                                                mention_html(user_member.user.id, user_member.user.first_name),
                                                                user_member.user.id)
        else:
            update.effective_message.edit_text(
                "р┤Зр┤пр┤╛р╡╛р┤Хр╡Нр┤Хр╡Н р┤ир┤┐р┤▓р┤╡р┤┐р╡╜ warns р┤Тр┤ир╡Нр┤ир╡Бр┤ор┤┐р┤▓р╡Нр┤▓."
                .format(mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)

    return ""
예제 #7
0
def button(bot: Bot, update: Update) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    message = update.effective_message  # type: Optional[Message]
    match = re.match(r"rm_warn\((.+?)\)", query.data)

    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        res = sql.remove_warn(user_id, chat.id)
        if res:
            admin_tag = mention_html(user.id, user.first_name)
            user_member = chat.get_member(user_id)
            unwarned_tag = mention_html(user_member.user.id,
                                        user_member.user.first_name)
            prev_message = update.effective_message.text_html
            message.edit_text(
                f"{prev_message}\n\n ~ Warning removed by {admin_tag}",
                parse_mode=ParseMode.HTML)
            # message.edit_text(prev_message,parse_mode=ParseMode.HTML)
            return f"<b>{html.escape(chat.title)}:</b>" \
                   f"\n#UNWARN" \
                   f"\n<b>Admin:</b> {admin_tag}" \
                   f"\n<b>User:</b> {unwarned_tag} (<code>{user_member.user.id}</code>)"
        else:
            message.edit_text("User already has no warns.")

    return ""
예제 #8
0
def rmwarn_handler(bot: Bot, update: Update) -> str:
    chat = update.effective_chat
    query = update.callback_query
    user = update.effective_user
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        if not is_user_admin(chat, int(user.id)):
            query.answer(text=tld(chat.id, 'warns_remove_admin_only'),
                         show_alert=True)
            return ""
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text(tld(
                chat.id, 'warns_remove_success').format(
                    mention_html(user.id, user.first_name)),
                                               parse_mode=ParseMode.HTML)
            user_member = chat.get_member(user_id)
            return tld(chat.id, 'warns_remove_log_channel').format(
                html.escape(chat.title), mention_html(user.id,
                                                      user.first_name),
                mention_html(user_member.user.id, user_member.user.first_name),
                user_member.user.id)
        else:
            update.effective_message.edit_text(tld(
                chat.id, 'warns_user_has_no_warns').format(
                    mention_html(user.id, user.first_name)),
                                               parse_mode=ParseMode.HTML)

    return ""
예제 #9
0
파일: warns.py 프로젝트: Khamis0/Khamis
def button(bot: Bot, update: Update) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text("Warn removed by {}.".format(
                mention_html(user.id, user.first_name)),
                                               parse_mode=ParseMode.HTML)
            user_member = chat.get_member(user_id)
            return "<b>{}:</b>" \
                   "\n#UNWARN" \
                   "\n<b>Admin:</b> {}" \
                   "\n<b>User:</b> {} (<code>{}</code>)".format(html.escape(chat.title),
                                                                mention_html(user.id, user.first_name),
                                                                mention_html(user_member.user.id, user_member.user.first_name),
                                                                user_member.user.id)
        else:
            update.effective_message.edit_text(
                "User has already has no warns.".format(
                    mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)

    return ""
예제 #10
0
def button(update, context):
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    chat = update.effective_chat  # type: Optional[Chat]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        if not is_user_admin(chat, int(user.id)):
            context.bot.answer_callback_query(
                query.id,
                text="You don't have enough rights to remove users warn.",
                show_alert=True)
            return ""
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text(
                "Last warn removed by {}.".format(
                    mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML,
            )
            user_member = chat.get_member(user_id)
            return ("<b>{}:</b>"
                    "\n#UNWARN"
                    "\n<b>Admin:</b> {}"
                    "\n<b>User:</b> {} (<code>{}</code>)".format(
                        html.escape(chat.title),
                        mention_html(user.id, user.first_name),
                        mention_html(user_member.user.id,
                                     user_member.user.first_name),
                        user_member.user.id,
                    ))
        update.effective_message.edit_text("This user already has no warns.",
                                           parse_mode=ParseMode.HTML)

    return ""
예제 #11
0
def button(update: Update, context: CallbackContext) -> str:
    query: Optional[CallbackQuery] = update.callback_query
    user: Optional[User] = update.effective_user
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat: Optional[Chat] = update.effective_chat
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text(
                "Warn removed by {}.".format(
                    mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML,
            )
            user_member = chat.get_member(user_id)
            return (
                f"<b>{html.escape(chat.title)}:</b>\n"
                f"#UNWARN\n"
                f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
                f"<b>User:</b> {mention_html(user_member.user.id, user_member.user.first_name)}"
            )
        else:
            update.effective_message.edit_text("User already has no warns.",
                                               parse_mode=ParseMode.HTML)

    return ""
예제 #12
0
def button(bot: Bot, update: Update) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text(
                "විසින් ඉවත් කරන ලද අනතුරු ඇඟවීම{}.".format(
                    mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)
            user_member = chat.get_member(user_id)
            return "<b>{}:</b>" \
                   "\n#UNWARN" \
                   "\n<b>Admin:</b> {}" \
                   "\n<b>User:</b> {}".format(html.escape(chat.title),
                                              mention_html(user.id, user.first_name),
                                              mention_html(user_member.user.id, user_member.user.first_name))
        else:
            update.effective_message.edit_text(
                "පරිශීලකයාට දැනටමත් අනතුරු ඇඟවීම් නොමැත.".format(
                    mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)

    return ""
예제 #13
0
def button(bot: Bot, update: Update) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text(
                "SP dihapus oleh {}.".format(mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)
            user_member = chat.get_member(user_id)
            return "✉️ #SP_EDIT ✍️" \
                   "\n<b>• Dari:</b> {} [<code>{}</code>]" \
                   "\n<b>• Untuk:</b> {} [<code>{}</code>]" \
                   "\n<b>• Grup:</b> {} [<code>{}</code>]" \
                   "\n#id{}".format(mention_html(user.id, user.first_name), user.id, 
                                    mention_html(user_member.user.id, user_member.user.first_name), user_member.user.id, 
                                    chat.title, chat.id, user_member.user.id)
        else:
            update.effective_message.edit_text(
                "⚠️ Pengguna sudah tidak memiliki SP".format(mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)

    return ""
예제 #14
0
def button(bot: Bot, update: Update) -> str:
    query: Optional[CallbackQuery] = update.callback_query
    user: Optional[User] = update.effective_user
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat: Optional[Chat] = update.effective_chat
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text(
                "Peringatkan dihapus oleh {}.".format(
                    mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML,
            )
            user_member = chat.get_member(user_id)
            return (
                f"<b>{html.escape(chat.title)}:</b>\n"
                f"#UNWARN\n"
                f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
                f"<b>Pengguna:</b> {mention_html(user_member.user.id, user_member.user.first_name)}"
            )
        else:
            update.effective_message.edit_text(
                f"Pengguna sudah tidak memiliki peringatan.",
                parse_mode=ParseMode.HTML)

    return ""
예제 #15
0
def button(bot: Bot, update: Update) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text(
                "Xəbərdarlıqlar {} tərəfindən təmizləndi.".format(mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)
            user_member = chat.get_member(user_id)
            return "<b>{}:</b>" \
                   "\n#UNWARN" \
                   "\n<b>Admin:</b> {}" \
                   "\n<b>User:</b> {}".format(html.escape(chat.title),
                                              mention_html(user.id, user.first_name),
                                              mention_html(user_member.user.id, user_member.user.first_name))
        else:
            update.effective_message.edit_text(
                "İstifadəçinin heç bir xəbərdarlığı yoxdu.".format(mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)

    return ""
예제 #16
0
def button(bot: Bot, update: Update) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text(
                "ئاگادارکردنەوە لابرا لەلایەن {}.".format(
                    mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)
            user_member = chat.get_member(user_id)
            return "<b>{}:</b>" \
                   "\n#لابردنی_ئاگادارکردنەوە" \
                   "\n<b>بەڕێوەبەر:</b> {}" \
                   "\n<b>بەکارهێنەر:</b> {} (<code>{}</code>)".format(html.escape(chat.title),
                                                                mention_html(user.id, user.first_name),
                                                                mention_html(user_member.user.id, user_member.user.first_name),
                                                                user_member.user.id)
        else:
            update.effective_message.edit_text(
                "ئەمە هیچ ئاگادارکردنەوەیەکی نییە.".format(
                    mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)

    return ""
def button(bot: Bot, update: Update) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        if not is_user_admin(chat, int(user.id)):
            query.answer(text="കീരികാടൻ ജോസ് ഇന്റെ പണി വേരോരുത്തനും ചെയ്യണ്ട",
                         show_alert=True)
            return ""
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text("Warn removed by {}.".format(
                mention_html(user.id, user.first_name)),
                                               parse_mode=ParseMode.HTML)
            user_member = chat.get_member(user_id)
            return "<b>{}:</b>" \
                   "\n#UNWARN" \
                   "\n<b>Admin:</b> {}" \
                   "\n<b>User:</b> {} (<code>{}</code>)".format(html.escape(chat.title),
                                                                mention_html(user.id, user.first_name),
                                                                mention_html(user_member.user.id, user_member.user.first_name),
                                                                user_member.user.id)
        else:
            update.effective_message.edit_text(
                "ഇയാൾക്ക് നിലവിൽ warns ഒന്നുമില്ല.".format(
                    mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)

    return ""
예제 #18
0
def button(bot: Bot, update: Update) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text(
                "{} താക്കീത് മാറ്റിയിരിക്കുന്നു.".format(mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)
            user_member = chat.get_member(user_id)
            return "<b>{}:</b>" \
                   "\n#UNWARN" \
                   "\n<b>Admin:</b> {}" \
                   "\n<b>User:</b> {}".format(html.escape(chat.title),
                                              mention_html(user.id, user.first_name),
                                              mention_html(user_member.user.id, user_member.user.first_name))
        else:
            update.effective_message.edit_text(
                "ഈ ഉപഭോക്താവിന് താക്കീതുകൾ ഒന്നും ലഭിച്ചിട്ടില്ല ".format(mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)

    return ""
예제 #19
0
def button(bot: Bot, update: Update) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        admin_user = chat.get_member(int(user.id))
        if not (admin_user.can_restrict_members
                or admin_user.status == "creator"):
            query.answer(
                text=
                "ചീള് പിള്ളേർസ് ADMIN അല്ല എന്നിട്ട് REMOVE WARN അമർത്താൻ വന്നിരിക്കുന്നു",
                show_alert=True)
            return ""
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text("Warn removed by {}.".format(
                mention_html(user.id, user.first_name)),
                                               parse_mode=ParseMode.HTML)
            user_member = chat.get_member(user_id)
            return "<b>{}:</b>" \
                   "\n#UNWARN" \
                   "\n<b>Admin:</b> {}" \
                   "\n<b>User:</b> {} (<code>{}</code>)".format(html.escape(chat.title),
                                                                mention_html(user.id, user.first_name),
                                                                mention_html(user_member.user.id, user_member.user.first_name),
                                                                user_member.user.id)
        else:
            update.effective_message.edit_text(
                "ഇയാൾക്ക് നിലവിൽ warns ഒന്നുമില്ല.".format(
                    mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)

    return ""
예제 #20
0
def button(bot: Bot, update: Update) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text(
                "اخطار ها توسط {} پاک شد!.".format(
                    mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)
            user_member = chat.get_member(user_id)
            return "<b>{}:</b>" \
                   "\n#پاکسازی_اخطار" \
                   "\n<b>توسط:</b> {}" \
                   "\n<b>کاربر:</b> {} (<code>{}</code>)".format(html.escape(chat.title),
                                                                mention_html(user.id, user.first_name),
                                                                mention_html(user_member.user.id, user_member.user.first_name),
                                                                user_member.user.id)
        else:
            update.effective_message.edit_text(
                "این کاربر اخطاری نداره که".format(
                    mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)

    return ""
예제 #21
0
def button(bot: Bot, update: Update) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text(
                "Otrzeżenie usunięte przez {}.".format(mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)
            user_member = chat.get_member(user_id)
            return "<b>{}:</b>" \
                   "\n#OTRZEŻENIE_ZDJĘTE" \
                   "\n<b>Administrator:</b> {}" \
                   "\n<b>Futrzak:</b> {}".format(html.escape(chat.title),
                                              mention_html(user.id, user.first_name),
                                              mention_html(user_member.user.id, user_member.user.first_name))
        else:
            update.effective_message.edit_text(
                "Futrzak już nie ma ostrzeżeń.".format(mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML)

    return ""
예제 #22
0
def remove_warns(bot: Bot, update: Update, args: List[str]) -> str:
    message = update.effective_message
    chat = update.effective_chat
    user = update.effective_user

    user_id = extract_user(message, args)

    if user_id:
        sql.remove_warn(user_id, chat.id)
        message.reply_text(tld(chat.id, 'warns_latest_remove_success'))
        warned = chat.get_member(user_id).user
        return tld(chat.id, 'warns_remove_log_channel').format(
            html.escape(chat.title), mention_html(user.id, user.first_name),
            mention_html(warned.id, warned.first_name), warned.id)
    else:
        message.reply_text(tld(chat.id, 'common_err_no_user'))
    return ""
예제 #23
0
def button(bot, update):
    query = update.callback_query
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat_id = update.effective_chat.id
        res = sql.remove_warn(user_id, chat_id)
        if res:
            update.effective_message.edit_text("Warn removed.")
예제 #24
0
def remove_warns(bot: Bot, update: Update, args: List[str]) -> str:
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]

    user_id = extract_user(message, args)

    if user_id:
        sql.remove_warn(user_id, chat.id)
        message.reply_text("Last warn has been removed!")
        warned = chat.get_member(user_id).user
        return "<b>{}:</b>" \
               "\n#UNWARN" \
               "\n<b>• Admin:</b> {}" \
               "\n<b>• User:</b> {}" \
               "\n<b>• ID:</b> <code>{}</code>".format(html.escape(chat.title),
                                                       mention_html(user.id, user.first_name),
                                                       mention_html(warned.id, warned.first_name),
                                                       warned.id)
    else:
        message.reply_text("No user has been designated!")
    return ""
예제 #25
0
def remove_warn(bot: Bot, update: Update, args: List[str]) -> str:
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]

    user_id = extract_user(message, args)

    if user_id:
        sql.remove_warn(user_id, chat.id)
        warned = chat.get_member(user_id).user
        unwarned_tag = mention_html(user_id, warned.first_name)
        warner_tag = mention_html(user.id, user.first_name)
        message.reply_text(
            f"{warner_tag} removed a warning for {unwarned_tag}",
            parse_mode=ParseMode.HTML)
        return f"<b>{html.escape(chat.title)}:</b>" \
               f"\n#UNWARN" \
               f"\n<b>• Admin:</b> {mention_html(user.id, user.first_name)}" \
               f"\n<b>• User:</b> {mention_html(warned.id, warned.first_name)}" \
               f"\n<b>• ID:</b> <code>{warned.id}</code>"
    else:
        message.reply_text("No user has been designated!")
    return ""
예제 #26
0
def button(update: Update, context: CallbackContext) -> str:
    bot = context.bot
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    chat = update.effective_chat
    admin = chat.get_member(int(user.id))
    if ((admin.status != "creator") and (not admin.can_restrict_members)
            and int(user.id) not in SUDO_USERS):
        query.answer(
            text="You don't have sufficient permissions to remove warns!")
        return ""

    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text(
                "Warn removed by {}.".format(
                    mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML,
            )
            user_member = chat.get_member(user_id)
            return ("<b>{}:</b>"
                    "\n#UNWARN"
                    "\n<b>Admin:</b> {}"
                    "\n<b>User:</b> {} (<code>{}</code>)".format(
                        html.escape(chat.title),
                        mention_html(user.id, user.first_name),
                        mention_html(user_member.user.id,
                                     user_member.user.first_name),
                        user_member.user.id,
                    ))
        update.effective_message.edit_text(
            "User has already has no warns.".format(
                mention_html(user.id, user.first_name)),
            parse_mode=ParseMode.HTML,
        )

    return ""
예제 #27
0
def button(update: Update, context: CallbackContext) -> str:
    bot = context.bot
    user = update.effective_user
    chat = update.effective_chat
    query = update.callback_query
    splitter = query.data.replace("report_", "").split("=")
    user_id = splitter[2]
    if splitter[1] == "kick":
        try:
            bot.kickChatMember(splitter[0], splitter[2])
            bot.unbanChatMember(splitter[0], splitter[2])
            query.answer("Successfully Kicked.")
            update.effective_message.edit_text(
                "User kicked by {}.".format(
                    mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML,
            )
            sql.reset_warns(splitter[2], splitter[0])
            return ""
        except Exception as err:
            query.answer("Failed to Kick")
    elif splitter[1] == "remove":
        res = sql.remove_warn(splitter[2], splitter[0])
        if res:
            update.effective_message.edit_text(
                "Warn removed by {}.".format(
                    mention_html(user.id, user.first_name)),
                parse_mode=ParseMode.HTML,
            )
            user_member = chat.get_member(user_id)
            return (
                f"<b>{html.escape(chat.title)}:</b>\n"
                f"#UNWARN\n"
                f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
                f"<b>User:</b> {mention_html(user_member.user.id, user_member.user.first_name)}"
            )
        else:
            update.effective_message.edit_text("User already has no warns.",
                                               parse_mode=ParseMode.HTML)
        return ""
예제 #28
0
def button(bot: Bot, update: Update) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text(
                "Warn removed by [{}](tg://user?id={}).".format(
                    escape_markdown(user.first_name), user.id),
                parse_mode=ParseMode.MARKDOWN)
            user_member = chat.get_member(user_id)
            return "{}:" \
                   "\n#UNWARN" \
                   "\n*Admin:* [{}](tg://user?id={})" \
                   "\n*User:* [{}](tg://user?id={})".format(escape_markdown(chat.title),
                                                            escape_markdown(user.first_name),
                                                            user.id, escape_markdown(user_member.user.first_name),
                                                            user_member.user.id)
    return ""
예제 #29
0
def button(bot: Bot, update: Update) -> str:
    query = update.callback_query  # type: Optional[CallbackQuery]
    user = update.effective_user  # type: Optional[User]
    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        user_id = match.group(1)
        chat = update.effective_chat  # type: Optional[Chat]
        res = sql.remove_warn(user_id, chat.id)
        if res:
            update.effective_message.edit_text(
                "Ammonimento rimosso da {}.".format(
                    mention_html(user.id, user.first_name)
                ),
                parse_mode=ParseMode.HTML,
            )
            user_member = chat.get_member(user_id)
            return (
                "<b>{}:</b>"
                "\n#UNWARN"
                "\n<b>Admin:</b> {}"
                "\n<b>Utente:</b> {} (<code>{}</code>)".format(
                    html.escape(chat.title),
                    mention_html(user.id, user.first_name),
                    mention_html(user_member.user.id, user_member.user.first_name),
                    user_member.user.id,
                )
            )
        else:
            update.effective_message.edit_text(
                "Utente gia privo di ammonimenti.".format(
                    mention_html(user.id, user.first_name)
                ),
                parse_mode=ParseMode.HTML,
            )

    return ""