示例#1
0
def report_setting(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    msg = update.effective_message  # type: Optional[Message]

    if chat.type == chat.PRIVATE:
        if len(args) >= 1:
            if args[0] in ("روشن", "on"):
                sql.set_user_setting(chat.id, True)
                msg.reply_text("حالت خبرچین فعال شد! اگه کسی درخواست بده سریعا بهتون اطلاع میدم.")

            elif args[0] in ("خاموش", "off"):
                sql.set_user_setting(chat.id, False)
                msg.reply_text("حالت خبرچین غیرفعال شد! کسی بمیره هم بهت اطلاع نمیدم😄")
        else:
            msg.reply_text("حالت خبرچین شما : `{}`".format(sql.user_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)

    else:
        if len(args) >= 1:
            if args[0] in ("روشن", "on"):
                sql.set_chat_setting(chat.id, True)
                msg.reply_text("خبرچین گپ فعال شد ، اگه کسی از دستور ریپورت یا /report روی کسی"
                               "ریپلی کنه من سریعا به ادمینها اطلاع میدم.")

            elif args[0] in ("غیرفعال", "off"):
                sql.set_chat_setting(chat.id, False)
                msg.reply_text("حالت خبرچین غیرفعال شد . اینجا همدیگه هم بکشن ، من صدام درنمیاد☹️.")
        else:
            msg.reply_text("حالت خبرچین این گپ: `{}`".format(sql.chat_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)
示例#2
0
def report_setting(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    msg = update.effective_message  # type: Optional[Message]

    if chat.type == chat.PRIVATE:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_user_setting(chat.id, True)
                msg.reply_text(
                    "채팅방 관리자에게 신고 기능을 켰어요! 관리자들은 누군가 /report 명령어를 쓰는 즉시 알림이 뜰 거예요!"
                )

            elif args[0] in ("no", "off"):
                sql.set_user_setting(chat.id, False)
                msg.reply_text("채팅방 관리자에게 신고 기능을 껐어요! 당신은 아무것도 보고할 수 없어요.")
        else:
            msg.reply_text("현재 당신의 채팅방 관리자에게 신고 기능 설정 : `{}`".format(
                sql.user_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)

    else:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_chat_setting(chat.id, True)
                msg.reply_text(
                    "채팅방 관리자에게 신고 기능을 켰어요! 관리자들은 누군가 /report 명령어를 쓰는 즉시 알림이 뜰 거예요!"
                )

            elif args[0] in ("no", "off"):
                sql.set_chat_setting(chat.id, False)
                msg.reply_text("채팅방 관리자에게 신고 기능을 껐어요! 당신은 아무것도 신고할 수 없어요.")
        else:
            msg.reply_text("현재 당신의 채팅방 관리자에게 신고 기능 설정 : `{}`".format(
                sql.chat_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)
示例#3
0
def report_setting(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    msg = update.effective_message  # type: Optional[Message]

    if chat.type == chat.PRIVATE:
        if len(args) >= 1:
            if args[0] in ("ac", "evet"):
                sql.set_user_setting(chat.id, True)
                msg.reply_text("Şikayet etme açıldı! Herhangi biri bir şey bildirdiğinde bilgilendirileceksiniz.")

            elif args[0] in ("kapat", "hayir"):
                sql.set_user_setting(chat.id, False)
                msg.reply_text("Şikayet etme kapatıldı! Herhangi bir rapor almayacaksınız.")
        else:
            msg.reply_text("Mevcut rapor tercihiniz: `{}`".format(sql.user_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)

    else:
        if len(args) >= 1:
            if args[0] in ("ac", "evet"):
                sql.set_chat_setting(chat.id, True)
                msg.reply_text("Şikayet etme seçeneği açıldı! /sikayetet ve @yönetici komutları artık çalışıyor ! "
                               "Yöneticilere bildirim yapılacak.")

            elif args[0] in ("kapat", "hayir"):
                sql.set_chat_setting(chat.id, False)
                msg.reply_text("Şikayet etme seçeneği kapatıldı. /sikayetet ve @yönetici komutları artık çalışmayacak.")
        else:
            msg.reply_text("Bu sohbetin mevcut ayarı: `{}`".format(sql.chat_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)
示例#4
0
def report(bot: Bot, update: Update) -> str:
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]

    if chat and message.reply_to_message and sql.chat_should_report(chat.id):
        reported_user = message.reply_to_message.from_user  # type: Optional[User]
        chat_name = chat.title or chat.first or chat.username
        admin_list = chat.get_administrators()
        messages = update.effective_message  # type: Optional[Message]
        if chat.username and chat.type == Chat.SUPERGROUP:
            
            reported = "Reported {} to admins. I've notified the admins!".format(mention_html(reported_user.id,
                                                                                       reported_user.first_name))
            msg = "<b>{}:</b>" \
                  "\n<b>Reported user:</b> {} (<code>{}</code>)" \
                  "\n<b>Reported by:</b> {} (<code>{}</code>)".format(html.escape(chat.title),
                                                                      mention_html(
                                                                          reported_user.id,
                                                                          reported_user.first_name),
                                                                      reported_user.id,
                                                                      mention_html(user.id,
                                                                                   user.first_name),
                                                                      user.id)
            link = "\n<b>Link:</b> " \
                   "<a href=\"http://telegram.me/{}/{}\">click here</a>".format(chat.username, message.message_id)
            
            
            should_forward = False
            keyboard = []
            messages.reply_text(reported, reply_markup=keyboard, parse_mode=ParseMode.HTML)
        else:
            reported = "Reported {} to admins. I've notified the admins!".format(mention_html(reported_user.id,
                                                                                       reported_user.first_name))
            msg = "{} is calling for admins in \"{}\"!".format(mention_html(user.id, user.first_name),
                                                               html.escape(chat_name))
            link = ""
            should_forward = True
            keyboard = []
            messages.reply_text(reported, reply_markup=keyboard, parse_mode=ParseMode.HTML)
        for admin in admin_list:
            if admin.user.is_bot:  # can't message bots
                continue

            if sql.user_should_report(admin.user.id):
                try:
                    bot.send_message(admin.user.id, msg + link, parse_mode=ParseMode.HTML)
                    if should_forward:
                        message.reply_to_message.forward(admin.user.id)

                        if len(message.text.split()) > 1:  # If user is giving a reason, send his message too
                            message.forward(admin.user.id)

                except Unauthorized:
                    pass
                except BadRequest as excp:  # TODO: cleanup exceptions
                    LOGGER.exception("Exception while reporting user")
        return msg

    return ""
示例#5
0
def report_setting(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    msg = update.effective_message  # type: Optional[Message]

    if chat.type == chat.PRIVATE:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_user_setting(chat.id, True)
                msg.reply_text("Turned on reporting! You'll be notified whenever anyone reports something.")

            elif args[0] in ("no", "off"):
                sql.set_user_setting(chat.id, False)
                msg.reply_text("Turned off reporting! You wont get any reports.")
        else:
            msg.reply_text("Your current report preference is: `{}`".format(sql.user_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)

    else:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_chat_setting(chat.id, True)
                msg.reply_text("Turned on reporting! Admins who have turned on reports will be notified when /report "
                               "or @admin are called.")

            elif args[0] in ("no", "off"):
                sql.set_chat_setting(chat.id, False)
                msg.reply_text("Turned off reporting! No admins will be notified on /report or @admin.")
        else:
            msg.reply_text("This chat's current setting is: `{}`".format(sql.chat_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)
示例#6
0
def report(bot: Bot, update: Update) -> str:
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]

    if chat and message.reply_to_message and sql.chat_should_report(chat.id):
        reported_user = message.reply_to_message.from_user  # type: Optional[User]
        chat_name = chat.title or chat.first or chat.username
        admin_list = chat.get_administrators()

        if chat.username and chat.type == Chat.SUPERGROUP:
            message.reply_text("Raporunuz Alındı!")
            msg = "<b>{}:</b>" \
                  "\n<b>Raporlanan Kullanıcı:</b> {} (<code>{}</code>)" \
                  "\n<b>Raporlayan Kullanıcı:</b> {} (<code>{}</code>)".format(html.escape(chat.title),
                                                                      mention_html(
                                                                          reported_user.id,
                                                                          reported_user.first_name),
                                                                      reported_user.id,
                                                                      mention_html(user.id,
                                                                                   user.first_name),
                                                                      user.id)
            link = "\n<b>Mesaj Linki:</b> " \
                   "<a href=\"http://telegram.me/{}/{}\">Mesaja Git!</a>".format(chat.username, message.message_id)

            should_forward = False

        else:
            msg = "{} İsimli Kullanıcı Sizi Arıyor \"{}\"!".format(
                mention_html(user.id, user.first_name), html.escape(chat_name))
            link = ""
            should_forward = True

        for admin in admin_list:
            if admin.user.is_bot:  # can't message bots
                continue

            if sql.user_should_report(admin.user.id):
                try:
                    bot.send_message(admin.user.id,
                                     msg + link,
                                     parse_mode=ParseMode.HTML)

                    if should_forward:
                        message.reply_to_message.forward(admin.user.id)

                        if len(
                                message.text.split()
                        ) > 1:  # If user is giving a reason, send his message too
                            message.forward(admin.user.id)

                except Unauthorized:
                    pass
                except BadRequest as excp:  # TODO: cleanup exceptions
                    LOGGER.exception("Exception while reporting user")
        return msg

    return ""
示例#7
0
def report(bot: Bot, update: Update) -> str:
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]

    if chat and message.reply_to_message and sql.chat_should_report(chat.id):
        reported_user = message.reply_to_message.from_user  # type: Optional[User]
        chat_name = chat.title or chat.first or chat.username
        admin_list = chat.get_administrators()

        if chat.username and chat.type == Chat.SUPERGROUP:
            msg = ("<b>{}:</b>"
                   "\n<b>Reported user:</b> {} (<code>{}</code>)"
                   "\n<b>Reported by:</b> {} (<code>{}</code>)".format(
                       html.escape(chat.title),
                       mention_html(reported_user.id,
                                    reported_user.first_name),
                       reported_user.id,
                       mention_html(user.id, user.first_name),
                       user.id,
                   ))
            link = ("\n<b>Link:</b> "
                    '<a href="http://telegram.me/{}/{}">qui</a>'.format(
                        chat.username, message.message_id))

            should_forward = False

        else:
            msg = '{} sta chiamando gli admin in "{}"!'.format(
                mention_html(user.id, user.first_name), html.escape(chat_name))
            link = ""
            should_forward = True

        for admin in admin_list:
            if admin.user.is_bot:  # can't message bots
                continue

            if sql.user_should_report(admin.user.id):
                try:
                    bot.send_message(admin.user.id,
                                     msg + link,
                                     parse_mode=ParseMode.HTML)

                    if should_forward:
                        message.reply_to_message.forward(admin.user.id)

                        if (
                                len(message.text.split()) > 1
                        ):  # If user is giving a reason, send his message too
                            message.forward(admin.user.id)

                except Unauthorized:
                    pass
                except BadRequest as excp:  # TODO: cleanup exceptions
                    LOGGER.exception("Exception while reporting user")
        return msg

    return ""
def report(update: Update, context: CallbackContext) -> str:
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]

    if chat and message.reply_to_message and sql.chat_should_report(chat.id):
        reported_user = message.reply_to_message.from_user  # type: Optional[User]
        chat_name = chat.title or chat.first or chat.username
        admin_list = chat.get_administrators()

        if chat.username and chat.type == Chat.SUPERGROUP:
            msg = "<b>{}:</b>" \
                  "\n<b>신고하는 유저:</b> {} (<code>{}</code>)" \
                  "\n<b>신고 대상:</b> {} (<code>{}</code>)".format(html.escape(chat.title),
                                                                      mention_html(
                                                                          reported_user.id,
                                                                          reported_user.first_name),
                                                                      reported_user.id,
                                                                      mention_html(user.id,
                                                                                   user.first_name),
                                                                      user.id)
            link = "\n<b>링크:</b> " \
                   "<a href=\"http://telegram.me/{}/{}\">여기를 누르세요</a>".format(chat.username, message.message_id)

            should_forward = False

        else:
            msg = "{} 이(가) \"{}\" 방의 관리자에게 말해요!".format(
                mention_html(user.id, user.first_name), html.escape(chat_name))
            link = ""
            should_forward = True

        for admin in admin_list:
            if admin.user.is_bot:  # can't message bots
                continue

            if sql.user_should_report(admin.user.id):
                try:
                    context.bot.send_message(admin.user.id,
                                             msg + link,
                                             parse_mode=ParseMode.HTML)

                    if should_forward:
                        message.reply_to_message.forward(admin.user.id)

                        if len(
                                message.text.split()
                        ) > 1:  # If user is giving a reason, send his message too
                            message.forward(admin.user.id)

                except Unauthorized:
                    pass
                except BadRequest as excp:  # TODO: cleanup exceptions
                    LOGGER.exception("사용자를 채팅방 관리자에게 신고하는 동안 예외 발생.")
        return msg

    return ""
示例#9
0
def report(bot: Bot, update: Update) -> str:
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]

    if chat and message.reply_to_message and sql.chat_should_report(chat.id):
        reported_user = message.reply_to_message.from_user  # type: Optional[User]
        chat_name = chat.title or chat.first or chat.username
        admin_list = chat.get_administrators()

        if chat.username and chat.type == Chat.SUPERGROUP:
            msg = "<b>{}:</b>" \
                  "\n<b>کاربر گزارش شده:</b> {} (<code>{}</code>)" \
                  "\n<b>توسط:</b> {} (<code>{}</code>) مشخص شد!".format(html.escape(chat.title),
                                                                      mention_html(
                                                                          reported_user.id,
                                                                          reported_user.first_name),
                                                                      reported_user.id,
                                                                      mention_html(user.id,
                                                                                   user.first_name),
                                                                      user.id)
            link = "\n<b>لینک:</b> " \
                   "<a href=\"http://telegram.me/{}/{}\">کلیک کن</a>".format(chat.username, message.message_id)

            should_forward = False

        else:
            msg = "کاربر {} درگپ \"{}\"درخواست ادمین کرده . خواهشا زود بیا!".format(mention_html(user.id, user.first_name),
                                                               html.escape(chat_name))
            link = ""
            should_forward = True

        for admin in admin_list:
            if admin.user.is_bot:  # can't message bots
                continue

            if sql.user_should_report(admin.user.id):
                try:
                    bot.send_message(admin.user.id, msg + link, parse_mode=ParseMode.HTML)

                    if should_forward:
                        message.reply_to_message.forward(admin.user.id)

                        if len(message.text.split()) > 1:  # If user is giving a reason, send his message too
                            message.forward(admin.user.id)

                except Unauthorized:
                    pass
                except BadRequest as excp:  # TODO: cleanup exceptions
                    LOGGER.exception("Exception while reporting user")
        return msg

    return ""
示例#10
0
def report(bot: Bot, update: Update) -> str:
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]

    if chat and message.reply_to_message and sql.chat_should_report(chat.id):
        reported_user = message.reply_to_message.from_user  # type: Optional[User]
        chat_name = chat.title or chat.first or chat.username
        admin_list = chat.get_administrators()

        if chat.username and chat.type == Chat.SUPERGROUP:
            msg = "*Group:* {}\n" \
                  "*Reported user:* {} (`{}`)\n" \
                  "*Reported by:* {} (`{}`)\n" \
                  "*Link:* [click here](http://telegram.me/{}/{})".format(escape_markdown(chat.title),
                                                                          escape_markdown(reported_user.first_name),
                                                                          reported_user.id,
                                                                          escape_markdown(user.first_name),
                                                                          user.id,
                                                                          chat.username, message.message_id)
            should_forward = False

        else:
            msg = "[{}](tg://user?id={}) is calling for admins in \"{}\"!".format(
                escape_markdown(user.first_name), user.id,
                escape_markdown(chat_name))
            should_forward = True

        for admin in admin_list:
            if admin.user.is_bot:  # can't message bots
                continue

            if sql.user_should_report(admin.user.id):
                try:
                    bot.send_message(admin.user.id,
                                     msg,
                                     parse_mode=ParseMode.MARKDOWN)

                    if should_forward:
                        message.reply_to_message.forward(admin.user.id)

                        if len(
                                message.text.split()
                        ) > 1:  # If user is giving a reason, send his message too
                            message.forward(admin.user.id)

                except Unauthorized:
                    pass
                except BadRequest as excp:  # TODO: cleanup exceptions
                    LOGGER.exception("Exception while reporting user")
        return msg

    return ""
示例#11
0
def __user_settings__(update, context, user):
    if sql.user_should_report(user.id) is True:
        text = "You will receive reports from chats you're admin."
        keyboard = [[
            InlineKeyboardButton(text="Disable reporting",
                                 callback_data="panel_reporting_U_disable")
        ]]
    else:
        text = "You will *not* receive reports from chats you're admin."
        keyboard = [[
            InlineKeyboardButton(text="Enable reporting",
                                 callback_data="panel_reporting_U_enable")
        ]]

    return text, keyboard
示例#12
0
def __user_settings__(bot, update, user):
    if sql.user_should_report(user.id) == True:
        text = "Anda akan menerima laporan dari obrolan yang Anda kelola."
        keyboard = [[
            InlineKeyboardButton(text="Nonaktifkan pelaporan",
                                 callback_data="panel_reporting_U_disable")
        ]]
    else:
        text = "Anda *tidak* akan menerima laporan dari obrolan yang Anda kelola."
        keyboard = [[
            InlineKeyboardButton(text="Aktifkan pelaporan",
                                 callback_data="panel_reporting_U_enable")
        ]]

    return text, keyboard
示例#13
0
def alert(update: Update, context: CallbackContext) -> str:
    bot = context.bot
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    ping_list = ""

    if chat and sql.chat_should_report(chat.id):
        chat_name = chat.title or chat.first or chat.username
        admin_list = chat.get_administrators()

        log = ("<b>{}:</b>"
               "\n#ALERTED"
               "\n<b>Reporter:</b> {} (<code>{}</code>)".format(
                   html.escape(chat_name),
                   mention_html(user.id, user.first_name),
                   user.id,
               ))

        admin_msg = log
        if chat.type == chat.SUPERGROUP and chat.username:
            admin_msg += (
                "\n<b>Link:</b> " +
                '<a href="http://telegram.me/{}/{}">click here</a>'.format(
                    chat.username, message.message_id))

        for admin in admin_list:
            if admin.user.is_bot:  # can't message bots
                continue
            if sql.user_should_report(admin.user.id):
                ping_list += f"​[​](tg://user?id={admin.user.id})"
                try:
                    bot.send_message(admin.user.id,
                                     admin_msg,
                                     parse_mode=ParseMode.HTML)
                except Unauthorized:
                    pass
                except BadRequest:  # TODO: cleanup exceptions
                    LOGGER.exception("Exception while reporting user")

        message.reply_text(
            "Successfully alerted admins!" + ping_list,
            parse_mode=ParseMode.MARKDOWN,
        )

        return log

    return ""
示例#14
0
def report_setting(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    msg = update.effective_message  # type: Optional[Message]

    if chat.type == chat.PRIVATE:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_user_setting(chat.id, True)
                msg.reply_text(
                    "Aktifkan pelaporan! Anda akan diberi tahu setiap kali ada yang melaporkan sesuatu."
                )

            elif args[0] in ("no", "off"):
                sql.set_user_setting(chat.id, False)
                msg.reply_text(
                    "Nonaktifkan pelaporan! Anda tidak akan mendapatkan laporan apapun."
                )
        else:
            msg.reply_text(
                "Preferensi laporan Anda saat ini adalah: `{}`".format(
                    sql.user_should_report(chat.id)),
                parse_mode=ParseMode.MARKDOWN,
            )

    else:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_chat_setting(chat.id, True)
                msg.reply_text(
                    "Aktifkan pelaporan! Admin yang telah mengaktifkan laporan akan diberi tahu ketika /report "
                    "atau @admin jika dipanggil.")

            elif args[0] in ("no", "off"):
                sql.set_chat_setting(chat.id, False)
                msg.reply_text(
                    "Nonaktifkan pelaporan! Tidak ada admin yang akan diberitahukan pada /report atau @admin."
                )
        else:
            msg.reply_text(
                "Pengaturan obrolan saat ini adalah: `{}`".format(
                    sql.chat_should_report(chat.id)),
                parse_mode=ParseMode.MARKDOWN,
            )
示例#15
0
def report_setting(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    msg = update.effective_message  # type: Optional[Message]

    if chat.type == chat.PRIVATE:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_user_setting(chat.id, True)
                msg.reply_text(
                    "Reporting aktiv edildi! Əgər kimsə nəyisə bildirsə adminlərə bildiriş gedəcək."
                )

            elif args[0] in ("no", "off"):
                sql.set_user_setting(chat.id, False)
                msg.reply_text(
                    "Reporting deaktiv edildi! Əgər kimsə məyisə bildirsə adminlərə bildiriş gedəcək."
                )
        else:
            msg.reply_text("Hazırkı report ayarı: `{}`".format(
                sql.user_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)

    else:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_chat_setting(chat.id, True)
                msg.reply_text(
                    "Reporting aktiv edildi! Kimsə /report "
                    "və ya @admin əmrlərini işlətsə adminlərə bildiriç gedəcək."
                )

            elif args[0] in ("no", "off"):
                sql.set_chat_setting(chat.id, False)
                msg.reply_text(
                    "Reporting deaktiv edildi! İstifadəçilər /report və ya @admin əmrini işlətsə adminlərə bildiriş getməyəcək."
                )
        else:
            msg.reply_text("Hazırki ayar: `{}`".format(
                sql.chat_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)
示例#16
0
def report_setting(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    msg = update.effective_message  # type: Optional[Message]

    if chat.type == chat.PRIVATE:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_user_setting(chat.id, True)
                msg.reply_text(
                    "Reporting acceso! Verrai notificati ogni volta che qualcuno riporta qualcosa."
                )

            elif args[0] in ("no", "off"):
                sql.set_user_setting(chat.id, False)
                msg.reply_text("Reporting spento. Non verrai notificato.")
        else:
            msg.reply_text(
                "Le tue impostazioni attuali per il modulo Reporting sono: `{}`"
                .format(sql.user_should_report(chat.id)),
                parse_mode=ParseMode.MARKDOWN,
            )

    else:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_chat_setting(chat.id, True)
                msg.reply_text(
                    "Reporting acceso! Tutti gli admin che hanno abilitato il reporting verranno notificati ogni voltra che un utente usa il comando /reporting "
                    "o @admin")

            elif args[0] in ("no", "off"):
                sql.set_chat_setting(chat.id, False)
                msg.reply_text(
                    "Reporting spento. Nessun admin verrà notificato.")
        else:
            msg.reply_text(
                "La chat è attualmente impostata: `{}`".format(
                    sql.chat_should_report(chat.id)),
                parse_mode=ParseMode.MARKDOWN,
            )
示例#17
0
def report_setting(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    msg = update.effective_message  # type: Optional[Message]

    if chat.type == chat.PRIVATE:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_user_setting(chat.id, True)
                msg.reply_text(
                    "Pelaporan diaktifkan!, Anda akan diberi tahu setiap kali ada yang melaporkan sesuatu di dalam grup."
                )

            elif args[0] in ("no", "off"):
                sql.set_user_setting(chat.id, False)
                msg.reply_text(
                    "Pelaporan dinonaktifkan, Anda tidak akan menerima laporan lagi dari grup."
                )
        else:
            msg.reply_text(
                "Preferensi laporan anda saat ini adalah: `{}`".format(
                    sql.user_should_report(chat.id)),
                parse_mode=ParseMode.MARKDOWN)

    else:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_chat_setting(chat.id, True)
                msg.reply_text(
                    "Pelaporan diaktifkan!, Admin yang mengaktifkan pelaporan akan di beritahu jika ada anggota yang mengatakan /report "
                    "atau dipanggil dengan tag @admin.")

            elif args[0] in ("no", "off"):
                sql.set_chat_setting(chat.id, False)
                msg.reply_text(
                    "Pelaporan dinonaktifkan!, admin tidak akan lagi diberitahu jika ada yang mengatakan /report atau @admin."
                )
        else:
            msg.reply_text("This chat's current setting is: `{}`".format(
                sql.chat_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)
示例#18
0
def report_setting(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    msg = update.effective_message  # type: Optional[Message]

    if chat.type == chat.PRIVATE:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_user_setting(chat.id, True)
                msg.reply_text(
                    "වාර්තා කිරීම සක්‍රිය කර ඇත! කවුරුහරි යමක් වාර්තා කළ විට ඔබට දන්වනු ලැබේ."
                )

            elif args[0] in ("no", "off"):
                sql.set_user_setting(chat.id, False)
                msg.reply_text(
                    "වාර්තා කිරීම අක්‍රියයි! ඔබට කිසිදු වාර්තාවක් ලැබෙන්නේ නැත."
                )
        else:
            msg.reply_text("Your current report preference is: `{}`".format(
                sql.user_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)

    else:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_chat_setting(chat.id, True)
                msg.reply_text(
                    "වාර්තා කිරීම සක්‍රිය කර ඇත! වාර්තා සක්‍රිය කර ඇති පරිපාලකයින්ට කවදාදැයි දැනුම් දෙනු ලැබේ /report "
                    "හෝ @admin ලෙස හැඳින්වේ.")

            elif args[0] in ("no", "off"):
                sql.set_chat_setting(chat.id, False)
                msg.reply_text(
                    "වාර්තා කිරීම අක්‍රියයි! කිසිදු පරිපාලකවරයෙකුට දැනුම් දෙනු නොලැබේ /report or @admin."
                )
        else:
            msg.reply_text("This chat's current setting is: `{}`".format(
                sql.chat_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)
示例#19
0
def report_setting(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    msg = update.effective_message  # type: Optional[Message]

    if chat.type == chat.PRIVATE:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_user_setting(chat.id, True)
                msg.reply_text(
                    "Ativei os reports! Você será notificado quando alguém reportar algo."
                )

            elif args[0] in ("no", "off"):
                sql.set_user_setting(chat.id, False)
                msg.reply_text(
                    "Turned off reporting! You wont get any reports.")
        else:
            msg.reply_text("A sua preferência de reports é: `{}`".format(
                sql.user_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)

    else:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_chat_setting(chat.id, True)
                msg.reply_text(
                    "Ativei os reports! Admins que tiverem ligado os reports serão notificados quando /report "
                    "ou @admin for chamado.")

            elif args[0] in ("no", "off"):
                sql.set_chat_setting(chat.id, False)
                msg.reply_text(
                    "Desativei os reports! Nenhum admin será notificado com o /report ou @admin."
                )
        else:
            msg.reply_text("This chat's current setting is: `{}`".format(
                sql.chat_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)
示例#20
0
def report_setting(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    msg = update.effective_message  # type: Optional[Message]

    if chat.type == chat.PRIVATE:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_user_setting(chat.id, True)
                msg.reply_text(
                    "Habercilik açık! Ne zaman biri bir şey bildirse size bildirilir.."
                )

            elif args[0] in ("no", "off"):
                sql.set_user_setting(chat.id, False)
                msg.reply_text(
                    "Habercilik kapatıldı! Herhangi bir rapor almak olmaz.")
        else:
            msg.reply_text("Geçerli rapor tercihiniz: `{}`".format(
                sql.user_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)

    else:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_chat_setting(chat.id, True)
                msg.reply_text(
                    "Habercilik açık! Raporları açık olan yöneticiler "
                    "veya @admin denir.")

            elif args[0] in ("no", "off"):
                sql.set_chat_setting(chat.id, False)
                msg.reply_text(
                    "Habercilik kapatıldı! /report veya @admin'da yönetici bilgilendirilmeyecektir."
                )
        else:
            msg.reply_text("Bu sohbetin geçerli ayarı: `{}`".format(
                sql.chat_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)
示例#21
0
def report_setting(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    msg = update.effective_message  # type: Optional[Message]

    if chat.type == chat.PRIVATE:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_user_setting(chat.id, True)
                msg.reply_text(
                    "Raporlama açıldı! Herhangi biri bir şey bildirdiğinde bilgilendirileceksiniz."
                )

            elif args[0] in ("no", "off"):
                sql.set_user_setting(chat.id, False)
                msg.reply_text(
                    "Raporlama kapatıldı! Herhangi bir rapor almayacaksınız.")
        else:
            msg.reply_text("Mevcut rapor tercihiniz: `{}`".format(
                sql.user_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)

    else:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_chat_setting(chat.id, True)
                msg.reply_text(
                    "Raporlama açıldı! Raporları etkinleştiren yöneticiler, /report edildiğinde bilgilendirilecek "
                    "ya da @admin Çağırldığında.")

            elif args[0] in ("no", "off"):
                sql.set_chat_setting(chat.id, False)
                msg.reply_text(
                    "Raporlama kapatıldı! /report veya @admin ile ilgili hiçbir yönetici bilgilendirilmeyecektir."
                )
        else:
            msg.reply_text("Mevcut rapor tercihiniz: `{}`".format(
                sql.chat_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)
示例#22
0
def report_setting(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    msg = update.effective_message  # type: Optional[Message]

    if chat.type == chat.PRIVATE:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_user_setting(chat.id, True)
                msg.reply_text(
                    "Rapor alınabilir! Birisi bir şey bildirdiğinde bildirim alacaksınız."
                )

            elif args[0] in ("no", "off"):
                sql.set_user_setting(chat.id, False)
                msg.reply_text(
                    "Raporlama kapatıldı. Herhangi bir rapor almayacaksınız.")
        else:
            msg.reply_text("Mevcut rapor tercihiniz: `{}`".format(
                sql.user_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)

    else:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_chat_setting(chat.id, True)
                msg.reply_text("Raporlama etkin. /report veya "
                               "@admin şeklinde raporlayabilirsiniz.")

            elif args[0] in ("no", "off"):
                sql.set_chat_setting(chat.id, False)
                msg.reply_text(
                    "Raporlama iptal edildi! /report veya @admin üzerinde hiçbir yönetici bildirilmez."
                )
        else:
            msg.reply_text("Mevcut rapor tercihiniz: `{}`".format(
                sql.chat_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)
示例#23
0
def report_setting(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    msg = update.effective_message  # type: Optional[Message]

    if chat.type == chat.PRIVATE:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_user_setting(chat.id, True)
                msg.reply_text(
                    "سکاڵاکردن چالاککرا! ئاگاداردەکرێیتەوە هەرکاتێک یەکێک سکاڵایەکی کرد."
                )

            elif args[0] in ("no", "off"):
                sql.set_user_setting(chat.id, False)
                msg.reply_text("سکاڵاکردن ناچالاککرا!")
        else:
            msg.reply_text("Your current report preference is: `{}`".format(
                sql.user_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)

    else:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_chat_setting(chat.id, True)
                msg.reply_text(
                    "Turned on reporting! Admins who have turned on reports will be notified when /report "
                    "or @admin are called.")

            elif args[0] in ("no", "off"):
                sql.set_chat_setting(chat.id, False)
                msg.reply_text(
                    "Turned off reporting! No admins will be notified on /report or @admin."
                )
        else:
            msg.reply_text("This chat's current setting is: `{}`".format(
                sql.chat_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)
示例#24
0
def report_setting(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    msg = update.effective_message  # type: Optional[Message]

    if chat.type == chat.PRIVATE:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_user_setting(chat.id, True)
                msg.reply_text(
                    "Kisi ke kuch bhi report karne pe apko notify kiya jaega.")

            elif args[0] in ("no", "off"):
                sql.set_user_setting(chat.id, False)
                msg.reply_text(
                    "kisi ke report karne pe apko notification nhi milegi")
        else:
            msg.reply_text("Your current report preference is: `{}`".format(
                sql.user_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)

    else:
        if len(args) >= 1:
            if args[0] in ("yes", "on"):
                sql.set_chat_setting(chat.id, True)
                msg.reply_text(
                    "admins ko notify kiya jaega jinki reporting ON h agar koi user /report "
                    "or @admin use kare to.")

            elif args[0] in ("no", "off"):
                sql.set_chat_setting(chat.id, False)
                msg.reply_text(
                    "admins ko notify nhi kiya jaega jinki reporting ON h agar koi user /report or @admin use karega."
                )
        else:
            msg.reply_text("Group ki reporting setting abhi: `{}`".format(
                sql.chat_should_report(chat.id)),
                           parse_mode=ParseMode.MARKDOWN)
示例#25
0
def report(update, context) -> str:
    message = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]

    if chat and message.reply_to_message and sql.chat_should_report(chat.id):
        reported_user = message.reply_to_message.from_user  # type: Optional[User]
        chat_name = chat.title or chat.first or chat.username
        admin_list = chat.get_administrators()
        messages = update.effective_message

        isadmeme = chat.get_member(reported_user.id).status
        if isadmeme == "administrator" or isadmeme == "creator":
            return ""  # No point of reporting admins!

        if user.id == reported_user.id:
            message.reply_text("Why the hell you're reporting yourself?")
            return ""

        if reported_user.id == context.bot.id:
            message.reply_text("I'm not gonna report myself!")
            return ""

        if chat.username and chat.type == Chat.SUPERGROUP:

            reported = f"Reported {mention_html(reported_user.id, reported_user.first_name)} to the admins!"

            msg = (
                f"<b>Report from: </b>{html.escape(chat.title)}\n"
                f"<b> × Report by:</b> {mention_html(user.id, user.first_name)}(<code>{user.id}</code>)\n"
                f"<b> × Reported user:</b> {mention_html(reported_user.id, reported_user.first_name)} (<code>{reported_user.id}</code>)\n"
            )
            link = f'<b> × Reported message:</b> <a href="https://t.me/{chat.username}/{message.reply_to_message.message_id}">click here</a>'
            should_forward = False
            keyboard = [
                [
                    InlineKeyboardButton(
                        "💬 Message",
                        url=
                        f"https://t.me/{chat.username}/{message.reply_to_message.message_id}",
                    ),
                    InlineKeyboardButton(
                        "⚽ Kick",
                        callback_data=
                        f"report_{chat.id}=kick={reported_user.id}={reported_user.first_name}",
                    ),
                ],
                [
                    InlineKeyboardButton(
                        "⛔️ Ban",
                        callback_data=
                        f"report_{chat.id}=banned={reported_user.id}={reported_user.first_name}",
                    ),
                    InlineKeyboardButton(
                        "❎ Delete Message",
                        callback_data=
                        f"report_{chat.id}=delete={reported_user.id}={message.reply_to_message.message_id}",
                    ),
                ],
            ]
            reply_markup = InlineKeyboardMarkup(keyboard)
        else:
            reported = f"Reported {mention_html(reported_user.id, reported_user.first_name)} to the admins!"

            msg = f'{mention_html(user.id, user.first_name)} is calling for admins in "{html.escape(chat_name)}"!'
            link = ""
            reply_markup = None
            should_forward = True

        for admin in admin_list:
            if admin.user.is_bot:  # can't message bots
                continue

            if sql.user_should_report(admin.user.id):
                try:
                    context.bot.send_message(
                        admin.user.id,
                        msg + link,
                        reply_markup=reply_markup,
                        parse_mode=ParseMode.HTML,
                    )
                    if should_forward:
                        message.reply_to_message.forward(admin.user.id)

                        if (
                                len(message.text.split()) > 1
                        ):  # If user is giving a reason, send his message too
                            message.forward(admin.user.id)

                except Unauthorized:
                    pass
                except BadRequest as excp:  # TODO: cleanup exceptions
                    if excp.message == "Message_id_invalid":
                        pass
                    else:
                        LOGGER.exception("Exception while reporting user " +
                                         excp.message)

        message.reply_to_message.reply_text(reported,
                                            parse_mode=ParseMode.HTML)
        return msg

    return ""
示例#26
0
def __user_settings__(user_id):
    return "You receive reports from chats you're admin in: `{}`.\nToggle this with /reports in PM.".format(
        sql.user_should_report(user_id))
示例#27
0
def report(update: Update, context: CallbackContext) -> str:
    # sourcery no-metrics
    global reply_markup
    bot = context.bot
    args = context.args
    message = update.effective_message
    chat = update.effective_chat
    user = update.effective_user

    log_setting = logsql.get_chat_setting(chat.id)
    if not log_setting:
        logsql.set_chat_setting(
            logsql.LogChannelSettings(chat.id, True, True, True, True, True))
        log_setting = logsql.get_chat_setting(chat.id)

    if message.sender_chat:
        admin_list = bot.getChatAdministrators(chat.id)
        reported = "Reported to admins."
        for admin in admin_list:
            if admin.user.is_bot:  # AI didnt take over yet
                continue
            try:
                reported += f"<a href=\"tg://user?id={admin.user.id}\">\u2063</a>"
            except BadRequest:
                log.exception("Exception while reporting user")
        message.reply_text(reported, parse_mode=ParseMode.HTML)

    if chat and message.reply_to_message and sql.chat_should_report(chat.id):
        reported_user = message.reply_to_message.from_user
        chat_name = chat.title or chat.username
        admin_list = chat.get_administrators()
        message = update.effective_message

        if not args:
            message.reply_text("Add a reason for reporting first.")
            return ""

        if user.id == reported_user.id:
            message.reply_text("Uh yeah, Sure sure...maso much?")
            return ""

        if user.id == bot.id:
            message.reply_text("Nice try.")
            return ""

        if reported_user.id in REPORT_IMMUNE_USERS:
            message.reply_text("Uh? You reporting a nation?")
            return ""

        if chat.username and chat.type == Chat.SUPERGROUP:

            reported = f"{mention_html(user.id, user.first_name)} reported {mention_html(reported_user.id, reported_user.first_name)} to the admins!"

            msg = (
                f"<b>⚠️ Report: </b>{html.escape(chat.title)}\n"
                f"<b> • Report by:</b> {mention_html(user.id, user.first_name)}(<code>{user.id}</code>)\n"
                f"<b> • Reported user:</b> {mention_html(reported_user.id, reported_user.first_name)} (<code>{reported_user.id}</code>)\n"
            )
            link = f'<b> • Reported message:</b> <a href="https://t.me/{chat.username}/{message.reply_to_message.message_id}">click here</a>'
            should_forward = False
            keyboard = [
                [
                    InlineKeyboardButton(
                        "➡ Message",
                        url=
                        f"https://t.me/{chat.username}/{message.reply_to_message.message_id}",
                    )
                ],
                [
                    InlineKeyboardButton(
                        "⚠ Kick",
                        callback_data=
                        f"report_{chat.id}=kick={reported_user.id}={reported_user.first_name}",
                    ),
                    InlineKeyboardButton(
                        "⛔️ Ban",
                        callback_data=
                        f"report_{chat.id}=banned={reported_user.id}={reported_user.first_name}",
                    ),
                ],
                [
                    InlineKeyboardButton(
                        "❎ Delete Message",
                        callback_data=
                        f"report_{chat.id}=delete={reported_user.id}={message.reply_to_message.message_id}",
                    )
                ],
            ]
            reply_markup = InlineKeyboardMarkup(keyboard)
        else:
            reported = (
                f"{mention_html(user.id, user.first_name)} reported "
                f"{mention_html(reported_user.id, reported_user.first_name)} to the admins!"
            )

            msg = f'{mention_html(user.id, user.first_name)} is calling for admins in "{html.escape(chat_name)}"!'
            link = ""
            should_forward = True

        for admin in admin_list:
            if admin.user.is_bot:  # can't message bots
                continue

            if sql.user_should_report(admin.user.id):
                try:
                    if chat.type != Chat.SUPERGROUP:
                        bot.send_message(admin.user.id,
                                         msg + link,
                                         parse_mode=ParseMode.HTML)

                        if should_forward:
                            message.reply_to_message.forward(admin.user.id)

                            if (
                                    len(message.text.split()) > 1
                            ):  # If user is giving a reason, send his message too
                                message.forward(admin.user.id)
                    if not chat.username:
                        bot.send_message(admin.user.id,
                                         msg + link,
                                         parse_mode=ParseMode.HTML)

                        if should_forward:
                            message.reply_to_message.forward(admin.user.id)

                            if (
                                    len(message.text.split()) > 1
                            ):  # If user is giving a reason, send his message too
                                message.forward(admin.user.id)

                    if chat.username and chat.type == Chat.SUPERGROUP:
                        bot.send_message(
                            admin.user.id,
                            msg + link,
                            parse_mode=ParseMode.HTML,
                            reply_markup=reply_markup,
                        )

                        if should_forward:
                            message.reply_to_message.forward(admin.user.id)

                            if (
                                    len(message.text.split()) > 1
                            ):  # If user is giving a reason, send his message too
                                message.forward(admin.user.id)

                except Unauthorized:
                    pass
                except BadRequest as excp:  # TODO: cleanup exceptions
                    log.exception(
                        "Exception while reporting user\n{}".format(excp))

        try:
            update.effective_message.reply_sticker(
                "CAACAgUAAx0CRSKHWwABAXGoYB2UJauytkH4RJWSStz9DTlxQg0AAlcHAAKAUF41_sNx9Y1z2DQeBA"
            )
        except:
            pass
        message.reply_to_message.reply_text(
            reported,
            parse_mode=ParseMode.HTML,
        )
        if not log_setting.log_report:
            return ""
        return msg

    return ""
示例#28
0
def report(update: Update, context: CallbackContext) -> str:
    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]

    if chat and sql.chat_should_report(chat.id):
        user_id, reason = extract_user_and_text(message, args)
        chat_name = chat.title or chat.first or chat.username

        if message.reply_to_message:
            reported_user = message.reply_to_message.from_user  # type: Optional[User]
        elif user_id:
            reported_user = bot.getChatMember(
                chat.id, user_id).user  # type: Optional[User]
        else:
            message.reply_text("I can't guess the person you want to report.")
            return ("<b>{}:</b>"
                    "\n#REPORTED_FAILED"
                    "\n<b>Reporter:</b> {} (<code>{}</code>)".format(
                        html.escape(chat_name),
                        mention_html(user.id, user.first_name),
                        user.id,
                    ))

        if reported_user.id == bot.id:
            message.reply_text("Haha nope, not gonna report myself.")
            return ""

        log = ("<b>{}:</b>"
               "\n#REPORTED"
               "\n<b>Reporter:</b> {}"
               "\n<b>Whom:</b> {} (<code>{}</code>)".format(
                   html.escape(chat_name),
                   mention_html(user.id, user.first_name),
                   mention_html(reported_user.id, reported_user.first_name),
                   reported_user.id,
               ))
        if reason:
            log += "\n<b>Reason:</b> {}".format(reason)

        admin_msg = log
        if chat.type == chat.SUPERGROUP and chat.username:
            admin_msg += (
                "\n<b>Link:</b> " +
                '<a href="http://telegram.me/{}/{}">click here</a>'.format(
                    chat.username, message.message_id))

        for admin in chat.get_administrators():
            if admin.user.is_bot:  # can't message bots
                continue
            if admin.user.id == user.id:  # don't have to get notifications
                continue
            if admin.user.id == reported_user.id:  # don't have to get notifications
                continue
            if sql.user_should_report(admin.user.id):
                try:
                    bot.send_message(admin.user.id,
                                     admin_msg,
                                     parse_mode=ParseMode.HTML)
                except Unauthorized:
                    pass
                except BadRequest:  # TODO: cleanup exceptions
                    LOGGER.exception("Exception while reporting user")

        message.reply_text(
            "Successfully reported " +
            '<a href="tg://user?id={id}">{name}</a> (<code>{id}</code>)!'.
            format(
                id=reported_user.id,
                name=reported_user.first_name,
            ),
            parse_mode=ParseMode.HTML,
        )

        return log

    return ""
示例#29
0
def __user_settings__(user_id):
    return "Admin olduğun qruplardan bildiriş ala bilirsən(/report və @admin): `{}`.\nToggle this with /reports in PM.".format(
        sql.user_should_report(user_id))
示例#30
0
def report(update: Update, context: CallbackContext) -> str:
    bot = context.bot
    args = context.args
    message = update.effective_message
    chat = update.effective_chat
    user = update.effective_user

    if chat and message.reply_to_message and sql.chat_should_report(chat.id):
        reported_user = message.reply_to_message.from_user
        chat_name = chat.title or chat.first or chat.username
        admin_list = chat.get_administrators()
        message = update.effective_message

        if not args:
            message.reply_text("Add a reason for reporting first.")
            return ""

        if user.id == reported_user.id:
            message.reply_text("Uh yeah, Sure sure...maso much?")
            return ""

        if user.id == bot.id:
            message.reply_text("Nice try.")
            return ""

        if reported_user.id in REPORT_IMMUNE_USERS:
            message.reply_text("Uh? You reporting whitelisted users?")
            return ""

        if chat.username and chat.type == Chat.SUPERGROUP:

            reported = f"{mention_html(user.id, user.first_name)} reported {mention_html(reported_user.id, reported_user.first_name)} to the admins!"

            msg = (
                f"<b>⚠️ Report: </b>{html.escape(chat.title)}\n"
                f"<b> • Report by:</b> {mention_html(user.id, user.first_name)}(<code>{user.id}</code>)\n"
                f"<b> • Reported user:</b> {mention_html(reported_user.id, reported_user.first_name)} (<code>{reported_user.id}</code>)\n"
            )
            link = f'<b> • Reported message:</b> <a href="https://t.me/{chat.username}/{message.reply_to_message.message_id}">click here</a>'
            should_forward = False
            keyboard = [
                [
                    InlineKeyboardButton(
                        u"➡ Message",
                        url=
                        f"https://t.me/{chat.username}/{message.reply_to_message.message_id}"
                    )
                ],
                [
                    InlineKeyboardButton(
                        u"⚠ Kick",
                        callback_data=
                        f"report_{chat.id}=kick={reported_user.id}={reported_user.first_name}"
                    ),
                    InlineKeyboardButton(
                        u"⛔️ Ban",
                        callback_data=
                        f"report_{chat.id}=banned={reported_user.id}={reported_user.first_name}"
                    )
                ],
                [
                    InlineKeyboardButton(
                        u"❎ Delete Message",
                        callback_data=
                        f"report_{chat.id}=delete={reported_user.id}={message.reply_to_message.message_id}"
                    )
                ]
            ]
            reply_markup = InlineKeyboardMarkup(keyboard)
        else:
            reported = f"{mention_html(user.id, user.first_name)} reported " \
                       f"{mention_html(reported_user.id, reported_user.first_name)} to the admins!"

            msg = f'{mention_html(user.id, user.first_name)} is calling for admins in "{html.escape(chat_name)}"!'
            link = ""
            should_forward = True

        for admin in admin_list:
            if admin.user.is_bot:  # can't message bots
                continue

            if sql.user_should_report(admin.user.id):
                try:
                    if not chat.type == Chat.SUPERGROUP:
                        bot.send_message(admin.user.id,
                                         msg + link,
                                         parse_mode=ParseMode.HTML)

                        if should_forward:
                            message.reply_to_message.forward(admin.user.id)

                            if len(
                                    message.text.split()
                            ) > 1:  # If user is giving a reason, send his message too
                                message.forward(admin.user.id)
                    if not chat.username:
                        bot.send_message(admin.user.id,
                                         msg + link,
                                         parse_mode=ParseMode.HTML)

                        if should_forward:
                            message.reply_to_message.forward(admin.user.id)

                            if len(
                                    message.text.split()
                            ) > 1:  # If user is giving a reason, send his message too
                                message.forward(admin.user.id)

                    if chat.username and chat.type == Chat.SUPERGROUP:
                        bot.send_message(admin.user.id,
                                         msg + link,
                                         parse_mode=ParseMode.HTML,
                                         reply_markup=reply_markup)

                        if should_forward:
                            message.reply_to_message.forward(admin.user.id)

                            if len(
                                    message.text.split()
                            ) > 1:  # If user is giving a reason, send his message too
                                message.forward(admin.user.id)

                except Unauthorized:
                    pass
                except BadRequest as excp:  # TODO: cleanup exceptions
                    LOGGER.exception("Exception while reporting user")

        message.reply_to_message.reply_text(
            f"{mention_html(user.id, user.first_name)} reported the message to the admins.",
            parse_mode=ParseMode.HTML)
        return msg

    return ""