Esempio n. 1
0
        public AdminControlMessage BuildMessage()
        {
            base.TextMessage = Bold("Список операторов системы:");
            string OperatorsList = "";

            using (MarketBotDbContext db = new MarketBotDbContext())
            {
                var operators = db.Admin.Where(a => a.Enable).Include(a => a.Follower).ToList();

                if (operators != null)
                {
                    int counter = 1;

                    foreach (var op in operators)
                    {
                        OperatorsList += NewLine() + counter.ToString() + ") " + op.Follower.FirstName + " | телефон: " + op.Follower.Telephone +
                                         NewLine() + "Отстранить: /removeoperator" + op.Id.ToString() + NewLine();
                        counter++;
                    }
                }
            }

            base.TextMessage       += OperatorsList + NewLine() + Italic("Оператор системы имеет следующие права доступа: Обрабатывать заказы, Обрабатывать заявки технической поддержки.");
            NewOperatorBtn          = new InlineKeyboardCallbackButton("Создать оператора", BuildCallData("GenerateKey", Bot.AdminModule.AdminBot.ModuleName));
            base.MessageReplyMarkup = new InlineKeyboardMarkup(
                new[] {
                new[]
                {
                    NewOperatorBtn
                },
            });

            return(this);
        }
Esempio n. 2
0
        public BasketPositionListMessage BuildMessage()
        {
            using (MarketBotDbContext db = new MarketBotDbContext())
                Basket = db.Basket.Where(b => b.FollowerId == FollowerId).Include(b => b.Product).GroupBy(b => b.Product).ToList();

            if (Basket != null)
            {
                ProductBtn = new InlineKeyboardCallbackButton[Basket.Count() + 1][];

                int counter = 0;

                foreach (var position in Basket)
                {
                    ProductBtn[counter]    = new InlineKeyboardCallbackButton[1];
                    ProductBtn[counter][0] = new InlineKeyboardCallbackButton((counter + 1).ToString() + ") " + position.ElementAt(0).Product.Name,
                                                                              BuildCallData(Bot.BasketBot.EditBasketProductCmd, Bot.BasketBot.ModuleName, position.ElementAt(0).ProductId));
                    counter++;
                }

                ProductBtn[ProductBtn.Length - 1]    = new InlineKeyboardCallbackButton[1];
                ProductBtn[ProductBtn.Length - 1][0] = BackBtn;
                base.MessageReplyMarkup = new InlineKeyboardMarkup(ProductBtn);
                base.TextMessage        = "Выберите позицию";
            }

            return(this);
        }
Esempio n. 3
0
        public AdminPanelCmdMessage BuildMessage()
        {
            EditProductBtn        = new InlineKeyboardCallbackButton("Изменить товар" + " \ud83d\udd8a", BuildCallData(AdminBot.ProductEditCmd, AdminBot.ModuleName));
            EditCategoryBtn       = new InlineKeyboardCallbackButton("Изменить категорию" + " \ud83d\udd8a", BuildCallData(AdminBot.CategoryEditCmd, AdminBot.ModuleName));
            ContactEditPanelBtn   = new InlineKeyboardCallbackButton("Изменить контактные данные" + " \ud83d\udd8a", BuildCallData(AdminBot.ContactEditCmd, AdminBot.ModuleName));
            NoConfirmOrdersBtn    = new InlineKeyboardCallbackButton("Показать необработанные заказы" + " \ud83d\udcd2", BuildCallData(AdminBot.NoConfirmOrderCmd, AdminBot.ModuleName));
            PaymentsEnableListBtn = new InlineKeyboardCallbackButton("Выбрать доступные методы оплаты" + " \ud83d\udcb0", BuildCallData(AdminBot.PayMethodsListCmd, AdminBot.ModuleName));

            base.TextMessage = Bold("Панель администратора") + NewLine() +
                               "1) Показать текущие остатки /currentstock" + NewLine() +
                               "2) Показать все товары одним сообщением /allprod" + NewLine() +
                               "3) Импорт новых товаров из CSV файла /import" + NewLine() +
                               "4) Экспорт всех заказов в CSV файл /export" + NewLine() +
                               "5) Экспорт истории изменения остатков /stockexport" + NewLine() +
                               "6) Добавить новый товар /newprod" + NewLine() +
                               "7) Создать новую категорию /newcategory" + NewLine() +
                               "8) Выбрать доступные способы оплаты /paymethods" + NewLine() +
                               "9) Статистика /stat" + NewLine() +
                               "10) Список операторов / Добавить нового / Удалить /operators" + NewLine() +
                               "11) Список доступных городов /cities" + NewLine() +
                               "12) Бот рассылает уведомления в ЛС. Что бы выключить нажмите /off , что бы включить нажмите /on";

            SetInlineKeyBoard();
            return(this);
        }
        public BasketPositionEditMessage BuildMessage()
        {
            using (MarketBotDbContext db = new MarketBotDbContext())
            {
                Positions = db.Basket.Where(b => b.FollowerId == FollowerId && b.ProductId == ProductId).Include(b => b.Product).ToList();
                Product   = db.Product.Where(p => p.Id == ProductId).FirstOrDefault();
            }

            if (Positions != null && Positions.Count() > 0)
            {
                base.TextMessage = Positions.FirstOrDefault().Product.Name + " " + Positions.Count() + " шт.";
                AddBtn           = new InlineKeyboardCallbackButton("+", BuildCallData(Bot.BasketBot.AddProductToBasketCmd, Bot.BasketBot.ModuleName, Positions.FirstOrDefault().ProductId));
                RemoveBtn        = new InlineKeyboardCallbackButton("-", BuildCallData(Bot.BasketBot.RemoveProductFromBasketCmd, Bot.BasketBot.ModuleName, Positions.FirstOrDefault().ProductId));
                SetInlineKeyBoard();
            }

            else // Пользователь удалил последнюю еденицу этого товара. Значит теперь его 0 шт.
            {
                base.TextMessage = Product.Name + " 0 шт.";
                AddBtn           = new InlineKeyboardCallbackButton("+", BuildCallData(Bot.BasketBot.AddProductToBasketCmd, Bot.BasketBot.ModuleName, ProductId));
                RemoveBtn        = new InlineKeyboardCallbackButton("-", BuildCallData(Bot.BasketBot.RemoveProductFromBasketCmd, Bot.BasketBot.ModuleName, ProductId));
                SetInlineKeyBoard();
            }

            return(this);
        }
Esempio n. 5
0
        public override BotMessage BuildMsg()
        {
            if (FeedBack == null && FeedBackId > 0)
            {
                FeedBack = FeedbackFunction.GetFeedBack(FeedBackId);
            }

            if (FeedBack != null && FeedBack.Id > 0) // отзыв уже сохранен в базе
            {
                Product          = FeedBack.Product;
                BackBtn          = BuildInlineBtn("Назад", BuildCallData(Bot.OrderBot.CmdBackFeedBackView, Bot.OrderBot.ModuleName, Convert.ToInt32(FeedBack.OrderId), FeedBackId));
                SaveBtn          = BuildInlineBtn("Сохранить", BuildCallData(Bot.OrderBot.CmdSaveFeedBack, Bot.OrderBot.ModuleName, Convert.ToInt32(FeedBack.OrderId), FeedBack.Id), base.DoneEmodji);
                AddCommentBtn    = BuildInlineBtn("Добавить комментарий", BuildCallData(Bot.OrderBot.CmdAddCommentFeedBack, Bot.OrderBot.ModuleName, Convert.ToInt32(FeedBack.OrderId), FeedBack.Id), base.PenEmodji);
                base.TextMessage = base.BlueRhombus + "Название товара:" + Product.Name + NewLine() +
                                   Bold("Оценка:") + FeedBack.RaitingValue + NewLine() +
                                   Bold("Время:") + FeedBack.DateAdd.ToString() + NewLine() +
                                   Bold("Комментарий:") + FeedBack.Text + NewLine();

                base.MessageReplyMarkup = new Telegram.Bot.Types.ReplyMarkups.InlineKeyboardMarkup(
                    new[] {
                    new[]
                    {
                        AddCommentBtn, SaveBtn
                    },
                    new[]
                    {
                        BackBtn
                    },
                });
            }

            if (FeedBack == null && OrderId > 0 && ProductId > 0) //отзыва еще нет
            {
                db          = new MarketBotDbContext();
                Product     = db.Product.Find(ProductId);
                BackBtn     = BuildInlineBtn("Назад", BuildCallData(Bot.OrderBot.CmdBackFeedBackView, Bot.OrderBot.ModuleName, OrderId));
                RaitingBtns = new InlineKeyboardCallbackButton[5];

                RaitingBtns[0] = BuildInlineBtn("1", BuildCallData(Bot.OrderBot.CmdFeedBackRaiting, Bot.OrderBot.ModuleName, OrderId, ProductId, 1), base.StartEmodji);
                RaitingBtns[1] = BuildInlineBtn("2", BuildCallData(Bot.OrderBot.CmdFeedBackRaiting, Bot.OrderBot.ModuleName, OrderId, ProductId, 2), base.StartEmodji);
                RaitingBtns[2] = BuildInlineBtn("3", BuildCallData(Bot.OrderBot.CmdFeedBackRaiting, Bot.OrderBot.ModuleName, OrderId, ProductId, 3), base.StartEmodji);
                RaitingBtns[3] = BuildInlineBtn("4", BuildCallData(Bot.OrderBot.CmdFeedBackRaiting, Bot.OrderBot.ModuleName, OrderId, ProductId, 4), base.StartEmodji);
                RaitingBtns[4] = BuildInlineBtn("5", BuildCallData(Bot.OrderBot.CmdFeedBackRaiting, Bot.OrderBot.ModuleName, OrderId, ProductId, 5), base.StartEmodji);

                base.TextMessage = base.BlueRhombus + "Название товара:" + Product.Name + NewLine() + NewLine()
                                   + Italic("Поставьте оценку от 1 до 5");

                base.MessageReplyMarkup = new Telegram.Bot.Types.ReplyMarkups.InlineKeyboardMarkup(
                    new[] {
                    RaitingBtns,
                    new[]
                    {
                        BackBtn
                    },
                });
                db.Dispose();
            }

            return(this);
        }
        public override BotMessage BuildMsg()
        {
            DbContext = new BotMngmntDbContext();

            var ServiceType = DbContext.ServiceType.Where(s => s.Enable && !s.IsDemo).LastOrDefault();

            if (Bot == null)
            {
                Bot = DbContext.Bot.Where(b => b.Id == BotId).Include(b => b.Service.ServiceType).FirstOrDefault();
            }

            DbContext.Dispose();

            base.TextMessage = "Услуга №" + Bot.Service.Id + NewLine() +
                               Bold("Тариф:") + Bot.Service.ServiceType.Name + NewLine() +
                               Bold("Дата завершения услуги:") + Bot.Service.EndTimeStamp.ToString() + NewLine() +
                               Bold("Бот:") + "@" + Bot.BotName;


            if (!Bot.Service.ServiceType.IsDemo)
            {
                ProlongBtn = BuildInlineBtn("Продлить", BuildCallData(ConnectBot.PaidVersionCmd, ConnectBot.ModuleName, Bot.Id, Convert.ToInt32(Bot.Service.ServiceTypeId)), base.CreditCardEmodji);

                InvoiceViewBtn = BuildInlineBtn("Посмотреть счет", BuildCallData("InvoiceView", ConnectBot.ModuleName, Bot.Id, Convert.ToInt32(Bot.Service.InvoiceId)));
            }
            BuyPaidVersionBtn = BuildInlineBtn("Приобрести платную версию", BuildCallData(ConnectBot.PaidVersionCmd, ConnectBot.ModuleName, Bot.Id, ServiceType.Id), base.CreditCardEmodji);

            BackBtn = BuildInlineBtn("На главную", BuildCallData(MainMenuBot.ToMainMenuCmd, MainMenuBot.ModuleName));

            base.MessageReplyMarkup = SetKeyboard();

            return(this);
        }
