Ejemplo n.º 1
0
        def log_action(update, context, *args, **kwargs):
            result = func(update, context, *args, **kwargs)
            chat = update.effective_chat  # type: Optional[Chat]
            message = update.effective_message  # type: Optional[Message]
            if result:
                if chat.type == chat.SUPERGROUP and chat.username:
                    result += (
                        "\n<b>Link:</b> "
                        '<a href="http://telegram.me/{}/{}">click here</a>'.
                        format(chat.username, message.message_id))
                log_chat = sql.get_chat_log_channel(chat.id)
                if log_chat:
                    try:
                        send_log(context.bot, log_chat, chat.id, result)
                    except Unauthorized:
                        sql.stop_chat_logging(chat.id)

            elif result == "":
                pass
            else:
                LOGGER.warning(
                    "%s was set as loggable, but had no return statement.",
                    func,
                )

            return result
Ejemplo n.º 2
0
    def send_log(context: CallbackContext, log_chat_id: str, orig_chat_id: str,
                 result: str):
        bot = context.bot
        try:
            bot.send_message(
                log_chat_id,
                result,
                parse_mode=ParseMode.HTML,
                disable_web_page_preview=True,
            )
        except BadRequest as excp:
            if excp.message == "Chat not found":
                bot.send_message(
                    orig_chat_id,
                    "This log channel has been deleted - unsetting.")
                sql.stop_chat_logging(orig_chat_id)
            else:
                LOGGER.warning(excp.message)
                LOGGER.warning(result)
                LOGGER.exception("Could not parse")

                bot.send_message(
                    log_chat_id,
                    result +
                    "\n\nFormatting has been disabled due to an unexpected error.",
                )
Ejemplo n.º 3
0
    def send_log(bot: Bot, log_chat_id: str, orig_chat_id: str, result: str):
        try:
            bot.send_message(log_chat_id, result, parse_mode=ParseMode.HTML)
        except BadRequest as excp:
            if excp.message == "Chat not found":
                bot.send_message(orig_chat_id, "bu günlük kanalı silindi - ayarlanmamış.")
                sql.stop_chat_logging(orig_chat_id)
            else:
                LOGGER.warning(excp.message)
                LOGGER.warning(result)
                LOGGER.exception("Could not parse")

                bot.send_message(log_chat_id, result + "\n\nBiçimlendirme beklenmeyen bir hata nedeniyle devre dışı bırakıldı.")
Ejemplo n.º 4
0
    def send_log(bot: Bot, log_chat_id: str, orig_chat_id: str, result: str):
        try:
            bot.send_message(log_chat_id, result, parse_mode=ParseMode.HTML)
        except BadRequest as excp:
            if excp.message == "Chat not found":
                bot.send_message(orig_chat_id, "이 로그 채널이 삭제되었어요 - 설정되지 않음")
                sql.stop_chat_logging(orig_chat_id)
            else:
                LOGGER.warning(excp.message)
                LOGGER.warning(result)
                LOGGER.exception("Could not parse")

                bot.send_message(log_chat_id,
                                 result + "\n\n예기치 않은 오류로 인해 포맷이 비활성화되었어요.")
Ejemplo n.º 5
0
    def send_log(bot: Bot, log_chat_id: str, orig_chat_id: str, result: str):
        try:
            bot.send_message(log_chat_id, result, parse_mode=ParseMode.HTML)
        except BadRequest as excp:
            if excp.message == "චැට් හමු නොවීය":
                bot.send_message(orig_chat_id,
                                 "මෙම ලොග් නාලිකාව මකා දමා ඇත - සැකසීම.")
                sql.stop_chat_logging(orig_chat_id)
            else:
                LOGGER.warning(excp.message)
                LOGGER.warning(result)
                LOGGER.exception("Could not parse")

                bot.send_message(
                    log_chat_id, result +
                    "\n\nඅනපේක්ෂිත දෝෂයක් හේතුවෙන් ආකෘතිකරණය අක්‍රීය කර ඇත.")
