public override async Task <UpdateHandlingResult> HandleCommand(Update update, DefaultCommandArgs args) { var userGroups = await Storage.GetGroupsForChatAsync(update.Message.Chat); if (userGroups != null) { var weekSchedule = await Scheduler.GetScheduleForAsync(userGroups, ScheduleRequiredFor.Week); foreach (var daySchedule in weekSchedule.ScheduleRoot.Elems.Cast <Day>()) { var answer = CustomSerializator.ProcessSchedule(daySchedule.Elems.Cast <Lesson>(), daySchedule.DayOfWeek); await Bot.Client.SendTextMessageAsync( update.Message.Chat.Id, answer, ParseMode.Html); Thread.Sleep(200); } } else { await Bot.Client.SendTextMessageAsync( update.Message.Chat.Id, "А группа?"); } return(UpdateHandlingResult.Handled); }
public override async Task <UpdateHandlingResult> HandleCommand(Update update) { var teacher = teachers.GetTeachersNames() .FirstOrDefault(x => x == update.CallbackQuery.Data); if (teacher != null) { teacherSelector.TeacherName = teacher; var teacherSchedule = await scheduleService.CompileScheduleWithSelector(teacherSelector); if (teacherSchedule.ScheduleRoot.Level == ScheduleElemLevel.Week) { await Bot.Client.SendTextMessageAsync( update.CallbackQuery.Message.Chat.Id, teacher); await Bot.Client.AnswerCallbackQueryAsync(update.CallbackQuery.Id, teacher); foreach (var daySchedule in teacherSchedule.ScheduleRoot.Elems.Cast <Day>()) { await SendDay(daySchedule); await Task.Delay(200); } } else if (teacherSchedule.ScheduleRoot.Level == ScheduleElemLevel.Day) { await Bot.Client.SendTextMessageAsync( update.CallbackQuery.Message.Chat.Id, teacher); await Bot.Client.AnswerCallbackQueryAsync(update.CallbackQuery.Id, teacher); await SendDay((Day)teacherSchedule.ScheduleRoot); } else { await Bot.Client.SendTextMessageAsync( update.CallbackQuery.Message.Chat.Id, "Пар нет", replyMarkup : keyboards.GetMainOptionsKeyboard()); } } else { await Bot.Client.SendTextMessageAsync( update.CallbackQuery.Message.Chat.Id, "Нет такого преподавателя.", replyMarkup : keyboards.GetMainOptionsKeyboard()); } return(UpdateHandlingResult.Handled); async Task SendDay(Day day) { var answer = CustomSerializator.ProcessSchedule(day.Elems.OfType <Lesson>(), day.DayOfWeek); await Bot.Client.SendTextMessageAsync( update.CallbackQuery.Message.Chat.Id, answer, ParseMode.Html, replyMarkup : keyboards.GetMainOptionsKeyboard()); } }
protected async Task <UpdateHandlingResult> HandleCommandForPeriod(Update update, DefaultCommandArgs args, ScheduleRequiredFor period) { if (DateTime.Today.DayOfWeek == DayOfWeek.Sunday && period == ScheduleRequiredFor.Today || DateTime.Today.DayOfWeek == DayOfWeek.Saturday && period == ScheduleRequiredFor.Tomorrow) { await Bot.Client.SendTextMessageAsync(update.Message.Chat.Id, "Выходной день 😃"); return(UpdateHandlingResult.Handled); } var userGroups = await Storage.GetGroupsForChatAsync(update.Message.Chat); if (userGroups != null) { var schedule = await Scheduler.GetScheduleForAsync(userGroups, period); if (schedule.ScheduleRoot.Level == ScheduleElemLevel.Undefined) { await Bot.Client.SendTextMessageAsync(update.Message.Chat.Id, "Пар нет 😃"); return(UpdateHandlingResult.Handled); } var answer = CustomSerializator.ProcessSchedule(schedule.ScheduleRoot.Elems.Cast <Lesson>(), ((Day)schedule.ScheduleRoot).DayOfWeek); await Bot.Client.SendTextMessageAsync( update.Message.Chat.Id, answer, ParseMode.Html); } else { await Bot.Client.SendTextMessageAsync( update.Message.Chat.Id, "А группа?"); } return(UpdateHandlingResult.Handled); }