WhiskeySockets / BaileysCSharp

Lightweight full-featured C# WhatsApp Web API
72 stars 25 forks source link

MEssage Util ExtractMessageContent #11

Open viniciusverasdossantos opened 7 months ago

viniciusverasdossantos commented 7 months ago

Message Util ExtractMessageContent

I need the ExtractMessageContent method. I tried to port the code to typescrypt but I was unable to evolve. I believe there is little missing. Can you help me finish?

public static Message ExtractMessageContent(Message content) { Message extractFromTemplateMessage(Message msg) { if (msg.ImageMessage!=null) return new Message() { ImageMessage = msg.ImageMessage }; else if (msg.DocumentMessage != null) return new Message() { DocumentMessage = msg.DocumentMessage }; else if (msg.VideoMessage!=null) return new Message() { VideoMessage = msg.VideoMessage };
else if (msg.LocationMessage!=null) return new Message() { LocationMessage = msg.LocationMessage };
else { //Todo: return new Message(){};
} } content = NormalizeMessageContent(content); if (content?.ButtonsMessage!=null) return extractFromTemplateMessage(content.ButtonsMessage); if (content?.TemplateMessage?.HydratedFourRowTemplate != null) return extractFromTemplateMessage(content.ButtonsMessage); if (content?.TemplateMessage?.HydratedFourRowTemplate!=null) return extractFromTemplateMessage(content?.TemplateMessage?.HydratedFourRowTemplate);
if (content?.TemplateMessage?.HydratedTemplate != null) return extractFromTemplateMessage(content?.TemplateMessage?.HydratedTemplate);
if (content?.TemplateMessage?.FourRowTemplate != null) return extractFromTemplateMessage(content?.TemplateMessage?.FourRowTemplate);
return content; }

donaldjansen commented 7 months ago

I have added this to my TODOs

renerlemes commented 2 weeks ago

@viniciusverasdossantos se precisar de ajudar pra melhorar essa lib, tem meus dados de contato no meu perfil aqui do GitHub.