예제 #1
0
        private SubscriberRecord FairSelectSupporter()
        {
            var supporters  = SupporterRepo.GetAll();
            var connections = ConnectionRepo.GetAll();

            //TODO: Fair select
            return(supporters.FirstOrDefault(x => connections.All(c => c.SupporterChatId != x.ChatId)));
        }
예제 #2
0
        public bool TryConnect(SubscriberRecord customer)
        {
            var supporters  = SupporterRepo.GetAll();
            var connections = ConnectionRepo.GetAll();

            if (supporters.Count() > connections.Count())
            {
                var supporter = FairSelectSupporter();
                ConnectionRepo.Add(supporter, customer);

                TelegramClient.SendTextMessageAsync(supporter.ChatId, $"You're Connected to {customer.FirstName} {customer.LastName}",
                                                    replyMarkup: StateManager.GetSupporterReplyKeyboardMarkup(supporter));

                TelegramClient.SendTextMessageAsync(customer.ChatId, "You're Connected.",
                                                    replyMarkup: StateManager.GetCustomerReplyKeyboardMarkup(customer));

                return(true);
            }

            return(false);
        }