예제 #1
0
        public static void Start(int Device)
        {
            DeviceId = Device;
            byte[] silence = new byte[10000];
            Array.Clear(silence, 0, 5000);
            client.PlayVoice = true;
            decoder          = OpusDecoder.Create(48000, 1);
            players          = new Dictionary <int, BufferedWaveProvider>();

            foreach (ClientData data in client.ClientList())
            {
                BufferedWaveProvider player = new BufferedWaveProvider(new WaveFormat(48000, 16, 1));
                players[data.ClientId] = player;
                player.AddSamples(silence, 0, 5000);
            }

            mixer = new MixingSampleProvider(players.Select((playr) => playr.Value.ToSampleProvider()));

            Out = new WaveOut();
            Out.DeviceNumber = Device;
            Out.Init(mixer);
            Out.Play();

            Active = true;
        }
예제 #2
0
        public string List()
        {
            if (!client.Connected)
            {
                return("Not connected!");
            }

            context.BufferOn();
            CommandHelper.ResetColor();
            foreach (ClientData data in client.ClientList())
            {
                CommandHelper.AlternateColor();
                //context.Write(data.ReturnCode);
                context.WriteLine(data.ClientId + "\t" + data.NickName + "\t|");
            }
            CommandHelper.ResetColor();
            context.Flush();

            return(null);
        }
예제 #3
0
 public Context(TextMessage Message, Ts3FullClient client)
 {
     if (Message != null && client != null)
     {
         this.client = client;
         useTs       = true;
         if (Message.Target == TextMessageTargetMode.Private)
         {
             usePrivate = true;
             sender     = client.ClientList().Where((o) => Message.InvokerId == o.ClientId).FirstOrDefault();
         }
     }
 }
예제 #4
0
 public E <LocalStr> RefreshClientBuffer(bool force)
 {
     if (clientbufferOutdated || force)
     {
         var result = tsFullClient.ClientList(ClientListOptions.uid);
         if (!result)
         {
             Log.Debug("Clientlist failed ({0})", result.Error.ErrorFormat());
             return(result.Error.FormatLocal());
         }
         clientbuffer         = result.Value.ToList();
         clientbufferOutdated = false;
     }
     return(R.Ok);
 }
예제 #5
0
        public string getConnectedClients()
        {
            string returns = "";

            ClientData[] clients = _ts.ClientList().ToArray();
            int          count   = clients.Length;

            for (int i = 0; i < count; i++)
            {
                string nick       = clients[i].NickName;
                ulong  channel_id = clients[i].ChannelId;
                returns += i + ". " + nick + " in Channel with id: " + channel_id + "\n";
            }
            return(returns);
        }
예제 #6
0
 public static void Client_OnClientEnterView(object sender, IEnumerable <ClientEnterView> e)
 {
     foreach (ClientEnterView Client in e)
     {
         try
         {
             if (Client.ClientType == ClientType.Full)
             {
                 Player.Connected(Client.ClientId);
                 ConsoleHelper.WriteEventLine(Client.NickName + " entered view!(" + Client.Reason + ")", Color.ForestGreen);
             }
             Clients.Add(Client.ClientId, client.ClientList().Where((o) => o.ClientId == Client.ClientId).SingleOrDefault <ClientData>());
         }
         catch { }
     }
 }
예제 #7
0
        public static IOrderedEnumerable <ClientInfo> ListUsers(this Ts3FullClient client)
        {
            var clientList = client.ClientList();

            if (clientList.Ok)
            {
                return(clientList
                       .Unwrap()
                       .Where(x => x.ClientType != ClientType.Query)
                       .Select(x => client.ClientInfo(x.ClientId))
                       .Where(x => x.Ok)
                       .Select(x => x.Unwrap())
                       .OrderBy(x => x.ChannelId));
            }
            else
            {
                return(Enumerable.Empty <ClientInfo>()
                       .OrderBy(x => x));
            }
        }
예제 #8
0
        private void Lib_OnTextMessageReceived(object sender, IEnumerable <TextMessage> e)
        {
            if (!Enabled)
            {
                return;
            }
            List <ClientData> clientbuffer = null;

            foreach (var msg in e)
            {
                if (msg.Target != TextMessageTargetMode.Private || msg.InvokerId == lib.WhoAmI().ClientId)
                {
                    continue;
                }
                try {
                    clientbuffer = clientbuffer ?? lib.ClientList(ClientListOptions.uid).ToList();
                    foreach (var client in clientbuffer)
                    {
                        if (client.Uid == msg.InvokerUid)
                        {
                            continue;
                        }
                        if (!bot.RightsManager.HasAllRights(new InvokerData(client.Uid), "PMRedirect.isowner"))
                        {
                            continue;
                        }
                        // PluginLog(Log.Level.Debug, "Got PM from " + msg.InvokerUid + ". Redirecting to " + client.Uid);
                        bot.QueryConnection.SendMessage("Got PM from " + ParseInvoker(msg) + ": " + msg.Message, client.ClientId);
                    }
                    //foreach (var uid in Settings.Default.uids)
                    //{
                    //    PluginLog(Log.Level.Debug, "uid: " + uid);
                    //}
                } catch (Ts3CommandException exception) {
                    PluginLog(Log.Level.Error, exception.ToString());
                }
            }
        }