Esempio n. 7
0
        /// <summary>
        /// ساخت کیبورد ماتریسی براساس آرایه ورودی و تعداد ستون موردنیاز هر ردیف
        /// </summary>
        /// <param name="textArr">آرایه شامل متن دکمه ها</param>
        /// <param name="columnCount">تعداد ستون موردنیاز در هر ستون</param>
        /// <param name="hasReturnBtn">آیا دکمه بازگشت هم باشد؟</param>
        /// <param name="dataArr">آرایه شامل داده های متناظر دکمه ها</param>
        /// <returns>کیبورد تولید شده</returns>
        public static InlineKeyboardMarkup makeKeyboard(string[] textArr, int columnCount, bool hasReturnBtn, string[] dataArr = null)
        {
            int rowCount = (int)Math.Ceiling((double)textArr.Length / columnCount);

            InlineKeyboardCallbackButton[][] keyboard = new InlineKeyboardCallbackButton[rowCount + (hasReturnBtn ? 1 : 0)][];
            for (int i = 0; i < rowCount; i++)
            {
                if (i == rowCount - 1 && textArr.Length % columnCount != 0)
                {
                    keyboard[i] = new InlineKeyboardCallbackButton[textArr.Length % columnCount];
                }
                else
                {
                    keyboard[i] = new InlineKeyboardCallbackButton[columnCount];
                }
            }
            for (int i = 0; i < textArr.Length; i++)
            {
                keyboard[i / columnCount][i % columnCount] = new InlineKeyboardCallbackButton(textArr[i], (dataArr == null ? (i + 1).ToString() : dataArr[i]));
            }

            if (hasReturnBtn)
            {
                keyboard[rowCount]    = new InlineKeyboardCallbackButton[1];
                keyboard[rowCount][0] = new InlineKeyboardCallbackButton("بازگشت \U000021A9", "0");
            }

            return(new InlineKeyboardMarkup(keyboard));
        }
        public override BotMessage BuildMsg()
        {
            if (Notification != null)
            {
                base.TextMessage = base.GoldRhobmus + "Рассылка №" + Notification.Id.ToString() + NewLine() +
                                   Bold("Дата: ") + Notification.DateAdd.ToString() + NewLine() +
                                   Bold("Текст: ") + Notification.Text;

                RemoveBtn = BuildInlineBtn("Удалить", BuildCallData(NotificationBot.NotificationRemoveCmd, NotificationBot.ModuleName, Notification.Id), base.CrossEmodji);

                SaveAndSendBtn = BuildInlineBtn("Сохранить и отправить", BuildCallData(NotificationBot.NotificationSendCmd, NotificationBot.ModuleName, Notification.Id), base.SenderEmodji);

                base.MessageReplyMarkup = new InlineKeyboardMarkup(
                    new[] {
                    new[]
                    {
                        RemoveBtn
                    },
                    new[]
                    {
                        SaveAndSendBtn
                    }
                });

                return(this);
            }

            else
            {
                return(null);
            }
        }
