From 0e3016a345462a9bee39a6df518cbad7924b2e60 Mon Sep 17 00:00:00 2001 From: Elepover Date: Mon, 6 Apr 2020 23:18:24 +0800 Subject: [PATCH] dices! (updated NuGet package too) --- pmcenter/BotCommands/InfoCommand.cs | 63 ++++++++++++++++------------- pmcenter/pmcenter.csproj | 2 +- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/pmcenter/BotCommands/InfoCommand.cs b/pmcenter/BotCommands/InfoCommand.cs index 5c54720..4b28c10 100644 --- a/pmcenter/BotCommands/InfoCommand.cs +++ b/pmcenter/BotCommands/InfoCommand.cs @@ -18,80 +18,87 @@ public async Task ExecuteAsync(TelegramBotClient botClient, Update update) { return false; } + var targetMessage = update.Message.ReplyToMessage; var sb = new StringBuilder("ā„¹ *Message Info*\nšŸ“© *Sender*: ["); if (Vars.CurrentConf.UseUsernameInMsgInfo) { - sb.Append(update.Message.ReplyToMessage.ForwardFrom.FirstName); + sb.Append(targetMessage.ForwardFrom.FirstName); sb.Append(" "); - sb.Append(update.Message.ReplyToMessage.ForwardFrom.LastName); + sb.Append(targetMessage.ForwardFrom.LastName); } else { sb.Append("Here"); } sb.Append("](tg://user?id="); - sb.Append(update.Message.ReplyToMessage.ForwardFrom.Id); + sb.Append(targetMessage.ForwardFrom.Id); sb.Append(")\nšŸ‘¤ User ID: `"); - sb.Append(update.Message.ReplyToMessage.ForwardFrom.Id); + sb.Append(targetMessage.ForwardFrom.Id); sb.Append("`\nšŸŒ Language: `"); - sb.Append(update.Message.ReplyToMessage.ForwardFrom.LanguageCode); + sb.Append(targetMessage.ForwardFrom.LanguageCode); sb.Append("`\nāŒš Forward Time: `"); - sb.Append(update.Message.ReplyToMessage.ForwardDate.ToString()); + sb.Append(targetMessage.ForwardDate.ToString()); sb.Append("`\nšŸ†” Message ID: `"); - sb.Append(update.Message.ReplyToMessage.MessageId); + sb.Append(targetMessage.MessageId); sb.Append("`"); sb.Append("\n\nāž• *Additional Info*"); - sb.Append("\nšŸ“¼ Message Type: " + update.Message.ReplyToMessage.Type.ToString()); - if (update.Message.ReplyToMessage.Document != null) + sb.Append("\nšŸ“¼ Message Type: " + targetMessage.Type.ToString()); + if (targetMessage.Document != null) { sb.Append("\nšŸ“› File Name: `"); - sb.Append(update.Message.ReplyToMessage.Document.FileName); + sb.Append(targetMessage.Document.FileName); sb.Append("`\nšŸ“„ File ID: `"); - sb.Append(update.Message.ReplyToMessage.Document.FileId); + sb.Append(targetMessage.Document.FileId); sb.Append("`\nšŸ—œ File Size: `"); - sb.Append(update.Message.ReplyToMessage.Document.FileSize); + sb.Append(targetMessage.Document.FileSize); sb.Append("`\nšŸ“– MIME Type: `"); - sb.Append(update.Message.ReplyToMessage.Document.MimeType); + sb.Append(targetMessage.Document.MimeType); sb.Append("`"); } - else if (update.Message.ReplyToMessage.Location != null) + else if (targetMessage.Location != null) { sb.Append("\nšŸŒ Latitude: `"); - sb.Append(update.Message.ReplyToMessage.Location.Latitude); + sb.Append(targetMessage.Location.Latitude); sb.Append("`\nšŸŒ Longitude: `"); - sb.Append(update.Message.ReplyToMessage.Location.Longitude); + sb.Append(targetMessage.Location.Longitude); sb.Append("`"); } - else if (update.Message.ReplyToMessage.Sticker != null) + else if (targetMessage.Sticker != null) { sb.Append("\nšŸ˜¶ Emoji: `"); - sb.Append(update.Message.ReplyToMessage.Sticker.Emoji); + sb.Append(targetMessage.Sticker.Emoji); sb.Append("`\nšŸ“„ File ID: `"); - sb.Append(update.Message.ReplyToMessage.Sticker.FileId); + sb.Append(targetMessage.Sticker.FileId); sb.Append("`"); } - else if (update.Message.ReplyToMessage.Audio != null) + else if (targetMessage.Audio != null) { sb.Append("\nšŸ“„ File ID: `"); - sb.Append(update.Message.ReplyToMessage.Audio.FileId); + sb.Append(targetMessage.Audio.FileId); sb.Append("`\nšŸ—œ File Size: `"); - sb.Append(update.Message.ReplyToMessage.Audio.FileSize); + sb.Append(targetMessage.Audio.FileSize); sb.Append("`\nšŸ“– MIME Type: `"); - sb.Append(update.Message.ReplyToMessage.Audio.MimeType); + sb.Append(targetMessage.Audio.MimeType); sb.Append("`\nā³ Duration(secs): `"); - sb.Append(update.Message.ReplyToMessage.Audio.Duration); + sb.Append(targetMessage.Audio.Duration); sb.Append("`"); } - else if (update.Message.ReplyToMessage.Photo != null) + else if (targetMessage.Photo != null) { sb.Append("\nšŸ“„ File ID: `"); - sb.Append(update.Message.ReplyToMessage.Photo[0].FileId); + sb.Append(targetMessage.Photo[0].FileId); sb.Append("`\nšŸ—œ File Size: `"); - sb.Append(update.Message.ReplyToMessage.Photo[0].FileSize); + sb.Append(targetMessage.Photo[0].FileSize); sb.Append("`"); } - sb.Append("\n\n_Additional information is available for a limited set of message types, including: Audios, Documents(Files), Locations, Photos and Stickers._"); + else if (targetMessage.Dice != null) + { + sb.Append("\nšŸŽ² Dice: `"); + sb.Append(targetMessage.Dice.Value); + sb.Append("`"); + } + sb.Append("\n\n_Additional information is available for a limited set of message types, including: Audios, Documents(Files), Dices, Locations, Photos and Stickers._"); _ = await botClient.SendTextMessageAsync( update.Message.From.Id, diff --git a/pmcenter/pmcenter.csproj b/pmcenter/pmcenter.csproj index 887903c..8eebe17 100644 --- a/pmcenter/pmcenter.csproj +++ b/pmcenter/pmcenter.csproj @@ -9,7 +9,7 @@ - +