Пример #1
0
        private static async Task SetTopList(TeamSpeakClient bot)
        {
            if (!ClientManager.Clients.Any())
            {
                Console.WriteLine("[!] Couldn't update channel info: no users! ==========");
                return;
            }

            Console.WriteLine("[>] Updating channel info");
            var topUsers    = ClientManager.Clients.OrderByDescending(x => x.ActiveTime).ToArray();
            var channelName = FormatChannelName(topUsers.FirstOrDefault());;

            var channelInfo = await bot.GetChannelInfo(ConfigManager.Config.ChannelId);

            var editInfo = new EditChannelInfo();

            editInfo.Description = FormatChannelDescription(topUsers);
            if (channelInfo.Name != channelName)
            {
                editInfo.Name = channelName;
            }
            await bot.EditChannel(ConfigManager.Config.ChannelId, editInfo);
        }
Пример #2
0
        private async void Run()
        {
            var loginData = File.ReadAllLines("..\\..\\..\\logindata.secret");

            var token = loginData[0].Trim();

            var rc = new TeamSpeakClient();
            await rc.Connect();

            await rc.Auth(token);

            await rc.RegisterNotification(Event.Any);

            var whoami = await rc.WhoAmI();

            Console.WriteLine($"I am client {whoami.ClientId} in channel {whoami.ChannelId}.");

            var selected = await rc.Use();

            Console.WriteLine($"Currently looking at connection {selected.ServerConnectionHandlerId}.");

            var serverVariable = await rc.GetServerVariable(ServerVariable.Name,
                                                            ServerVariable.Platform,
                                                            ServerVariable.Version,
                                                            ServerVariable.Created,
                                                            ServerVariable.CodecEncryptionMode,
                                                            ServerVariable.DefaultServerGroup,
                                                            ServerVariable.DefaultChannelGroup,
                                                            ServerVariable.HostbannerUrl,
                                                            ServerVariable.HostbannerGfxUrl,
                                                            ServerVariable.HostbannerGfxInterval,
                                                            ServerVariable.PrioritySpeakerDimmModificator,
                                                            ServerVariable.Id,
                                                            ServerVariable.HostbuttonTooltip,
                                                            ServerVariable.HostbuttonUrl,
                                                            ServerVariable.HostbuttonGfxUrl,
                                                            ServerVariable.NamePhonetic,
                                                            ServerVariable.IconId,
                                                            ServerVariable.Ip,
                                                            ServerVariable.AskForPrivilegekey,
                                                            ServerVariable.HostbannerMode);

            Console.WriteLine($"My server is called {serverVariable.Name} running version {serverVariable.Version}.");

            var connections = await rc.GetConnectionList();

            Console.WriteLine($"I have {connections.Count} active connections.");

            var myChannel = await rc.GetChannelInfo(whoami.ChannelId);

            Console.WriteLine($"I am currently in channel {myChannel.Path} on {serverVariable.Name}.");

            var channelClients = await rc.GetChannelClients(whoami.ChannelId);

            Console.WriteLine($"There are {channelClients.Count} users in my channel.");

            rc.Subscribe <CurrentServerConnectionChanged>(data =>
                                                          Console.WriteLine($"Switched active connection to {data.First().ServerConnectionHandlerId}"));

            rc.Subscribe <TalkStatusChange>(data =>
            {
                var stuff = data.First();
                if (stuff.ServerConnectionHandlerId != selected.ServerConnectionHandlerId)
                {
                    return;
                }

                var clientName = channelClients.First(c => c.ClientId == stuff.Id).Name ?? $"Unknown {stuff.Id}";
                if (stuff.IsTalking)
                {
                    Console.WriteLine($"{serverVariable.Name}: {clientName} started talking");
                }
                else
                {
                    Console.WriteLine($"{serverVariable.Name}: {clientName} stopped talking");
                }
            });
        }