/// <summary> /// Удалить город из списка доступных /// </summary> /// <returns></returns> private async Task <IActionResult> RemoveAvailableCity() { try { int id = Convert.ToInt32(CommandName.Substring(RemoveAvailableCityCmd.Length)); MarketBotDbContext db = new MarketBotDbContext(); var city = db.AvailableСities.Where(c => c.Id == id).FirstOrDefault(); if (city != null) { db.AvailableСities.Remove(city); db.SaveChanges(); } db.Dispose(); return(await SendAvailableCities()); } catch { return(OkResult); } }
private async Task <IActionResult> SendHelpDesk() { try { if (HelpDeskId == 0) { HelpNumber = Convert.ToInt32(CommandName.Substring(7)); HelpDesk = HelpDeskFunction.HelpDeskFindByNumber(HelpNumber); } if (HelpDeskId > 0) { HelpDesk = HelpDeskFunction.GetHelpDesk(HelpDeskId); } if (HelpDesk != null) { AdminHelpDeskMessage adminHelpDesk = new AdminHelpDeskMessage(HelpDesk, FollowerId); await SendMessage(adminHelpDesk.BuildMsg()); } return(OkResult); } catch { return(OkResult); } }
public string GetInvocationCommandName() { return(!string.IsNullOrEmpty(CommandNameSpace) ? string.Format("{0}.{1}", CommandNameSpace, CommandName) .Substring(0, CommandNameSpace.Length + CommandName.Length + 1 - "command".Length) .Replace(".", "-").ToLowerInvariant() : CommandName .Substring(0, CommandName.Length - "command".Length) .Replace(".", "-").ToLowerInvariant()); }
private async Task <IActionResult> SendQuestion() { try { int id = Convert.ToInt32(CommandName.Substring(GetQuestionCmd2.Length, CommandName.Length - GetQuestionCmd2.Length)); return(await SendQuestion(id)); } catch { return(OkResult); } }
/// <summary> /// Подтверждение владельца /// </summary> /// <returns></returns> private async Task <IActionResult> OwnerRegister() { //ключ регистрации. string key = CommandName.Substring(OwnerReg.Length); //ключ регистрации это 15 символов из второй части Токена телеграм if (base.BotInfo.OwnerChatId == null && base.BotInfo.Token.Split(':').ElementAt(1).Substring(0, 15) == key) { if (AdminFunction.UpdateOwner(BotInfo.Id, Convert.ToInt32(ChatId)) > 0) { await SendMessage(new BotMessage { TextMessage = "Добро пожаловать! Нажмите сюда /admin" }); } } return(OkResult); }
private async Task <IActionResult> SendQiwiEditor() { MarketBotDbContext db = new MarketBotDbContext(); int id = Convert.ToInt32(CommandName.Substring(PayCgfCmd.Length)); var qiwi = db.PaymentTypeConfig.Find(id); if (qiwi != null) { BotMessage = new AdminQiwiSettingsMessage(qiwi); await SendMessage(BotMessage.BuildMsg()); db.Dispose(); } return(OkResult); }
private async Task <IActionResult> SendHelpDesk() { try { int Number = 0; HelpDesk Help = new HelpDesk(); if (HelpDeskId == 0) { Number = Convert.ToInt32(CommandName.Substring(7)); } using (MarketBotDbContext db = new MarketBotDbContext()) { if (HelpDeskId == 0 && Number > 0) { Help = db.HelpDesk.Where(h => h.Number == Number).Include(h => h.HelpDeskAnswer).Include(h => h.HelpDeskAttachment).Include(h => h.HelpDeskInWork).FirstOrDefault(); } if (HelpDeskId > 0 && Number == 0) { Help = db.HelpDesk.Where(h => h.Id == HelpDeskId).Include(h => h.HelpDeskAnswer).Include(h => h.HelpDeskAttachment).Include(h => h.HelpDeskInWork).FirstOrDefault(); } if (Help != null) { AdminHelpDeskMessage adminHelpDesk = new AdminHelpDeskMessage(Help, FollowerId); await SendMessage(await adminHelpDesk.BuldMessage()); return(OkResult); } return(OkResult); } } catch { return(OkResult); } }
private async Task <IActionResult> SendNotifiDetails() { try { NotifiId = Convert.ToInt32(CommandName.Substring(GetNotificationCmd.Length)); var Notifi = NotificationFunction.GetNotification(NotifiId); if (Notifi != null) { BotMessage = new NotificationDetailsMessage(Notifi); await SendMessage(BotMessage.BuildMsg()); } return(OkResult); } catch { return(OkResult); } }
public async override Task <IActionResult> Response() { if (IsOperator() || IsOwner()) { switch (base.CommandName) { //Панель администратора /admin case "/admin": return(await SendAdminControlPanelMsg()); //Вернуть в Панель администратора case BackToAdminPanelCmd: return(await BackToAdminPanel()); case NoConfirmOrderCmd: return(await NoConfirmOrder()); case "/stockexport": return(await StockExport()); case "/allprod": return(await SendAllProductsView()); case "/currentstock": return(await SendCurrentStock()); case "/on": return(await OnOffPrivateMessage(true)); case "/off": return(await OnOffPrivateMessage(false)); default: break; } } if (IsOwner()) { switch (base.CommandName) { //Пользователь нажал на кнопку "Добавить товар", ему пришло Сообщение с иструкцией по добавлению case "/newprod": return(await SendInsertProductFAQ()); //Пользователь нажал на "Изменить товар", ему пришло сообещние с выбором категории case ProductEditCmd: return(await EditProduct()); //Пользователь нажал на кнопку "Импорт из CSV" ему пришло сообщение с интрукцией case "/import": return(await SendImportFAQ()); case ContactEditCmd: return(await ContactEdit()); case VkEditCmd: return(await ForceReplyBuilder(ForceReplyVk)); case InstagramEditCmd: return(await ForceReplyBuilder(ForceReplyInstagram)); case ChatEditCmd: return(await ForceReplyBuilder(ForceReplyChat)); case ChannelEditCmd: return(await ForceReplyBuilder(ForceReplyChannel)); case "/export": return(await OrderExport()); case PayMethodsListCmd: return(await SendPaymentMethods()); case PaymentTypeEnableCmd: return(await PaymentMethodEnable()); case StatCmd: return(await SendStat()); case "/operators": return(await SendOperatorList()); case "GenerateKey": return(await GenerateKey()); case AddGroup: return(await AddBotToChat()); case "/cities": return(await SendAvailableCities()); case "/newcity": return(await ForceReplyBuilder("Введите название города")); default: break; } if (base.OriginalMessage.Contains("Введите название города")) { return(await AddAvailableCity()); } if (base.CommandName.Contains(RemoveAvailableCityCmd)) { return(await RemoveAvailableCity()); } if (base.OriginalMessage.Contains(ForceReplyVk)) { return(await UpdateVk()); } if (base.OriginalMessage.Contains(ForceReplyInstagram)) { return(await UpdateInstagram()); } if (base.OriginalMessage.Contains(ForceReplyChat)) { return(await UpdateChat()); } if (base.OriginalMessage.Contains(ForceReplyChannel)) { return(await UpdateChannel()); } if (base.CommandName.Contains(RemoveOperatorCmd)) { return(await RemoveOperator()); } else { return(null); } } else { if (base.CommandName.Contains("/key")) { return(await CheckOperatorKey(CommandName.Substring(5))); } else { return(null); } } }