How can I access to a Telegram channel messages with a bot registered as channel admin?
I am trying to get all the messages from Telegram channel and display them in an ASP.NET webpage (c#)
I am able to get updates when new message sent directly to the bot:
var json = wc.DownloadString(" https://api.telegram.org/bot<token>/getUpdates");
but its not working for the channel.
The FAQ reads: All bots, regardless of settings, will receive: All service messages. All messages from private chats with users.
c) On the desktop app's homescreen, click on the three horizontal lines on the top left corner to open the app menu. Once the menu pops up, select "Settings". d) On the screen that shows the 'Settings' options, scroll down to the 'Privacy and Security' option, then select 'Export Telegram Data'.
To use MTProto, you need to login to https://my.telegram.org/ with your existing Telegram account and get credentials: api_id and api_hash . Here is a working example of how to use Telethon python library to get list of Telegram channel/group users. It is easy to search channels/users by name/phone/URL with client.
Creating a client Before you can start interacting with the Telegram API, you need to create a client object with your api_id and api_hash and authenticate it with your phone number. This is similar to logging in to Telegram on a new device; you can imagine this client as just another Telegram app.
unfortunately it's not possible yet.(they may come up with something in future) as admin you can just send messages to channel.
You can receive channel posts and channel post editing.
But you won't receive it in OnMessage
event, you can receive it from OnUpdate
as Message
object like code below:
Note: The bot must be an administrator in the channel.
private static readonly TelegramBotClient Bot = new TelegramBotClient("my-real-token");
public static void Main(string[] args)
{
Bot.StartReceive(UpdateType.ChannelPost, UpdateType.EditedChannelPost);
Bot.OnUpdate += Bot_OnUpdate;
}
public static void OnUpdate(UpdateEventArgs e)
{
if (e.Update.Type == UpdateType.ChannelPost)
{
Message post = e.Update.ChannelPost;
//TODO: Store channel post
}
else if (e.Update.Type == UpdateType.EditedChannelPost)
{
Message editedPost = e.Update.EditedChannelPost;
//TODO: Store edited channel post
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With