示例#1
0
        def log_action(bot: Bot, update: Update, *args, **kwargs):
            result = func(bot, update, *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:
                    send_log(bot, log_chat, chat.id, result)
            elif result == "":
                pass
            else:
                LOGGER.warning(
                    "%s was set as loggable, but had no return statement.",
                    func)

            return result
    def log_resource(bot: Bot, update: Update):
        entities = update.effective_message.parse_entities()
        caption_entities = update.effective_message.parse_caption_entities()
        LOGGER.info(entities)
        chat = update.effective_chat  # type: Optional[Chat]
        log_chat = sql.get_chat_log_channel(chat.id)

        url = None
        tags = []

        if log_chat:
            for descriptor, entity in entities.items():
                if descriptor["type"] == MessageEntity.HASHTAG:
                    tags.append(entity)
            if tags:
                tags.sort()

            log_entities_list(bot, chat, entities, log_chat, tags, update)

            log_entities_list(bot, chat, caption_entities, log_chat, tags,
                              update)
示例#3
0
        def log_action(bot: Bot, update: Update, *args, **kwargs):

            result = func(bot, update, *args, **kwargs)
            chat = update.effective_chat
            message = update.effective_message

            if result:
                datetime_fmt = "%H:%M - %d-%m-%Y"
                result += f"\n<b>Event Stamp</b>: <code>{datetime.utcnow().strftime(datetime_fmt)}</code>"

                if message.chat.type == chat.SUPERGROUP and message.chat.username:
                    result += f'\n<b>Link:</b> <a href="https://t.me/{chat.username}/{message.message_id}">click here</a>'
                log_chat = sql.get_chat_log_channel(chat.id)
                if log_chat:
                    send_log(bot, log_chat, chat.id, result)
            elif result == "":
                pass
            else:
                LOGGER.warning("%s was set as loggable, but had no return statement.", func)

            return result
示例#4
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:
                datetime_fmt = "%H:%M - %d-%m-%Y"
                result += f"\n<b>Event Stamp</b>: <code>{datetime.utcnow().strftime(datetime_fmt)}</code>"
                try:
                    if message.chat.type == chat.SUPERGROUP:
                        if message.chat.username:
                            result += f'\n<b>Link:</b> <a href="https://t.me/{chat.username}/{message.message_id}">click here</a>'
                        else:
                            cid = str(chat.id).replace("-100", '')
                            result += f'\n<b>Link:</b> <a href="https://t.me/c/{cid}/{message.message_id}">click here</a>'
                except AttributeError:
                    result += '\n<b>Link:</b> No link for manual actions.'  # or just without the whole line
                log_chat = sql.get_chat_log_channel(chat.id)
                if log_chat:
                    send_log(context, log_chat, chat.id, result)

            return result
        def log_action(bot: Bot, update: Update, *args, **kwargs):
            result = func(bot, update, *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/{}/{}">Fai click qui</a>'.
                        format(chat.username, message.message_id))
                log_chat = sql.get_chat_log_channel(chat.id)
                if log_chat:
                    send_log(bot, log_chat, chat.id, result)
            elif result == "":
                pass
            else:
                LOGGER.warning(
                    "%s è stato impostato come loggable, ma non ha nessun return abilitato.",
                    func,
                )

            return result
示例#6
0
    def log_resource(bot: Bot, update: Update):
        entities = update.effective_message.parse_entities()
        caption_entities = update.effective_message.parse_caption_entities()
        chat = update.effective_chat  # type: Optional[Chat]
        log_chat = sql.get_chat_log_channel(chat.id)
        if log_chat:
            result = f'<b>Risorsa inviata da @{update.effective_user.username}:</b>\n'
            for descriptor, entity in entities.items():
                result = f'<b>Risorsa inviata da @{update.effective_user.username}:</b>\n'
                if descriptor['type'] in ['url', 'text_link']:
                    result += f'{entity}'
                    LOGGER.debug(
                        f"Found message entity: {descriptor['type']} {entity}")
                    send_log(bot, log_chat, chat.id, result)

            for descriptor, entity in caption_entities.items():
                result = '<b>Risorsa inviata da @{update.effective_user.username}:</b>\n'
                if descriptor['type'] in ['url', 'text_link']:
                    result += f'{entity}'
                    LOGGER.debug(
                        f"Found message entity: {descriptor['type']} {entity}")
                    send_log(bot, log_chat, chat.id, result)
        else:
            send_log(bot, log_chat, chat.id, result)
示例#7
0
        def log_action(update: Update,
                       context: CallbackContext,
                       job_queue: JobQueue = None,
                       *args,
                       **kwargs):
            if not job_queue:
                result = func(update, context, *args, **kwargs)
            else:
                result = func(update, context, job_queue, *args, **kwargs)

            chat = update.effective_chat
            message = update.effective_message

            if result:
                datetime_fmt = "%H:%M - %d-%m-%Y"
                result += f"\n<b>Event Stamp</b>: <code>{datetime.utcnow().strftime(datetime_fmt)}</code>"

                if message.chat.type == chat.SUPERGROUP and message.chat.username:
                    result += f'\n<b>Link:</b> <a href="https://t.me/{chat.username}/{message.message_id}">click here</a>'
                log_chat = sql.get_chat_log_channel(chat.id)
                if log_chat:
                    send_log(context, log_chat, chat.id, result)

            return result
示例#8
0
 def __chat_settings__(chat_id, user_id):
     log_channel = sql.get_chat_log_channel(chat_id)
     if log_channel:
         log_channel_info = dispatcher.bot.get_chat(log_channel)
         return f"This group has all it's logs sent to: {escape_markdown(log_channel_info.title)} (`{log_channel}`)"
     return "No log channel is set for this group!"
 def __chat_settings__(chat_id, user_id):
     log_channel = sql.get_chat_log_channel(chat_id)
     if log_channel:
         log_channel_info = dispatcher.bot.get_chat(log_channel)
         return f"Grup ini memiliki semua log yang dikirim ke: {escape_markdown(log_channel_info.title)} (`{log_channel}`)"
     return "Tidak ada saluran log yang disetel untuk grup ini!"