Last active
June 8, 2019 21:38
-
-
Save MihaZupan/fc55672e78091b2e5f21da311ff5c7d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public long GetBucket(Update update) | |
{ | |
if (update.Message is Message message) | |
return message.Chat.Id; | |
if (update.ChosenInlineResult is ChosenInlineResult chosenInlineResult) | |
return chosenInlineResult.From.Id; | |
if (update.InlineQuery is InlineQuery inlineQuery) | |
return inlineQuery.From.Id; | |
if (update.CallbackQuery is CallbackQuery callbackQuery) | |
return callbackQuery.Message?.Chat.Id ?? callbackQuery.From.Id; | |
if (update.ChannelPost is Message channelPost) | |
return channelPost.Chat.Id; | |
if (update.EditedMessage is Message editedMessage) | |
return editedMessage.Chat.Id; | |
if (update.EditedChannelPost is Message editedChannelPost) | |
return editedChannelPost.Chat.Id; | |
if (update.PreCheckoutQuery is PreCheckoutQuery preCheckoutQuery) | |
return preCheckoutQuery.From.Id; | |
if (update.ShippingQuery is ShippingQuery shippingQuery) | |
return shippingQuery.From.Id; | |
// Left-over: polls | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment