Giter VIP home page Giter VIP logo

Comments (2)

jez9999 avatar jez9999 commented on June 5, 2024

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.

karb0f0s avatar karb0f0s commented on June 5, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.