Create implicit convertation between ChatId and Update
I would like to request/propose a feature
So usually i do stuff like that to send response
public async Task Reply(TelegramBotClient client, Update hook)
{
await client.SendTextMessageAsync(
hook.Message.Chat.Id, "Hello World");
}
But I think it will be good to send message without hardcode chat id position because sometimes it can vary by message type, so i create extension method to retrieve ChatId from hook, but i think its better to have implicit convertion between Update and ChatId so i can use method like this:
public async Task Reply(TelegramBotClient client, Update hook)
{
await client.SendTextMessageAsync(
hook, "Hello World");
}
UPDT: or extension method That's great. Let us know what's on on your mind and please try to be specific.
Main issue what you wanna do in case where update doesn`t have any chatId/FromId.
My suggestion - add extension methods:
User? GetUser(this Update update);
Chat? GetChat(this Update update);
Which will return corresponding objects if they exist (or sender != anonymous user) after that you can easily implement methods that you need with Reply if chat exists and handle situation when there is none.
Additionally those methods useful while logging/user authorization, etc.