Esempio n. 1
0
        public async Task GoNextAboutStep(UserWrapper user)
        {
            if (user.LastCallBackQuery == null)
            {
                return;
            }

            var propName = user.LastCallBackQuery.Data.Replace(InlinePrefixKeys.AboutKey + "Edit", "");

            if (user.WaitingMessageQuery == null || user.WaitingMessageQuery != nameof(GoNextAboutStep))
            {
                user.WaitingMessageQuery = nameof(GoNextAboutStep);
                await Bot.EditMessageReplyMarkupAsync(user.LastCallBackQuery.Message.Chat.Id,
                                                      user.LastCallBackQuery.Message.MessageId, KeyboardCollection.CancelInlineKeyboard());

                await AnswerCallbackQueryAsync(user, $"Please enter new {Localization.ResourceManager.GetString(propName)?.ToLower()} and press Enter key.", false, cacheTime : 6000);
            }
            else
            {
                var prop = WebsiteManager.GetType().GetProperties().FirstOrDefault(p => p.Name == propName);
                prop?.SetValue(WebsiteManager, user.LastMessageQuery.Text);
                await Bot.EditMessageTextAsync(user.LastCallBackQuery.Message.Chat.Id, user.LastCallBackQuery.Message.MessageId,
                                               Localization.ResourceManager.GetString(propName) + ": \n\r" + (prop?.GetValue(WebsiteManager) ?? "---"),
                                               ParseMode.Default, false, (IReplyMarkup)KeyboardCollection.GetType().GetProperties().FirstOrDefault(p => p.Name.StartsWith(propName))?.GetValue(KeyboardCollection));

                user.WaitingMessageQuery = null; // waiting method called and then clear buffer
            }
        }