GetMessage Content Caption
KomodoCrypto opened this issue · 2 comments
KomodoCrypto commented
I am properly getting a list of the messages of a chat as,
var chatMessages = await _client.ExecuteAsync(new TdApi.GetChatHistory
{
ChatId = chatId,
Limit = limit,
FromMessageId = fromMessageId,
});
I can see the desired message content in intellisense as Message.Content.Caption.Text, however, Caption is not accessible. Message type is messagePhoto.
How to get the text caption of a message??
I already tried to get the message from its Id, but throws an exception.
var message = _client.Execute(new TdApi.GetMessage
{
ChatId = chatId,
MessageId = messageId,
});
ForNeVeR commented
Try casting the message content to MessagePhoto
, for example:
var chatMessages = await _client.ExecuteAsync(new TdApi.GetChatHistory
{
ChatId = chatId,
Limit = limit,
FromMessageId = fromMessageId,
});
var message = chatMessages.Messages_?.FirstOrDefault();
var content = message?.Content as TdApi.MessageContent.MessagePhoto;
var caption = content?.Caption;
Would that work?
KomodoCrypto commented
yes, it worked!! Thank you for the quick support.