public void GetLinks(BotUser user) { var group = peopleParser.GetGroupFromId(user.UserId); var links = linkParser.GetActualLinksForGroup(group); OnReply(user, new LinksReply(links)); }
private Reply SсheduleModify(int days, BotUser user) { var groupName = peopleParser.GetGroupFromId(user.UserId); var scheduleArray = dataBaseParser .GetTimetableForGroupForCurrentDay(groupName, DateTime.Today.AddDays(days)); return(new ScheduleReply(scheduleArray)); }
public bool SaveGroup(string group, BotUser user) { if (!groupProvider.GetAllGroups().Contains(group)) { return(false); } peopleParser.ChangeGroup(user.UserId, group); return(true); }
public bool AddLink(BotUser user, string name, string link) { try { var group = peopleParser.GetGroupFromId(user.UserId); linkParser.AddLinkForGroup(group, name, link); return(true); } catch { return(false); } }
public void Do() { try { Console.WriteLine("Hello from BotNotification"); var usersList = peopleParser.GetAllUsers(); foreach (var id in usersList) { var domain = peopleParser.GetPlatformFromId(id); var user = new BotUser(id, domain); indicator.Decrement(id); var flag = false; lock (lockObj) { if (!usersLastNotify.ContainsKey(user)) { usersLastNotify[user] = DateTime.Now; flag = true; } } var group = peopleParser.GetGroupFromId(user.UserId); var lesson = LessonReminderHandler(group); lock (lockObj) { var lastNotifyDifference = DateTime.Now.Hour + DateTime.Now.Minute - usersLastNotify[user].Minute - usersLastNotify[user].Hour; if (lesson == null || lastNotifyDifference > 3 && !flag) { continue; } usersLastNotify[user] = DateTime.Now; } Console.Write(lesson + user.UserId); var info = new Tuple <string, int>(lesson.LessonName, lesson.TimeToStart); var result = new LessonReply(info); OnReply(user, result); } } catch (Exception e) { Console.WriteLine(e); } }
public int GetDiningRoom(BotUser user) { diningRoom.Increment(user.UserId); return(diningRoom.VisitorsCount); }
public void GetScheduleForNextDay(BotUser user) { var scheduleNextDay = SсheduleModify(1, user); OnReply(user, scheduleNextDay); }
public void GetScheduleForToday(BotUser user) { var schedule = SсheduleModify(0, user); OnReply(user, schedule); }