'Get channel message history and mark views with WTelegramClient
How can I:
- Get a public channel message history [Text,Photo,Video ...]
- Mark these messages as a viewed
With Telethon (python) we can use this method:
for message in client.get_messages(channel, limit=int(count)):
result = client(functions.messages.GetMessagesViewsRequest(peer=channel,id=[message.id],increment=True))
I want a method like this on WTelegramClient in c#
Solution 1:[1]
If I understand correctly, you want to get list of messages (history) from a channel and increment the views counter for each.
?? From the official documentation: If you use the Telegram API for flooding, spamming, faking subscriber and view counters of channels, you will be banned forever.
The equivalent of your code with WTelegramClient would be something like this:
var msgs = await client.Messages_GetHistory(channel, limit: count);
foreach (var message in msgs.Messages)
await client.Messages_GetMessagesViews(channel, new[] { message.ID }, true);
// possible alternate way (single API call):
await client.Messages_GetMessagesViews(channel, msgs.Messages.Select(m => m.ID).ToArray(), true);
see EXAMPLES.md for more thorough examples on fetching chat history.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
