@botsgram_cu · Post #4765 · 14.04.2022 г., 13:30
¿Que puede hacer este bot? @mensajesecretobot Un bot en línea para enviar mensajes secretos a uno o más destinatarios dentro de un grupo Idiomas: Español (Visto en @botsgram_cu) #mensajes
Hashtags
TGINSIGHT SIMILAR POSTS
Изворен канал @pythonotes · Post #397 · 12 ное.
Использование Pydantic сегодня стало нормой, и это правильно. Но иногда на ревью вижу, что используют его не всегда корректно. Например, метод BaseModel.model_dump() по умолчанию не преобразует стандартные типы, такие как datetime, UUID или Decimal, в простой сериализуемый для JSON вид. Тогда пишут кастмоный сериализатор для этих типов чтобы функция json.dump() не падала с ошибкой. import uuid from datetime import datetime from decimal import Decimal from uuid import UUID from pydantic import BaseModel class MyModel(BaseModel): id: UUID date: datetime value: Decimal obj = MyModel( id=uuid.uuid4(), date=datetime.now(), value='1.23' ) print(obj.model_dump()) # не подходит для json.dump # { # 'id': UUID('4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1'), # 'date': datetime.datetime(2025, 12, 12, 12, 12, 12, 111111), # 'value': Decimal('1.23') # } # добавляем свой кастомный сериализатор json.dumps(obj.model_dump(), cls=MySerializer) # { # 'id': '4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1', # 'date': '2025-12-12T12:12:12.111111', # 'value': '1.23' # } В данном случае класс MySerializer обрабатывает datetime, UUID и Decimal. Например так: class MySerializer(json.JSONEncoder): def default(self, o): if isinstance(o, Decimal): return str(o) elif isinstance(o, datetime): return o.isoformat() elif isinstance(o, UUID): return str(o) return super().default(o) Специально для тех, кто всё еще так делает - в этом нет необходимости! Pydantic может это сделать сам, просто нужно добавить параметр mode="json". json.dumps(obj.model_dump(mode="json")) # { # 'id': '4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1', # 'date': '2012-12-12T12:12:12.111111', # 'value': '1.23' # } #pydantic#libs
Пребарај: #mensajes
@botsgram_cu · Post #4765 · 14.04.2022 г., 13:30
¿Que puede hacer este bot? @mensajesecretobot Un bot en línea para enviar mensajes secretos a uno o más destinatarios dentro de un grupo Idiomas: Español (Visto en @botsgram_cu) #mensajes
Hashtags
@botsgram_cu · Post #4026 · 17.06.2021 г., 02:28
¿Que puede hacer este bot? @asamsgbot Este bot le permite enviar mensajes privados en chats públicos, los mensajes solo son visibles para el destinatario y el remitente. Sólo funciona de forma inline. Idiomas: español, inglés, italiano (Visto en @botsgram_cu) #mensajes#grupos
@botsgram_cu · Post #4994 · 05.05.2024 г., 03:05
¿Qué puede hacer este robot? @NoPMsBot es un creador de bots de Telegram de retroalimentación. Puedes crear un bot para organizar comentarios convenientes basados en temas en grupos . Se crea un tema separado en el grupo para cada usuario, gracias al cual puede navegar fácilmente por los diálogos y comunicarse como en un chat privado normal. Idioma: Inglés #bot#mensajes (Visto en @BotsGram_Cu)
@botsgram_cu · Post #4392 · 03.10.2021 г., 00:56
¿Que puede hacer este? @WhatsAppSaveBot Con este Bot puedes guardar textos y compartirlos directamente en WhatsApp. Idiomas: inglés italiano (Visto en @botsgram_cu) #whatsapp#mensajes
@botsgram_cu · Post #4329 · 05.09.2021 г., 11:57
¿Que puede hacer este bot? @tacitmebot Este bot puede ayudarlo a programar mensajes secretos. Idiomas: inglés (Visto en @botsgram_cu) #mensajes#anónimo
@botsgram_cu · Post #3890 · 13.05.2021 г., 03:13
¿Que puede hacer este bot? @mysterious_forwarder_bot Haga que los mensajes sean anónimos y oculte las etiquetas reenviadas. Idiomas: inglés (Visto en @botsgram_cu) #anónimo#mensajes
@botsgram_cu · Post #4661 · 07.02.2022 г., 12:36
¿Que puede hacer este bot? @CommentsBoardBot Con este bot puedes crear, editar y compartir pequeños tableros de comentarios. Idiomas: Inglés (Visto en @botsgram_cu) #mensajes#comentarios
Hashtags
@botsgram_cu · Post #3085 · 24.10.2020 г., 01:56
¿Que puede hacer este bot? @WaTgLink_Bot Un bot gratuito y de código abierto para recibir y enviar mensajes de WhatsApp directamente en Telegram, con soporte multimedia y más funciones. Idiomas: inglés (Visto en @botsgram_cu) #whatsapp#mensajes#telegram
@botsgram_cu · Post #3993 · 08.06.2021 г., 17:35
¿Que puede hacer este bot? @DelAll_XBot Puede eliminar mensajes de sus grupos / canales con filtros especiales Idioma: inglés (Visto en @botsgram_cu) #grupos#canales#herramientas#mensajes
@botsgram_cu · Post #2905 · 16.07.2020 г., 02:55
¿Que puede hacer este bot? @Anti_ServiceBot Este bot elimina cualquier mensaje de servicio en grupos. Idiomas: inglés (visto en @botsgram_cu) #mensajes#telegram#herramientas#grupos
@botsgram_cu · Post #3986 · 07.06.2021 г., 04:40
¿Que puede hacer este bot? @UUBot Crea bots de mensajería privados para que otros usuarios hablen contigo. Idiomas: español, árabe, inglés, ruso, alemán (Visto en @botsgram_cu) #bot#mensajes#programación
Hashtags
@botsgram_cu · Post #3103 · 02.11.2020 г., 18:29
¿Que puede hacer este bot? @Autoforward_Nsbot Este bot puede reenviar mensajes de un canal a otro y agregar el título automáticamente. Idioma: inglés (Visto en @botsgram_cu) #mensajes#publicaciones#canales#herramientas