Esempio n. 1
0
        public static void ComposeNmStateModel(NmStoreModel model, FormattedMessage formattedMessage)
        {
            model.NullInspect(nameof(model));
            formattedMessage.NullInspect(nameof(formattedMessage));

            formattedMessage.To?.ForEach(to => { model.To.Add(new ToModel {
                    Email = to.Email, Name = to.Name
                }); });
            formattedMessage.Cc?.ForEach(cc => { model.Cc.Add(new CcModel {
                    Email = cc.Email, Name = cc.Name
                }); });
            formattedMessage.Bcc?.ForEach(bcc => { model.Bcc.Add(new BccModel {
                    Email = bcc.Email, Name = bcc.Name
                }); });
            if (formattedMessage.HasAttachments)
            {
                foreach (var attach in formattedMessage.Attachments)
                {
                    model.File.Add(new FileModel
                    {
                        AttachId     = attach.Id,
                        OriginalName = attach.FileName
                    });
                }
            }
            model.Subject = formattedMessage.Subject;
            if (formattedMessage.Body != null)
            {
                model.Message = GetTextPlainMessage(formattedMessage.Body);
            }
        }
Esempio n. 2
0
        public async Task UpdateMessage(string chatId, int messageId, GetKeyboardState state, FormattedMessage formattedMessage, int page = 0, bool isIgnored = false)
        {
            formattedMessage.NullInspect(nameof(formattedMessage));

            var header           = formattedMessage.Header;
            var keyboard         = _getKeyboardFactory.CreateKeyboard(state, formattedMessage, page, isIgnored);
            var displayedMessage = page == 0
                ? Emoji.CLOSED_EMAIL_ENVELOP + header + $"{Environment.NewLine}{Environment.NewLine}{formattedMessage.Snippet}"
                : Emoji.RED_ARROWED_ENVELOPE + header + $"{Environment.NewLine}{Environment.NewLine}{formattedMessage.DesirableBody[page - 1]}";
            await _telegramMethods.EditMessageText(displayedMessage, chatId, messageId.ToString(), null, ParseMode.Html, null, keyboard);
        }
Esempio n. 3
0
        public void ShowShortMessage(string chatId, FormattedMessage formattedMessage, string access = UserAccess.FULL)
        {
            formattedMessage.NullInspect(nameof(formattedMessage));

            var header   = formattedMessage.Header;
            var message  = Emoji.CLOSED_EMAIL_ENVELOP + header + $"{Environment.NewLine}{Environment.NewLine} {formattedMessage.Snippet}";
            var keyboard = access == UserAccess.FULL
                ? _getKeyboardFactory.CreateKeyboard(GetKeyboardState.Minimized, formattedMessage)
                : _getKeyboardFactory.CreateKeyboard(GetKeyboardState.Notify, formattedMessage);
            var temp = _telegramMethods.SendMessage(chatId, message, ParseMode.Html, false, false, null, keyboard).Result;
        }
Esempio n. 4
0
        public async Task ShowShortMessageAsync(string chatId, FormattedMessage formattedMessage, bool fullAccess = true)
        {
            formattedMessage.NullInspect(nameof(formattedMessage));

            var header   = formattedMessage.Header;
            var message  = Emoji.CLOSED_EMAIL_ENVELOP + header + $"{Environment.NewLine}{Environment.NewLine} {formattedMessage.Snippet}";
            var keyboard = fullAccess
                ? _getKeyboardFactory.CreateKeyboard(GetKeyboardState.Minimized, formattedMessage)
                : _getKeyboardFactory.CreateKeyboard(GetKeyboardState.Notify, formattedMessage);
            await _telegramMethods.SendMessage(chatId, message, ParseMode.Html, false, false, null, keyboard);
        }
Esempio n. 5
0
        public async Task SendAttachmentsListMessage(string chatId, int messageId, FormattedMessage formattedMessage, GetKeyboardState state, int page = 0)
        {
            formattedMessage.NullInspect(nameof(formattedMessage));
            if (!formattedMessage.HasAttachments)
            {
                throw new InvalidOperationException($"{nameof(formattedMessage.HasAttachments)} property must equals true to avoid this exception.");
            }

            var keyboard           = _getKeyboardFactory.CreateKeyboard(state, formattedMessage, page);
            var messageTextBuilder = new StringBuilder($"Files attached to this message:{Environment.NewLine}");

            formattedMessage.Attachments.IndexEach((a, i) =>
            {
                messageTextBuilder.AppendLine($"{i + 1}. {a.FileName}");
            });
            messageTextBuilder.AppendLine();
            messageTextBuilder.Append("Please select a file by number to download it:");
            await _telegramMethods.EditMessageText(messageTextBuilder.ToString(), chatId, messageId.ToString(), null, null, null, keyboard);
        }
Esempio n. 6
0
 protected GetKeyboard(FormattedMessage message)
 {
     message.NullInspect(nameof(message));
     Message = message;
 }