Ejemplo n.º 6
0
    def send_log(bot: Bot, log_chat_id: str, orig_chat_id: str, result: str):
        try:
            bot.send_message(log_chat_id, result, parse_mode=ParseMode.HTML)
        except BadRequest as excp:
            if excp.message == "Chat not found":
                bot.send_message(orig_chat_id,
                                 "ارتباطم قطع شد . خواهشا دوباره وصلم کن!")
                sql.stop_chat_logging(orig_chat_id)
            else:
                LOGGER.warning(excp.message)
                LOGGER.warning(result)
                LOGGER.exception("Could not parse")

                bot.send_message(
                    log_chat_id,
                    result + "\n\nپاکسازی به علت یه خطای غیر منتظه متوقف شد.")
Ejemplo n.º 7
0
    def send_log(bot: Bot, log_chat_id: str, orig_chat_id: str, result: str):
        try:
            bot.send_message(log_chat_id, result, parse_mode=ParseMode.HTML)
        except BadRequest as excp:
            if excp.message == "Chat not found":
                bot.send_message(orig_chat_id,
                                 "Bu günlük kanalı silindi - ayarlanmıyor.")
                sql.stop_chat_logging(orig_chat_id)
            else:
                LOGGER.warning(excp.message)
                LOGGER.warning(result)
                LOGGER.exception("Could not parse")

                bot.send_message(
                    log_chat_id, result +
                    "\n\nFormatting has been disabled due to an unexpected error."
                )
Ejemplo n.º 8
0
    def send_log(bot: Bot, log_chat_id: str, orig_chat_id: str, result: str):
        try:
            bot.send_message(log_chat_id, result, parse_mode=ParseMode.HTML)
        except BadRequest as excp:
            if excp.message == "Chat not found":
                bot.send_message(
                    orig_chat_id,
                    "Questo logchannel è stato cancellato - disattivamento.")
                sql.stop_chat_logging(orig_chat_id)
            else:
                LOGGER.warning(excp.message)
                LOGGER.warning(result)
                LOGGER.exception("Could not parse")

                bot.send_message(
                    log_chat_id, result +
                    "\n\nFormattazione disattivata a causa di un errore sconosciuto."
                )
Ejemplo n.º 9
0
    def send_log(bot: Bot, log_chat_id: str, orig_chat_id: str, result: str):
        try:
            bot.send_message(log_chat_id, result, parse_mode=ParseMode.HTML)
        except BadRequest as excp:
            if excp.message == "Chat not found":
                bot.send_message(
                    orig_chat_id,
                    "Ten log channel został usunięty - unsetting.")
                sql.stop_chat_logging(orig_chat_id)
            else:
                LOGGER.warning(excp.message)
                LOGGER.warning(result)
                LOGGER.exception("Could not parse")

                bot.send_message(
                    log_chat_id, result +
                    "\n\nFormatowanie zostało wyłączone z powodu nieoczekiwanego błędu."
                )
Ejemplo n.º 10
0
    def unsetlog(bot: Bot, update: Update):
        message = update.effective_message  # type: Optional[Message]
        chat = update.effective_chat  # type: Optional[Chat]

        log_channel = sql.stop_chat_logging(chat.id)
        if log_channel:
            bot.send_message(log_channel, "Kanal bağlantısı kaldırıldı {}".format(chat.title))
            message.reply_text("Günlük kanalı ayarlandı.")

        else:
            message.reply_text("Henüz günlük kanalı ayarlanmadı!")
Ejemplo n.º 11
0
    def send_log(bot: Bot, log_chat_id: str, orig_chat_id: str, result: str):
        try:
            bot.send_message(log_chat_id, result, parse_mode=ParseMode.HTML)
        except BadRequest as excp:
            if excp.message == "Chat not found":
                bot.send_message(
                    orig_chat_id,
                    "This log channel has been deleted - unsetting.",
                )
                sql.stop_chat_logging(orig_chat_id)
            else:
                LOGGER.warning(excp.message)
                LOGGER.warning(result)
                LOGGER.exception("Could not parse")

                bot.send_message(
                    log_chat_id,
                    result +
                    "\n\nFormatting has been disabled due to an unexpected error.",
                )