Esempio n. 9
0
        public CurrencyListMessage BuildMessage()
        {
            using (MarketBotDbContext db = new MarketBotDbContext())
            {
                var cur = db.Currency.ToList();

                CurrencyBtns = new InlineKeyboardCallbackButton[cur.Count + 1][];

                int counter = 0;
                foreach (Currency c in cur)
                {
                    CurrencyBtns[counter]    = new InlineKeyboardCallbackButton[1];
                    CurrencyBtns[counter][0] = new InlineKeyboardCallbackButton(c.Name + "-" + c.ShortName, BuildCallData("UpdateProductCurrency", Bot.ProductEditBot.ModuleName, ProductId, c.Id));
                    counter++;
                }

                CurrencyBtns[cur.Count]    = new InlineKeyboardCallbackButton[1];
                CurrencyBtns[cur.Count][0] = BackBtn;

                base.MessageReplyMarkup = new InlineKeyboardMarkup(CurrencyBtns);

                base.TextMessage = "Выберите валюту для цены";

                return(this);
            }
        }
Esempio n. 10
0
        private InlineKeyboardCallbackButton ReturnToCatalogList()
        {
            string data = base.BuildCallData("ReturnToCatalogList", CategoryBot.ModuleName);
            InlineKeyboardCallbackButton button = new InlineKeyboardCallbackButton("\u2934\ufe0f", data);

            return(button);
        }
Esempio n. 11
0
        private InlineKeyboardCallbackButton ViewBasket()
        {
            string data = base.BuildCallData(Bot.BasketBot.ViewBasketCmd, BasketBot.ModuleName);
            InlineKeyboardCallbackButton button = new InlineKeyboardCallbackButton("Посмотреть корзину" + "\u2139\ufe0f", data);

            return(button);
        }
Esempio n. 12
0
        private InlineKeyboardCallbackButton MoreInfoProduct(int ProductId)
        {
            string data = base.BuildCallData(Bot.ProductBot.MoreInfoProductCmd, ProductBot.ModuleName, ProductId);
            InlineKeyboardCallbackButton button = new InlineKeyboardCallbackButton("Подробнее" + " \ud83d\udd24", data);

            return(button);
        }
Esempio n. 13
0
        private InlineKeyboardCallbackButton ListingProduct(int ProductId, string BtnText)
        {
            string data = base.BuildCallData(Bot.ProductBot.GetProductCmd, ProductBot.ModuleName, ProductId);
            InlineKeyboardCallbackButton button = new InlineKeyboardCallbackButton(BtnText, data);

            return(button);
        }
Esempio n. 14
0
        private InlineKeyboardCallbackButton RemoveFromBasket(int ProductId)
        {
            string data = base.BuildCallData(Bot.ProductBot.RemoveFromBasketCmd, ProductBot.ModuleName, ProductId);
            InlineKeyboardCallbackButton button = new InlineKeyboardCallbackButton("-", data);

            return(button);
        }
        public override BotMessage BuildMsg()
        {
            db = new MarketBotDbContext();

            StatusList = db.Status.Where(s => s.Enable).ToList();

            StatusBtns = new InlineKeyboardCallbackButton[StatusList.Count + 1][];

            int counter = 0;

            foreach (Status status in StatusList)
            {
                StatusBtns[counter]    = new InlineKeyboardCallbackButton[1];
                StatusBtns[counter][0] = base.BuildInlineBtn(status.Name,
                                                             BuildCallData(OrderProccesingBot.CmdUpdateOrderStatus, OrderProccesingBot.ModuleName, Order.Id, status.Id));
                counter++;
            }

            StatusBtns[StatusBtns.Length - 1]    = new InlineKeyboardCallbackButton[1];
            StatusBtns[StatusBtns.Length - 1][0] = BackBtn;

            base.TextMessage = base.BlueRhombus + " Изменить статус заказа № " + Order.Number.ToString();

            base.MessageReplyMarkup = new InlineKeyboardMarkup(StatusBtns);

            return(this);
        }
