public override async Task <UpdateHandlingResult> HandleCommand(Update update, DefaultCommandArgs args) { var userAcademicGroup = (await storage.GetGroupsForChatAsync(update.Message.Chat)).FirstOrDefault(g => g.GType == ScheduleGroupType.Academic); if (userAcademicGroup != null) { var engGroups = scheduler.GroupsMonitor.GetAllowedGroups(ScheduleGroupType.Eng, userAcademicGroup)?.ToList() ?? new List <IScheduleGroup>(); if (engGroups.Any()) { await Bot.Client.SendTextMessageAsync( update.Message.Chat.Id, "Выбери свою группу по английскому.", replyMarkup : keyboards.GetKeyboardForCollection(engGroups, g => g.Name)); } else { await Bot.Client.SendTextMessageAsync( update.Message.Chat.Id, "У тебя не нашлось групп по английскому, прости.", replyMarkup : keyboards.GetSettingsKeyboard()); } } else { await Bot.Client.SendTextMessageAsync( update.Message.Chat.Id, "Сначала надо установить группу ☝️. Выбери курс.", replyMarkup : keyboards.GetCoursesKeyboad()); } return(UpdateHandlingResult.Handled); }
public override async Task <UpdateHandlingResult> HandleCommand(Update update, DefaultCommandArgs args) { var userAcademicGroup = (await Storage.GetGroupsForChatAsync(update.Message.Chat)).FirstOrDefault(g => g.GType == ScheduleGroupType.Academic); if (userAcademicGroup != null) { var allowedGroups = Scheduler.GroupsMonitor.GetAllowedGroups(GroupType, userAcademicGroup)?.ToList() ?? new List <IScheduleGroup>(); if (allowedGroups.Any()) { await Bot.Client.SendTextMessageAsync( update.Message.Chat.Id, ResponseText, replyMarkup : Keyboards.GetKeyboardForCollection(allowedGroups, g => g.Name)); } else { await Bot.Client.SendTextMessageAsync( update.Message.Chat.Id, NotFoundResponseText, replyMarkup : Keyboards.GetSettingsKeyboard()); } } else { await Bot.Client.SendTextMessageAsync( update.Message.Chat.Id, "Сначала надо установить группу ☝️. Выбери курс.", replyMarkup : Keyboards.GetCoursesKeyboad()); } return(UpdateHandlingResult.Handled); }
public ReplyKeyboardMarkup GetKeyboardForCollection <TItem>(IEnumerable <TItem> keyboardItems, Func <TItem, string> buttonTextSelector) { return(keyboards.GetKeyboardForCollection(keyboardItems, (item) => buttonTextSelector(item).Substring(0, buttonTextSelector(item).IndexOf("_")))); }