Esempio n. 1
0
        private static async Task CollectOnlineTime(TeamSpeakClient bot, DateTime lastRun)
        {
            Console.WriteLine("[>] Collecting online time");
            var clients = await bot.GetClients();

            var clientInfos = new List <GetClientDetailedInfo>();

            foreach (var cl in clients.Where(c => c.Type == ClientType.FullClient))
            {
                clientInfos.Add(await bot.GetClientInfo(cl.Id));
            }

            var trackedClients = new List <GetClientDetailedInfo>();

            foreach (var cl in clientInfos.Where(c => c.ServerGroupIds.Any(id => ConfigManager.Config.UserGroups.Contains(id))))
            {
                trackedClients.Add(cl);
            }

            bool anyChange = false;

            foreach (var ci in trackedClients)
            {
                anyChange |= UpdateClientTime(lastRun, ci);
            }
            if (anyChange)
            {
                ClientManager.Save();
            }
        }
Esempio n. 2
0
        private static async Task PokeAdmins(TeamSpeakClient tsClient, ClientMoved client)
        {
            var channelId   = 2;
            var groupToPoke = 6;
            var clients     = await tsClient.GetClients();

            var toPoke = await tsClient.GetServerGroupClientList(groupToPoke);

            if (client.TargetChannel == channelId)
            {
                foreach (var clid in client.ClientIds)
                {
                    var clientInfo = await tsClient.GetClientInfo(clid);

                    await tsClient.SendMessage($"Witaj {clientInfo.NickName} na kanale pomocy!", MessageTarget.Private, clid);

                    await tsClient.SendMessage($"Za chwilę jakiś administrator udzieli Ci pomocy.", MessageTarget.Private, clid);

                    foreach (var admin in toPoke)
                    {
                        var seriuslyToPoke = clients.Where(c => c.DatabaseId == admin.ClientDatabaseId);
                        foreach (var oknow in seriuslyToPoke)
                        {
                            await tsClient.PokeClient(oknow.Id, "Ktos czeka na kanale pomocy!");
                        }
                    }
                }
            }
        }
        private async Task <IReadOnlyList <GetClientDetailedInfo> > GetClientsDetailedTaskAsync(TeamSpeakClient tsc)
        {
            var clients = await GetClientsAsync(true);

            var clientsFiltered =
                clients.Where(cl => cl.Type == ClientType.FullClient).DistinctBy(x => x.DatabaseId).ToList();
            var detailedList = new List <GetClientDetailedInfo>();

            if ((clientsFiltered?.Count ?? 0) < 1)
            {
                return(detailedList);
            }

            foreach (var c in clientsFiltered)
            {
                var detailed = await tsc.GetClientInfo(c);

                detailedList.Add(detailed);
            }

            return(detailedList);
        }