Esempio n. 16
0
        public override BotMessage BuildMsg()
        {
            NextBtn = new InlineKeyboardCallbackButton("Далее", BuildCallData("VerifyUserName",Bot.OrderBot.ModuleName));

            // файл еще не разу не отправлялся. Считываем его из папки 
            if (Configuration!=null && Configuration.UserNameFaqFileId==null || Configuration==null)
            base.MediaFile = new MediaFile
            {
                Caption = "Для того что бы мы могли связаться с вами, в настройках Телеграм укажите свой ник-нейм. Потом нажмите далее." + NewLine() +
                "См. картинку.",
                FileTo = new FileToSend { Content = Bot.GeneralFunction.ReadFile("UserNameFaq.png"), Filename = "UserNameFaq.png" },

            };

            else // Отрпавляем только Id файла на сервер телеграм
                base.MediaFile = new MediaFile
                {
                    Caption = "Для того что бы мы могли связаться с вами, в настройках Телеграм укажите свой ник-нейм. Потом нажмите далее." + NewLine() +
                    "См. картинку.",
                    FileTo = new FileToSend { FileId=Configuration.UserNameFaqFileId, Filename = "UserNameFaq.png" },

                };

            base.MessageReplyMarkup = new InlineKeyboardMarkup(new[] {
                new[]
                {
                    NextBtn
                }
            });

            return this;
        }
Esempio n. 17
0
        private async Task LoadRandomQuestion(CallbackQuery query, BotData bData, TelegramBotClient client)
        {
            var totalQuestions = bData.Questions.Count();
            var random         = new Random();
            var skipRow        = random.Next(0, totalQuestions - 1);

            while (SkippedRows.Contains(skipRow))
            {
                skipRow = random.Next(0, totalQuestions - 1);
            }
            SkippedRows.Add(skipRow);
            CurrentQuestion = bData.Questions.Include(x => x.Answers).Skip(skipRow).FirstOrDefault();
            var btns = new List <InlineKeyboardCallbackButton>();

            foreach (var answer in CurrentQuestion.Answers)
            {
                var inlineK = new InlineKeyboardCallbackButton(answer.Text, answer.Id.ToString());
                btns.Add(inlineK);
            }

            InlineKeyboardButton[][] btnArray = new InlineKeyboardButton[btns.Count][];
            for (int i = 0; i < btns.Count; i++)
            {
                btnArray[i]    = new InlineKeyboardButton[1];
                btnArray[i][0] = btns[i];
            }
            var keyboard = new InlineKeyboardMarkup(btnArray);
            await client.SendTextMessageAsync(query.Message.Chat.Id, CurrentQuestion.Text, ParseMode.Default, false, false, 0, keyboard);
        }
