コード例 #1
0
        public void GetLinks(BotUser user)
        {
            var group = peopleParser.GetGroupFromId(user.UserId);
            var links = linkParser.GetActualLinksForGroup(group);

            OnReply(user, new LinksReply(links));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
 public bool SaveGroup(string group, BotUser user)
 {
     if (!groupProvider.GetAllGroups().Contains(group))
     {
         return(false);
     }
     peopleParser.ChangeGroup(user.UserId, group);
     return(true);
 }
コード例 #4
0
 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);
     }
 }
コード例 #5
0
 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);
     }
 }
コード例 #6
0
 public int GetDiningRoom(BotUser user)
 {
     diningRoom.Increment(user.UserId);
     return(diningRoom.VisitorsCount);
 }
コード例 #7
0
        public void GetScheduleForNextDay(BotUser user)
        {
            var scheduleNextDay = SсheduleModify(1, user);

            OnReply(user, scheduleNextDay);
        }
コード例 #8
0
        public void GetScheduleForToday(BotUser user)
        {
            var schedule = SсheduleModify(0, user);

            OnReply(user, schedule);
        }