Esempio n. 1
0
        //Trigger sound by chat
        public static void PlaySoundeffect(Comment c, Command command)
        {
            CheckCooldownList(); //Clear out the list of any left over user

            //Info on how to use this command
            if (c.comment.Substring(1) == command.name)
            {
                string folders = " ";
                foreach (string s in subDirektories)
                {
                    folders += GetDirName(s) + ", ";                                  //Display all folders/Sublibraries to choose from
                }
                client.SendChatMessage("Use " + FileManager.GetCommandCharacter() + "play + a sound name, ID or category OR random. Sublibraries:" + folders);
                return;
            }
            //If the user is on the cooldown list, return
            foreach (UserCooldown uc in cooldownList)
            {
                if (uc.username == c.user)
                {
                    if (!responseCooldownActive)
                    {
                        client.SendChatMessage("@" + c.user + " not ready (" + uc.TimeLeft() + "sec)");
                        SetResponseCooldown();
                        return;
                    }
                    else
                    {
                        return;
                    }
                }
            }
            //Play a random sound out of the library
            if (c.comment.Substring(1) == command.name + " random")
            {
                PlayRandom(c);
            }
            //Search for a specific sound. ID or name
            else if (c.comment.Substring(1).Contains(command.name) && c.comment.Length > command.name.Length)
            {
                //Get the comment Substring without !play
                string cSubstring = c.comment.Substring(c.comment.IndexOf(" ") + 1);
                int    idSearch; //ID to try to parse

                //Check if it's a ID
                if (int.TryParse(cSubstring, out idSearch))
                {
                    if (GetPathByID(idSearch) != null)
                    {
                        PlayID(c, idSearch);
                    }
                }
                //Check if it's a Sublibrarie name
                foreach (string s in subDirektories)
                {
                    if (cSubstring.Equals(s.Substring(s.LastIndexOf(@"\") + 1)))
                    {
                        PlayFolder(c, s);
                    }
                }
                //Check if it's a soundfile name
                foreach (string path in soundFiles)
                {
                    if (cSubstring.Equals(FileManager.GetSoundname(path)))
                    {
                        PlaySound(path, c, 0);
                    }
                }
            }
        }