Esempio n. 18
0
        public override BotMessage BuildMsg()
        {
            using (MarketBotDbContext db = new MarketBotDbContext())
            {
                var units = db.Units.ToList();

                UnitsBtn = new InlineKeyboardCallbackButton[(units.Count / 2) + 1][];

                for (int i = 0; i < units.Count / 2; i = i + 1)
                {
                    UnitsBtn[i]    = new InlineKeyboardCallbackButton[2];
                    UnitsBtn[i][0] = new InlineKeyboardCallbackButton(units[i * 2].Name + "- " + units[i * 2].ShortName, BuildCallData("UpdateProductUnit", Bot.ProductEditBot.ModuleName, ProductId, units[i * 2].Id));
                    UnitsBtn[i][1] = new InlineKeyboardCallbackButton(units[(i * 2) + 1].Name + "- " + units[(i * 2) + 1].ShortName, BuildCallData("UpdateProductUnit", Bot.ProductEditBot.ModuleName, ProductId, units[(i * 2) + 1].Id));
                }

                UnitsBtn[UnitsBtn.Length - 1]    = new InlineKeyboardCallbackButton[1];
                UnitsBtn[UnitsBtn.Length - 1][0] = BackBtn;

                base.MessageReplyMarkup = new InlineKeyboardMarkup(UnitsBtn);

                base.TextMessage = "Выберите еденицу измерения";

                return(this);
            }
        }
        public override BotMessage BuildMsg()
        {
            EditProductBtn = InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Редактор" + base.PenEmodji, InlineFind.EditProduct + "|");

            HelpDesktBtn = InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Тех. поддержка" + base.PenEmodji, InlineFind.HelpdDesk + "|");

            EditCategoryBtn = new InlineKeyboardCallbackButton("Изм. категорию" + " \ud83d\udd8a", BuildCallData(CategoryEditBot.CategoryEditorCmd, CategoryEditBot.ModuleName));

            StockViewBtn = BuildInlineBtn("Остатки", BuildCallData("ViewStock", AdminBot.ModuleName), base.Depth2Emodji);

            ViewFollowerBtn = BuildInlineBtn("Пользователи", BuildCallData(AdminBot.ViewFollowerListCmd, AdminBot.ModuleName), base.ManEmodji2);

            ViewOrdersBtn = BuildInlineBtn("Заказы", BuildCallData(AdminBot.ViewOrdersListCmd, AdminBot.ModuleName), base.PackageEmodji);

            ViewPaymentsBtn = InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Платежи" + base.CreditCardEmodji, InlineFind.Payment + "|");

            MoreSettingsBtn = BuildInlineBtn("Доп. настройки", BuildCallData(MoreSettingsBot.MoreSettingsCmd, MoreSettingsBot.ModuleName), base.CogwheelEmodji);

            ControlPanelPage2Btn = BuildInlineBtn(base.Next2Emodji, BuildCallData(AdminBot.AdminPage2Cmd, AdminBot.ModuleName));

            ExportBtn = BuildInlineBtn("Экспорт данных в .xlsx", BuildCallData(AdminBot.ExportViewerCmd, AdminBot.ModuleName), base.NoteBookEmodji);

            base.TextMessage = Bold("Панель администратора") + NewLine() +
                               "1) Добавить новый товар /addprod" + NewLine() +
                               "2) Создать новую категорию /newcategory" + NewLine() +
                               "3) Бот рассылает уведомления в ЛС. Что бы выключить нажмите /off , что бы включить нажмите /on" + NewLine() +
                               "4) Документация /doc ";

            SetInlineKeyBoard();
            return(this);
        }
Esempio n. 20
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="CategoryId">товары какой категории отобразить в этом сообщениее. Если ни чего не предалть, то будет отображать товары самой первой категории</param>
 public ViewAllProductInCategoryMessage(int CategoryId = 0, int PageNumber = 1)
 {
     BackBtn               = new InlineKeyboardCallbackButton("Назад", BuildCallData("BackCategoryList", Bot.CategoryBot.ModuleName));
     this.CategoryId       = CategoryId;
     this.SelectPageNumber = PageNumber;
     this.PageSize         = 5;
 }
 public BasketPositionEditMessage(int FollowerId, int ProductId)
 {
     this.FollowerId = FollowerId;
     this.ProductId  = ProductId;
     BackBtn         = new InlineKeyboardCallbackButton("Назад", BuildCallData(Bot.BasketBot.BackToBasketPositionCmd, Bot.BasketBot.ModuleName, this.FollowerId));
     BackToBasketBtn = new InlineKeyboardCallbackButton("Вернуться в корзину", BuildCallData(Bot.BasketBot.BackToBasketCmd, Bot.BasketBot.ModuleName));
 }
        public AdminProductListMessage BildMessage()
        {
            base.TextMessage = "Выберите товар";

            using (MarketBotDbContext db = new MarketBotDbContext())
                ProductList = db.Product.Where(p => p.CategoryId == CategoryId).ToList();

            if (ProductList != null && ProductList.Count() > 0)
            {
                ProductListBtn = new InlineKeyboardCallbackButton[ProductList.Count() + 1][];

                int counter = 0;

                foreach (Product product in ProductList)
                {
                    ProductListBtn[counter]    = new InlineKeyboardCallbackButton[1];
                    ProductListBtn[counter][0] = new InlineKeyboardCallbackButton(product.Name, BuildCallData(Bot.ProductEditBot.SelectProductCmd, Bot.ProductEditBot.ModuleName, product.Id));
                    counter++;
                }

                ProductListBtn[ProductList.Count()]    = new InlineKeyboardCallbackButton[1];
                ProductListBtn[ProductList.Count()][0] = BackBtn;
            }

            else
            {
                ProductListBtn       = new InlineKeyboardCallbackButton[1][];
                ProductListBtn[0]    = new InlineKeyboardCallbackButton[1];
                ProductListBtn[0][0] = BackBtn;
            }
            base.MessageReplyMarkup = new InlineKeyboardMarkup(ProductListBtn);
            return(this);
        }
