public void ProcessMessage(string messageText, BotUser user) { var httpConstant = "http"; var colonConstant = ":"; if (addingLinkCommandListProvider.GetCommands().Contains(messageText)) { var newUserState = container.Get <RegisterVK>(); peopleParser.ChangeState(user.UserId, UserStates.Register); vkMessageSender.SendNotification(user, new MessageResponse(ResponseType.LinkCancel).response, newUserState.GetKeyboard()); } else if (!messageText.Contains(httpConstant) && !messageText.Contains(colonConstant)) { vkMessageSender.SendNotification(user, new MessageResponse(ResponseType.LinksError).response, GetKeyboard()); } else if (messageText.Contains(httpConstant) && messageText.Contains(colonConstant)) { var splittedMessage = messageText.Split(": "); var name = splittedMessage[0]; var link = splittedMessage[1]; messageHandler.AddLink(user, name, link); var newUserState = container.Get <RegisterVK>(); peopleParser.ChangeState(user.UserId, UserStates.Register); vkMessageSender.SendNotification(user, new MessageResponse(ResponseType.SucessfulLinks).response, newUserState.GetKeyboard()); } else { vkUnknownMessageProcessor.ProcessUnknownCommand(messageText, user, GetKeyboard(), new MessageResponse(ResponseType.Help)); } }
public void ProcessMessage(string messageText, BotUser user) { switch (messageText) { case "расписание на сегодня": { messageHandler.GetScheduleForToday(user); break; } case "расписание на завтра": { messageHandler.GetScheduleForNextDay(user); break; } case var n when n == registerCommandListProvider.GettingDiningRoom: { var visitorsCount = messageHandler.GetDiningRoom(user); var text = new MessageResponse(ResponseType.DiningRoom).response; vkMessageSender.SendNotification(user, text + visitorsCount, GetKeyboard()); break; } case "ссылки на учебные чаты": { messageHandler.GetLinks(user); break; } case "добавить ссылку на чат": { var newUserState = container.Get <AddingLinkVK>(); peopleParser.ChangeState(user.UserId, UserStates.AddingLink); vkMessageSender.SendNotification(user, new MessageResponse(ResponseType.LinksMessage).response, newUserState.GetKeyboard()); break; } default: { vkUnknownMessageProcessor.ProcessUnknownCommand(messageText, user, GetKeyboard(), new MessageResponse(ResponseType.RegisterError)); break; } } }
public void ProcessMessage(string messageText, BotUser user) { if (groupProvider.GetAllGroups().Contains(messageText.ToUpper())) { if (messageHandler.SaveGroup(messageText.ToUpper(), user)) { peopleParser.EvaluateState(user.UserId); var updatedState = container.Get <RegisterVK>(); vkMessageSender.SendNotification(user, new MessageResponse(ResponseType.SuccessfulRegistration).response, updatedState.GetKeyboard()); } else { vkMessageSender.SendNotification(user, new MessageResponse(ResponseType.GroupError).response, GetKeyboard()); } } else { vkUnknownMessageProcessor.ProcessUnknownCommand(messageText, user, GetKeyboard(), new MessageResponse(ResponseType.RegisterInProgressError)); } }
public void ProcessUnknownCommand(string messageText, BotUser user, MessageKeyboard keyboard, MessageResponse messageResponse) { var helpCommands = helpCommandListProvider.GetCommands(); if (helpCommands.Contains(messageText)) { var helpMessage = new MessageResponse(ResponseType.Help).response; vkMessageSender.SendNotification(user, helpMessage, keyboard); return; } var allCommands = registerCommandListProvider.GetCommands() .Concat(notRegicterCommandListProvider.GetCommands()) .Concat(registerInProcessCommandListProvider.GetCommands()) .Concat(helpCommands) .ToArray(); var response = allCommands.Contains(messageText) ? messageResponse : new MessageResponse(ResponseType.Error); vkMessageSender.SendNotification(user, response.response, keyboard); }
private void Answer(string message) { var messageText = message.ToLower(); Console.WriteLine(messageText); var vkUser = user; var currentCommand = DefineCommand(user.UserId); try { currentCommand.ProcessMessage(messageText, vkUser); } catch (Exception e) { var text = new MessageResponse(ResponseType.CatchError).response; Console.WriteLine(e); vkMessageSender.SendNotification(vkUser, text, currentCommand.GetKeyboard()); } }
public void ProcessMessage(string messageText, BotUser user) { switch (messageText) { case "/start": case "start": case "начать": { var text = new MessageResponse(ResponseType.Start).response; peopleParser.AddNewUser(user.UserId, "vk"); peopleParser.EvaluateState(user.UserId); var updatedState = container.Get <RegisterInProcessVK>(); vkMessageSender.SendNotification(user, text, updatedState.GetKeyboard()); break; } default: vkUnknownMessageProcessor.ProcessUnknownCommand(messageText, user, GetKeyboard(), new MessageResponse(ResponseType.NotRegisterError)); break; } }