• Как передавать entities в telebot?

    @maezztro
    import telebot
    from telebot.types import Message, MessageEntity
    
    
    def get_entity_type(etype):
        arr_etype = str(etype).split('.')
        result = arr_etype[1].lower()
        # if etype == "MessageEntityType.TEXT_LINK":
        return result
    
    
    def send_message_entity(message, target, message_thread_id=None):
        
        entities = []
        
        for entity in message.entities:
            if entity.user is not None:
                user = entity.user
            else:
                user = None
            if entity.offset is not None:
                offset = entity.offset
            else:
                offset = None
            if entity.type is not None:
                type_entity = get_entity_type(entity.type)
            else:
                type_entity = None
            if entity.length is not None:
                length = entity.length
            else:
                length = None
            if entity.url is not None:
                url = entity.url
    
            entities.append(MessageEntity(type=type_entity, offset=offset, length=length, url=url, user=user))
            
        
        bot.send_message(chat_id=target, text=message.text, message_thread_id=message_thread_id, entities=entities)
    Ответ написан
    Комментировать