public async static Task <List <TeamSpeak3QueryApi.Net.Specialized.Responses.GetClientInfo> > GetClients()
        {
            try
            {
                var rc = new TeamSpeakClient(host);

                await rc.Connect();

                await rc.Login(username, pass);

                await rc.UseServer(1);

                await rc.WhoAmI();

                await rc.RegisterServerNotification();

                await rc.RegisterChannelNotification(30);

                var serverGroups = await rc.GetServerGroups();

                var firstNormalGroup = serverGroups?.FirstOrDefault(s => s.ServerGroupType == ServerGroupType.NormalGroup);
                var groupClients     = await rc.GetServerGroupClientList(firstNormalGroup.Id);

                var currentClients = await rc.GetClients();

                var fullClients = currentClients.Where(c => c.Type == ClientType.FullClient).ToList();
                await rc.Logout();

                return(fullClients);
            }
            catch { }
            return(null);
        }
Пример #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!");
                        }
                    }
                }
            }
        }
Пример #3
0
        static async Task Main(string[] args)
        {
            var loginData = File.ReadAllLines("..\\..\\..\\logindata.secret");

            var host     = loginData[0].Trim();
            var user     = loginData[1].Trim();
            var password = loginData[2].Trim();

            var rc = new TeamSpeakClient(host);

            await rc.Connect();

            await rc.Login(user, password);

            await rc.UseServer(1);

            await rc.WhoAmI();

            await rc.RegisterServerNotification();

            await rc.RegisterChannelNotification(30);

            var serverGroups = await rc.GetServerGroups();

            var firstNormalGroup = serverGroups?.FirstOrDefault(s => s.ServerGroupType == ServerGroupType.NormalGroup);
            var groupClients     = await rc.GetServerGroupClientList(firstNormalGroup.Id);

            var currentClients = await rc.GetClients();

            var fullClients = currentClients.Where(c => c.Type == ClientType.FullClient).ToList();
            await rc.KickClient(fullClients, KickOrigin.Channel);

            // await rc.MoveClient(1, 1);
            // await rc.KickClient(1, KickTarget.Server);

            rc.Subscribe <ClientEnterView>(data => data.ForEach(c => Debug.WriteLine($"Client {c.NickName} joined.")));
            rc.Subscribe <ClientLeftView>(data => data.ForEach(c => Debug.WriteLine($"Client with id {c.Id} left (kicked/banned/left).")));
            rc.Subscribe <ServerEdited>(data => Debugger.Break());
            rc.Subscribe <ChannelEdited>(data => Debugger.Break());
            rc.Subscribe <ClientMoved>(data => Debugger.Break());

            Console.WriteLine("Done");
            Console.ReadLine();
        }