public override async Task <UpdateHandlingResult> HandleCommand(Update update, DefaultCommandArgs args) { 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 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) { IScheduleGroup userAcademicGroup; IScheduleGroup groupToSet; if (Cache.TryGetValue(update.Id, out ValueTuple <IScheduleGroup, IScheduleGroup> cached)) { userAcademicGroup = cached.Item1 ?? await GetAcademicAsync(update); groupToSet = cached.Item2 ?? GetFirstMatchAllowed(userAcademicGroup, update); Cache.Remove(update.Id); } else { userAcademicGroup = await GetAcademicAsync(update); groupToSet = GetFirstMatchAllowed(userAcademicGroup, update); } if (userAcademicGroup != null && groupToSet != null) { if (await Storage.TryAddGroupToChatAsync(groupToSet, update.Message.Chat)) { await Bot.Client.SendTextMessageAsync( update.Message.Chat.Id, "Установлено!", replyMarkup : Keyboards.GetMainOptionsKeyboard()); } else { await Bot.Client.SendTextMessageAsync( update.Message.Chat.Id, "Не удалось установить группу :("); } } else { logger?.LogError( "Bad situation: allowed group not found but it can handle this command: {0}, {1}", GroupType, JsonConvert.SerializeObject(update)); 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 GetCoursesKeyboad() { return(keyboards.GetCoursesKeyboad()); }