Esempio n. 23
0
        public AdminPayMethodsSettings BuildMessage()
        {
            using (MarketBotDbContext db = new MarketBotDbContext())
            {
                var methods = db.PaymentType.ToList();

                MethodsBtns = new InlineKeyboardCallbackButton[methods.Count][];

                base.TextMessage = "Выберите доступые методы оплаты." + NewLine() +
                                   Italic("Должен быть доступен, как минимум один метод оплаты") + NewLine()
                                   + "Вернуться в панель администратора /admin";

                int counter = 0;
                foreach (PaymentType pt in methods)
                {
                    MethodsBtns[counter] = new InlineKeyboardCallbackButton[1];

                    if (pt.Enable == true)
                    {
                        MethodsBtns[counter][0] = new InlineKeyboardCallbackButton(pt.Name + " " + CheckEmodji, BuildCallData(AdminBot.PaymentTypeEnableCmd, AdminBot.ModuleName, pt.Id));
                    }

                    else
                    {
                        MethodsBtns[counter][0] = new InlineKeyboardCallbackButton(pt.Name + " " + UnCheckEmodji, BuildCallData(AdminBot.PaymentTypeEnableCmd, AdminBot.ModuleName, pt.Id));
                    }

                    counter++;
                }

                base.MessageReplyMarkup = new InlineKeyboardMarkup(MethodsBtns);
            }

            return(this);
        }
        public override BotMessage BuildMsg()
        {
            using (MarketBotDbContext db = new MarketBotDbContext())
            {
                OrderProductList = db.OrderProduct.Where(o => o.OrderId == OrderId).Include(o => o.Product).ToList();
                OrderNumber      = db.Orders.Where(o => o.Id == OrderId).FirstOrDefault().Number;
            }

            var group = OrderProductList.GroupBy(p => p.ProductId).ToList(); // групируем по товару

            if (OrderProductList != null)
            {
                PostitionsBtn = new InlineKeyboardCallbackButton[group.Count() + 1][];
                base.BackBtn  = new InlineKeyboardCallbackButton("Назад", BuildCallData("BackToOrder", OrderBot.ModuleName, OrderId));

                int Counter = 0;

                foreach (var product in group)
                {
                    PostitionsBtn[Counter]    = new InlineKeyboardCallbackButton[1];
                    PostitionsBtn[Counter][0] = ProductPosition(product.Key, (Counter + 1).ToString() + ") " + product.FirstOrDefault().Product.Name + " - " + product.Count().ToString() + " шт.");
                    Counter++;
                }
                PostitionsBtn[PostitionsBtn.Length - 1]    = new InlineKeyboardCallbackButton[1];
                PostitionsBtn[PostitionsBtn.Length - 1][0] = BackBtn;
                base.MessageReplyMarkup = new InlineKeyboardMarkup(PostitionsBtn);
                base.TextMessage        = "Изменить содержание заказа " + OrderNumber.ToString();
            }

            return(this);
        }
        public override BotMessage BuildMsg()
        {
            NotificationList = NotificationFunction.NotificationList();

            base.PageSize = 5;

            Pages = base.BuildDataPage <MyTelegramBot.Notification>(NotificationList, base.PageSize);

            CreateNotificationBtn = BuildInlineBtn("Создать рассылку", BuildCallData(NotificationBot.NotificationCreateCmd, NotificationBot.ModuleName));

            MessageReplyMarkup = PageNavigatorKeyboard <MyTelegramBot.Notification>(Pages,
                                                                                    NotificationBot.NotificationViewCmd, NotificationBot.ModuleName, BackToAdminPanelBtn(),
                                                                                    new InlineKeyboardButton[] { CreateNotificationBtn });

            base.TextMessage = "Список рассылок:" + NewLine() + NewLine();

            if (Pages != null && Pages.Count > 0 && Pages.Count >= SelectPageNumber && Pages[SelectPageNumber] != null)
            {
                var page = Pages[SelectPageNumber];

                foreach (var notifi in page)
                {
                    base.TextMessage += "Рассылка №" + notifi.Id.ToString() + " /notifi" + notifi.Id.ToString() + NewLine() +
                                        "Дата:" + notifi.DateAdd.ToString() + NewLine() + NewLine();
                }
            }

            return(this);
        }
        private InlineKeyboardCallbackButton ProductPosition(int PositionId, string BtnText)
        {
            string data = BuildCallData(Bot.OrderPositionBot.GetPositionCmd, Bot.OrderPositionBot.ModuleName, PositionId);
            InlineKeyboardCallbackButton btn = new InlineKeyboardCallbackButton(BtnText, data);

            return(btn);
        }
Esempio n. 27
0
        public static InlineKeyboardButton[][] GetCopy(this InlineKeyboardButton[][] arr)
        {
            InlineKeyboardButton[][] res = new InlineKeyboardButton[arr.Length][];

            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = new InlineKeyboardButton[arr[i].Length];
                for (int j = 0; j < arr[i].Length; j++)
                {
                    var callButt = arr[i][j] as InlineKeyboardCallbackButton;
                    var urlButt  = arr[i][j] as InlineKeyboardUrlButton;

                    if (callButt != null)
                    {
                        res[i][j] = new InlineKeyboardCallbackButton(callButt.Text, callButt.CallbackData);
                    }
                    else
                    {
                        //res[i][j] = new InlineKeyboardUrlButton(callButt.Text, (callButt as InlineKeyboardUrlButton).Url);
                    }
                }
            }

            return(res);
        }
