I use Telegram.Bot
and got the ID the following way:
/authenticate
or foo
)private static async Task Main()
{
var botClient = new TelegramBotClient("key");
botClient.OnUpdate += BotClientOnOnUpdate;
Console.ReadKey();
}
private static async void BotClientOnOnUpdate(object? sender, UpdateEventArgs e)
{
var id = e.Update.ChannelPost.Chat.Id;
await botClient.SendTextMessageAsync(new ChatId(id), $"Hello World! Channel ID is {id}");
}
This translates to the getUpdates
method in the plain API, which has an array of Update
which then contains channel_post.chat.id