Comments (2)
For reference, here's the extension method I made to correctly identify the message type:
/// <summary>
/// Gets the type of the Telegram message.
/// </summary>
/// <param name="msg">The Telegram message.</param>
/// <returns>The message type, or null if type is unknown.</returns>
public static Telegram.Bot.Types.Enums.MessageType? GetMsgType(this Telegram.Bot.Types.Message msg) {
if (msg.Photo != null) { return Telegram.Bot.Types.Enums.MessageType.Photo; }
if (msg.Audio != null) { return Telegram.Bot.Types.Enums.MessageType.Audio; }
if (msg.Video != null) { return Telegram.Bot.Types.Enums.MessageType.Video; }
if (msg.Voice != null) { return Telegram.Bot.Types.Enums.MessageType.Voice; }
if (msg.Animation != null) { return Telegram.Bot.Types.Enums.MessageType.Animation; }
if (msg.Document != null) { return Telegram.Bot.Types.Enums.MessageType.Document; }
if (msg.Sticker != null) { return Telegram.Bot.Types.Enums.MessageType.Sticker; }
if (msg.Location != null) { return Telegram.Bot.Types.Enums.MessageType.Location; }
if (msg.Venue != null) { return Telegram.Bot.Types.Enums.MessageType.Venue; }
if (msg.Contact != null) { return Telegram.Bot.Types.Enums.MessageType.Contact; }
if (msg.Game != null) { return Telegram.Bot.Types.Enums.MessageType.Game; }
if (msg.VideoNote != null) { return Telegram.Bot.Types.Enums.MessageType.VideoNote; }
if (msg.Invoice != null) { return Telegram.Bot.Types.Enums.MessageType.Invoice; }
if (msg.SuccessfulPayment != null) { return Telegram.Bot.Types.Enums.MessageType.SuccessfulPayment; }
if (msg.ConnectedWebsite != null) { return Telegram.Bot.Types.Enums.MessageType.WebsiteConnected; }
if (msg.NewChatMembers != null && msg.NewChatMembers.Length > 0) { return Telegram.Bot.Types.Enums.MessageType.ChatMembersAdded; }
if (msg.LeftChatMember != null) { return Telegram.Bot.Types.Enums.MessageType.ChatMemberLeft; }
if (msg.NewChatTitle != null) { return Telegram.Bot.Types.Enums.MessageType.ChatTitleChanged; }
if (msg.NewChatPhoto != null) { return Telegram.Bot.Types.Enums.MessageType.ChatPhotoChanged; }
if (msg.PinnedMessage != null) { return Telegram.Bot.Types.Enums.MessageType.MessagePinned; }
if (msg.DeleteChatPhoto ?? false) { return Telegram.Bot.Types.Enums.MessageType.ChatPhotoDeleted; }
if (msg.GroupChatCreated ?? false) { return Telegram.Bot.Types.Enums.MessageType.GroupCreated; }
if (msg.SupergroupChatCreated ?? false) { return Telegram.Bot.Types.Enums.MessageType.SupergroupCreated; }
if (msg.ChannelChatCreated ?? false) { return Telegram.Bot.Types.Enums.MessageType.ChannelCreated; }
if (msg.MigrateToChatId.HasValue) { return Telegram.Bot.Types.Enums.MessageType.MigratedToSupergroup; }
if (msg.MigrateFromChatId.HasValue) { return Telegram.Bot.Types.Enums.MessageType.MigratedFromGroup; }
if (msg.Poll != null) { return Telegram.Bot.Types.Enums.MessageType.Poll; }
if (msg.Dice != null) { return Telegram.Bot.Types.Enums.MessageType.Dice; }
if (msg.MessageAutoDeleteTimerChanged != null) { return Telegram.Bot.Types.Enums.MessageType.MessageAutoDeleteTimerChanged; }
if (msg.ProximityAlertTriggered != null) { return Telegram.Bot.Types.Enums.MessageType.ProximityAlertTriggered; }
if (msg.VideoChatScheduled != null) { return Telegram.Bot.Types.Enums.MessageType.VideoChatScheduled; }
if (msg.VideoChatStarted != null) { return Telegram.Bot.Types.Enums.MessageType.VideoChatStarted; }
if (msg.VideoChatEnded != null) { return Telegram.Bot.Types.Enums.MessageType.VideoChatEnded; }
if (msg.VideoChatParticipantsInvited != null) { return Telegram.Bot.Types.Enums.MessageType.VideoChatParticipantsInvited; }
if (msg.WebAppData != null) { return Telegram.Bot.Types.Enums.MessageType.WebAppData; }
if (msg.ForumTopicCreated != null) { return Telegram.Bot.Types.Enums.MessageType.ForumTopicCreated; }
if (msg.ForumTopicEdited != null) { return Telegram.Bot.Types.Enums.MessageType.ForumTopicEdited; }
if (msg.ForumTopicClosed != null) { return Telegram.Bot.Types.Enums.MessageType.ForumTopicClosed; }
if (msg.ForumTopicReopened != null) { return Telegram.Bot.Types.Enums.MessageType.ForumTopicReopened; }
if (msg.GeneralForumTopicHidden != null) { return Telegram.Bot.Types.Enums.MessageType.GeneralForumTopicHidden; }
if (msg.GeneralForumTopicUnhidden != null) { return Telegram.Bot.Types.Enums.MessageType.GeneralForumTopicUnhidden; }
if (msg.WriteAccessAllowed != null) { return Telegram.Bot.Types.Enums.MessageType.WriteAccessAllowed; }
if (msg.UserShared != null) { return Telegram.Bot.Types.Enums.MessageType.UserShared; }
if (msg.ChatShared != null) { return Telegram.Bot.Types.Enums.MessageType.ChatShared; }
if (msg.Text != null) { return Telegram.Bot.Types.Enums.MessageType.Text; }
return null;
}
from telegram.bot.
I’m closing this issue because it has been inactive for a few months. This probably means that it is not reproducible or it has been fixed in a newer version.
Please reopen if you still encounter this issue with the latest stable version and then please use the issue template.
from telegram.bot.
Related Issues (20)
- Bot API 6.8 (August 18, 2023)
- Missing documentation InputOnlineFile => InputFileUrl HOT 3
- Bot API 6.9 (September 22, 2023)
- Could we have InputMediaBase inherit from IAlbumInputMedia? HOT 3
- Erro não autorizado HOT 2
- Bug Report - Lack of Graceful Shutdown in Message Updates Handling HOT 4
- Replace Newtonsoft.Json with System.Text.Json with proper source generation HOT 10
- Release 19.0.1 HOT 3
- Bot API 7.0 (December 29, 2023)
- Calling MakeRequestAsync with Stream content more then once results in error HOT 2
- Looks like this source generator is completely non incremental HOT 3
- telegram.bot is missing NuGet package README file
- Telegram.Bot.dll PUA classification with ESET problem HOT 5
- Send v20.0.0-alpha.3 to nuget plz HOT 1
- Project is not compatible with net8.0 (.NETCoreApp,Version=v8.0) HOT 7
- System.Text.Json deserialization issue HOT 5
- Temporary alternative NuGet feed due to AV software false positives
- GetStickerSetAsync() fails: Required property 'is_animated' not found in JSON HOT 2
- Required property 'is_animated' not found in JSON HOT 2
- How to resize replymarkup? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telegram.bot.