Ejemplo n.º 12
0
    def unsetlog(bot: Bot, update: Update):
        message = update.effective_message  # type: Optional[Message]
        chat = update.effective_chat  # type: Optional[Chat]

        log_channel = sql.stop_chat_logging(chat.id)
        if log_channel:
            bot.send_message(log_channel, "Channel has been unlinked from {}".format(chat.title))
            message.reply_text("Log channel has been un-set.")

        else:
            message.reply_text("No log channel has been set yet!")
Ejemplo n.º 13
0
    def unsetlog(bot: Bot, update: Update):
        message = update.effective_message  # type: Optional[Message]
        chat = update.effective_chat  # type: Optional[Chat]

        log_channel = sql.stop_chat_logging(chat.id)
        if log_channel:
            bot.send_message(log_channel,
                             "کانال با گپ {} لینک شد!".format(chat.title))
            message.reply_text("اتصال ما قطع شد!!")

        else:
            message.reply_text("هنوز کانال اخبار من تنظیم نشده!")
Ejemplo n.º 14
0
    def unsetlog(bot: Bot, update: Update):

        message = update.effective_message
        chat = update.effective_chat

        log_channel = sql.stop_chat_logging(chat.id)
        if log_channel:
            bot.send_message(log_channel, f"Channel has been unlinked from {chat.title}")
            message.reply_text("Log channel has been un-set.")

        else:
            message.reply_text("No log channel has been set yet!")
Ejemplo n.º 15
0
    def unsetlog(bot: Bot, update: Update):
        message = update.effective_message  # type: Optional[Message]
        chat = update.effective_chat  # type: Optional[Chat]

        log_channel = sql.stop_chat_logging(chat.id)
        if log_channel:
            bot.send_message(log_channel,
                             "채널이 {} 에서 연결이 해제되었어요!".format(chat.title))
            message.reply_text("로그 채널이 해제되었어요.")

        else:
            message.reply_text("로그 채널이 아직 설정되지 않았어요!")
Ejemplo n.º 16
0
    def unsetlog(bot: Bot, update: Update):
        message = update.effective_message  # type: Optional[Message]
        chat = update.effective_chat  # type: Optional[Chat]

        log_channel = sql.stop_chat_logging(chat.id)
        if log_channel:
            bot.send_message(log_channel,
                             "Kanał został odpięty od {}".format(chat.title))
            message.reply_text("Log channel został nieustawiony.")

        else:
            message.reply_text("Nie ma żadnego ustawionego log channelu!")
Ejemplo n.º 17
0
    def unsetlog(bot: Bot, update: Update):
        message = update.effective_message  # type: Optional[Message]
        chat = update.effective_chat  # type: Optional[Chat]

        log_channel = sql.stop_chat_logging(chat.id)
        if log_channel:
            bot.send_message(log_channel,
                             "නාලිකාව සම්බන්ධ කර නොමැත {}".format(chat.title))
            message.reply_text("ලොග් නාලිකාව සකසා නොමැත.")

        else:
            message.reply_text("ලොග් නාලිකාවක් තවම සකසා නැත!")
    def unsetlog(bot: Bot, update: Update):
        message = update.effective_message  # type: Optional[Message]
        chat = update.effective_chat  # type: Optional[Chat]

        log_channel = sql.stop_chat_logging(chat.id)
        if log_channel:
            bot.send_message(
                log_channel,
                "Questo canale è stato scollegato da {}".format(chat.title))
            message.reply_text("Log channel è stato disattivato.")

        else:
            message.reply_text("Nessun log-channel è stato ancora collegato!")
Ejemplo n.º 19
0
    def unsetlog(bot: Bot, update: Update):

        message = update.effective_message
        chat = update.effective_chat

        log_channel = sql.stop_chat_logging(chat.id)
        if log_channel:
            bot.send_message(
                log_channel, f"Tautan saluran telah dibatalkan dari {chat.title}"
            )
            message.reply_text("Saluran log telah dilepas.")

        else:
            message.reply_text("Tidak ada saluran log yang telah ditetapkan kamut!")