Esempio n. 28
0
        public AdminCategoryFuncMessage BuildMessage()
        {
            using (MarketBotDbContext db = new MarketBotDbContext())
                Category = db.Category.Where(c => c.Id == CategoryId).FirstOrDefault();


            if (Category != null)
            {
                EditCategoryNameBtn = new InlineKeyboardCallbackButton("Изменить название", BuildCallData(Bot.CategoryEditBot.CategoryEditNameCmd, Bot.CategoryEditBot.ModuleName, CategoryId));

                if (Category.Enable)
                {
                    EditCategoryEnableBtn = new InlineKeyboardCallbackButton("Скрыть от пользователя", BuildCallData(Bot.CategoryEditBot.CategoryEditEnableCmd, Bot.CategoryEditBot.ModuleName, CategoryId));
                }

                else
                {
                    EditCategoryEnableBtn = new InlineKeyboardCallbackButton("Показывать пользователям", BuildCallData(Bot.CategoryEditBot.CategoryEditEnableCmd, Bot.CategoryEditBot.ModuleName, CategoryId));
                }

                BackToAdminPanelBtn = new InlineKeyboardCallbackButton("Панель Администратора", BuildCallData(AdminBot.BackToAdminPanelCmd, Bot.AdminModule.AdminBot.ModuleName));

                SetInlineKeyBoard();

                base.TextMessage = Category.Name + " выберите действие";
            }

            return(this);
        }
        public override BotMessage BuildMsg()
        {
            using (MarketBotDbContext db = new MarketBotDbContext())
            {
                var methods = db.PaymentType.Where(p => p.Enable == true).ToList();

                if (methods.Count > 0)
                {
                    PaymentsMethodsListBtns = new InlineKeyboardCallbackButton[methods.Count + 1][];

                    base.TextMessage = "Выберите метод оплаты. " + "\ud83d\udcb3";

                    int counter = 0;

                    foreach (PaymentType pt in methods)
                    {
                        PaymentsMethodsListBtns [counter]    = new InlineKeyboardCallbackButton[1];
                        PaymentsMethodsListBtns [counter][0] = new InlineKeyboardCallbackButton(pt.Name, BuildCallData(OrderBot.SelectPaymentMethodCmd, OrderBot.ModuleName, pt.Id));
                        counter++;
                    }

                    PaymentsMethodsListBtns[methods.Count] = new InlineKeyboardCallbackButton[1];
                    PaymentsMethodsListBtns[counter][0]    = BackBtn;

                    base.MessageReplyMarkup = new InlineKeyboardMarkup(PaymentsMethodsListBtns);

                    return(this);
                }

                else
                {
                    return(null);
                }
            }
        }
Esempio n. 30
0
        public override BotMessage BuildMsg()
        {
            DbContext = new BotMngmntDbContext();

            ServiceTypeList = DbContext.ServiceType.Where(s => s.Enable).ToList();

            DbContext.Dispose();

            BackBtn = base.BuildInlineBtn("Назад", base.BuildCallData("BackToMainMenu", MainMenuBot.ModuleName), base.Previuos2Emodji);

            ServiceTypeBtns = new InlineKeyboardCallbackButton[ServiceTypeList.Count + 2][];

            ServiceTypeBtns[ServiceTypeBtns.Length - 1]    = new InlineKeyboardCallbackButton[1];
            ServiceTypeBtns[ServiceTypeBtns.Length - 1][0] = BackBtn;

            ServiceTypeBtns[ServiceTypeBtns.Length - 2]    = new InlineKeyboardCallbackButton[1];
            ServiceTypeBtns[ServiceTypeBtns.Length - 2][0] = BuildInlineBtn("Серверная версия. 3000 рублей", BuildCallData(ConnectBot.EnterpriseVersionCmd, ConnectBot.ModuleName));

            int count = 0;

            foreach (var service in ServiceTypeList)
            {
                ServiceTypeBtns[count]    = new InlineKeyboardCallbackButton[1];
                ServiceTypeBtns[count][0] = BuildInlineBtn(service.Name, BuildCallData(ConnectBot.SelectServiceTypeCmd, ConnectBot.ModuleName, BotId, service.Id));
                count++;
            }

            base.TextMessage = "Выберите тариф";

            base.MessageReplyMarkup = new InlineKeyboardMarkup(ServiceTypeBtns);

            return(this);
        }