I am writing an ASP.NET Core web app where I want to display a list of the channels and groups with topics, showing the configured icons/profile photos for each.
The channels are fine and I can use:
await WT.Client.DownloadProfilePhotoAsync(t.Channel, photoOutputStream, false, false);
to download the image for serving.
What I'm struggling with are the - what looks like - custom emojis for the forum topics.
I have tried the following, where t is an instance of my model class for passing to the controller:
var forums = await WT.Client.Channels_GetForumTopics((Channel)subChat.Value);
if (forums != null)
{
t.Topics = forums;
foreach (ForumTopic forum in forums.topics)
{
if (forum.icon_emoji_id != 0)
{
var result = await WT.Client.Messages_GetCustomEmojiDocuments(subChat.Value.ID);
System.Console.WriteLine(result[0].ID);//debug breakpoint
}
}
}
else
{
t.Topics = null;
}
The problem seems to be that Messages_GetCustomEmojiDocuments returns DocumentBase[] and not Document[] thus I can't get any further details about the topic emoji as described here.
Is this approach correct? Can you advise a way I can achieve what I need to do please?
well
WTelegramClientis heavily tight topattern-matching, almost every API in telegram has some inheritance associated with its objects. in your case, when you get anDocumentBaseit can either beTL.DocumentEmptyorTL.Document( also included in the documents) so you can write:you can put an
elsestatement after theif and hard cast yourdocumentBaseto(DocumentEmpty)since there is no other possibilities or you can play it safe and do this:either way you have to access the inner data using
pattern-matching