예제 #9
0
 private void Lib_OnConnected(object sender, EventArgs e)
 {
     if (!Enabled)
     {
         return;
     }
     if (cfg["General"]["clearcache"] != "0")
     {
         ClearCache.Active = true;
     }
     if (cfg["Events"]["bot_connnected"] != "true")
     {
         return;
     }
     PluginLog(Log.Level.Debug, "Our client is now connected, setting channel commander :)");
     if (cfg["Events"]["bot_connnected"] == "true")
     {
         foreach (var client in lib.ClientList())
         {
             checkClient(client.ClientId);
         }
     }
 }
예제 #10
0
        private void PlayManager_AfterResourceStarted(object sender, PlayInfoEventArgs e)
        {
            if (!Settings.Default.Enabled)
            {
                return;
            }
            PluginLog(Log.Level.Debug, "Track changed. Applying now playing values");
            if (!string.IsNullOrWhiteSpace(Settings.Default.Description))
            {
                try {
                    bot.QueryConnection.ChangeDescription(ParseNowPlayingString(Settings.Default.Description, e));
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to change Description: " + ex.Message); }
            }
            if (!string.IsNullOrWhiteSpace(Settings.Default.ServerChat))
            {
                try {
                    bot.QueryConnection.SendServerMessage(ParseNowPlayingString(Settings.Default.ServerChat, e));
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to send Server Message: " + ex.Message); }
            }
            if (!string.IsNullOrWhiteSpace(Settings.Default.ChannelChat))
            {
                try {
                    bot.QueryConnection.SendChannelMessage(ParseNowPlayingString(Settings.Default.ChannelChat, e));
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to send Channel Message: " + ex.Message); }
            }
            if (!string.IsNullOrWhiteSpace(Settings.Default.PrivateChat))
            {
                try {
                    var clientbuffer = lib.ClientList(ClientListOptions.uid).ToList();
                    foreach (var client in clientbuffer)
                    {
                        foreach (var uid in Settings.Default.PrivateChatUIDs)
                        {
                            if (client.Uid == uid)
                            {
                                bot.QueryConnection.SendMessage(ParseNowPlayingString(Settings.Default.PrivateChat, e), client.ClientId);
                            }
                        }
                    }
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to send private Message: " + ex.Message); }
            }
            if (!string.IsNullOrWhiteSpace(Settings.Default.NickName))
            {
                try {
                    bot.QueryConnection.ChangeName(ParseNowPlayingString(Settings.Default.NickName, e));
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to change nickname: " + ex.Message); }
            }
            if (!string.IsNullOrWhiteSpace(Settings.Default.PluginCommand))
            {
                try {
                    lib.Send("plugincmd", new CommandParameter("name", "TS3AudioBot"),
                             new CommandParameter("targetmode", 0),
                             new CommandParameter("data", ParseNowPlayingString(Settings.Default.PluginCommand, e)));
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to send Plugin Command: " + ex.Message); }
            }
            if (!string.IsNullOrWhiteSpace(Settings.Default.MetaData))
            {
                try {
                    /* TODO: Append Meta Data
                     * var clid = lib.ClientId;
                     * var ownClient = lib.Send<ClientData>("clientinfo", new CommandParameter("clid", clid)).FirstOrDefault();
                     * ownClient.*/
                    lib.Send("clientupdate", new CommandParameter("client_meta_data", ParseNowPlayingString(Settings.Default.MetaData, e)));
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to set Meta Data: " + ex.Message); }
            }
            var ownChannelId = lib.WhoAmI().ChannelId;

            if (!string.IsNullOrWhiteSpace(Settings.Default.ChannelName))
            {
                try {
                    lib.Send("channeledit", new CommandParameter("cid", ownChannelId),
                             new CommandParameter("channel_name", ParseNowPlayingString(Settings.Default.ChannelName, e)));
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to set channel name: " + ex.Message); }
            }
            if (!string.IsNullOrWhiteSpace(Settings.Default.ChannelTopic))
            {
                try {
                    lib.Send("channeledit", new CommandParameter("cid", ownChannelId),
                             new CommandParameter("channel_topic", ParseNowPlayingString(Settings.Default.ChannelTopic, e)));
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to set channel topic: " + ex.Message); }
            }
            if (!string.IsNullOrWhiteSpace(Settings.Default.ChannelDescription))
            {
                try {
                    lib.Send("channeledit", new CommandParameter("cid", ownChannelId),
                             new CommandParameter("channel_description", ParseNowPlayingString(Settings.Default.ChannelDescription, e)));
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to set channel description: " + ex.Message); }
            }
        }