public void Mockup(MessageAudio audio)
        {
            Title.Text    = audio.Audio.GetTitle();
            Subtitle.Text = audio.Audio.GetDuration() + ", " + FileSizeConverter.Convert(4190000);

            Button.SetGlyph(0, MessageContentState.Download);
        }
示例#2
0
        private bool SetAudioTemplate(MessageViewModel message, MessageAudio audio, string title)
        {
            Visibility = Visibility.Visible;

            if (ThumbRoot != null)
            {
                ThumbRoot.Visibility = Visibility.Collapsed;
            }

            TitleLabel.Text   = GetFromLabel(message, title);
            ServiceLabel.Text = Strings.Resources.AttachMusic;
            MessageLabel.Text = string.Empty;

            //var document = documentMedia.Document as TLDocument;
            //if (document != null)
            //{
            //    ServiceLabel.Text = document.Title;
            //}

            if (audio.Caption != null && !string.IsNullOrWhiteSpace(audio.Caption.Text))
            {
                ServiceLabel.Text += ", ";
                MessageLabel.Text += audio.Caption.Text.Replace('\n', ' ');
            }

            return(true);
        }
示例#3
0
        private bool SetAudioTemplate(MessageViewModel message, MessageAudio audio, string title)
        {
            Visibility = Visibility.Visible;

            if (ThumbRoot != null)
            {
                ThumbRoot.Visibility = Visibility.Collapsed;
            }

            TitleLabel.Text = GetFromLabel(message, title);
            //ServiceLabel.Text = Strings.Resources.AttachMusic;
            MessageLabel.Text = string.Empty;


            var performer  = string.IsNullOrEmpty(audio.Audio.Performer) ? null : audio.Audio.Performer;
            var audioTitle = string.IsNullOrEmpty(audio.Audio.Title) ? null : audio.Audio.Title;

            if (performer == null || audioTitle == null)
            {
                ServiceLabel.Text = Strings.Resources.AttachMusic;
            }
            else
            {
                ServiceLabel.Text = $"\uD83C\uDFB5 {performer} - {audioTitle}";
            }

            if (audio.Caption != null && !string.IsNullOrWhiteSpace(audio.Caption.Text))
            {
                ServiceLabel.Text += ", ";
                MessageLabel.Text += audio.Caption.Text.Replace('\n', ' ');
            }

            return(true);
        }
示例#4
0
        private bool SetAudioTemplate(MessageViewModel message, MessageAudio audio, string title)
        {
            Visibility = Visibility.Visible;

            HideThumbnail();

            SetTitle(GetFromLabel(message, title));
            //SetService(Strings.Resources.AttachMusic;
            SetMessage(string.Empty);


            var performer  = string.IsNullOrEmpty(audio.Audio.Performer) ? null : audio.Audio.Performer;
            var audioTitle = string.IsNullOrEmpty(audio.Audio.Title) ? null : audio.Audio.Title;

            if (performer == null || audioTitle == null)
            {
                SetService(Strings.Resources.AttachMusic);
            }
            else
            {
                SetService($"\uD83C\uDFB5 {performer} - {audioTitle}");
            }

            if (audio.Caption != null && !string.IsNullOrWhiteSpace(audio.Caption.Text))
            {
                AppendService(", ");
                AppendMessage(audio.Caption.Text.Replace('\n', ' '));
            }

            return(true);
        }
        public static MessageAudio GetAudio(TelegramBotClient bot, Message mes)
        {
            if (bot == null ||
                mes == null ||
                mes.Type != MessageType.Audio)
            {
                return(null);
            }

            MessageAudio audio = new MessageAudio();

            audio.File = GetFile(bot, mes, mes.Audio.FileId);
            return(audio);
        }
 public static bool UpdateFile(this MessageAudio audio, File file)
 {
     return(audio.Audio.UpdateFile(file));
 }
示例#7
0
 public OutboxMessage(MessageAudio Audio) : this((object)Audio)
 {
     this.Type = OutboxMessageType.Audio;
 }
        private static async void SendOutboxMessageToChat(this TelegramBotClient bot, ChatId chatId, OutboxMessage message)
        {
            if (bot == null ||
                ((chatId == null || chatId?.Identifier == 0) &&
                 string.IsNullOrEmpty(chatId?.Username)))
            {
                throw new ArgumentNullException();
            }

            switch (message.Type)
            {
            //Send Text
            case OutboxMessageType.Text:
                await bot.SendTextMessageAsync(
                    chatId : chatId,
                    text : (string)message.Data,
                    replyMarkup : message.ReplyMarkup,
                    parseMode : message.ParseMode,
                    replyToMessageId : message.ReplyToMessageId);

                break;

            //Send MessagePhoto Entity
            case OutboxMessageType.Photo:
                MessagePhoto photo = (MessagePhoto)message.Data;
                await bot.SendPhotoAsync(
                    chatId : chatId,
                    photo : new InputOnlineFile(photo.File.Stream),
                    caption : photo.Caption,
                    replyToMessageId : message.ReplyToMessageId,
                    parseMode : message.ParseMode);

                break;

            //Send MessageAudio Entity
            case OutboxMessageType.Audio:
                MessageAudio audio = (MessageAudio)message.Data;
                await bot.SendAudioAsync(
                    chatId : chatId,
                    audio : new InputOnlineFile(audio.File.Stream),
                    caption : audio.Caption,
                    replyMarkup : message.ReplyMarkup,
                    replyToMessageId : message.ReplyToMessageId,
                    thumb : audio.Thumb,
                    title : audio.Title,
                    parseMode : message.ParseMode);

                break;

            //Send MessageVoice Entity
            case OutboxMessageType.Voice:
                MessageVoice voice = (MessageVoice)message.Data;
                await bot.SendVoiceAsync(
                    chatId : chatId,
                    voice : new InputOnlineFile(voice.File.Stream),
                    replyMarkup : message.ReplyMarkup,
                    replyToMessageId : message.ReplyToMessageId,
                    caption : voice.Caption,
                    parseMode : message.ParseMode);

                break;

            //ToDo other Types of message!
            default:
                throw new Exception("Не поддерживаемый тип отправки сообщений");
                break;
            }

            //Рекурсивно вызываем отправку вложенных элементов сообщения.
            foreach (var item in message.NestedElements)
            {
                SendOutboxMessageToChat(bot, chatId, item);
            }
        }