private string decklist(ParseState state)
        {
            if (state.parameter == "draw")
            {
                int rnd = generator.Next(0, deck.Count);
                COMMAND.Parse(state.user, "!" + deck.ElementAt(rnd).Key, state.flags);
                return(success);
            }

            string decks = "";

            foreach (var item in deck)
            {
                decks += "!" + item.Key + " ";
            }

            if (decks == "")
            {
                state.msg("No decks loaded.");
            }
            else
            {
                state.msg(decks);
            }

            return(success);
        }
            public void runscript()
            {
                try
                {
                    // BUG: A DynamicText context needs to be applied to each command to allow use of dynamic variables

                    foreach (var line in list)
                    {
                        COMMAND.Parse(TwitchWebSocketClient.OurTwitchUser, line);
                    }
                }
                catch (Exception ex) { Plugin.Log(ex.ToString()); } // Going to try this form, to reduce code verbosity.
            }
            public void runscript()
            {
                try
                {
                    // BUG: A DynamicText context needs to be applied to each command to allow use of dynamic variables

                    foreach (var line in list)
                    {
                        COMMAND.Parse(ChatHandler.Self, line, RequestBot.CmdFlags.Local);
                    }
                }
                catch (Exception ex)
                {
                    Plugin.Log(ex.ToString());
                } // Going to try this form, to reduce code verbosity.
            }
Example #4
0
        public async Task GetPPData()
        {
            if (pploading)
            {
                return;
            }

            pploading = true;

            //Instance.QueueChatMessage("Getting PP Data");
            var    StarTime   = DateTime.UtcNow;
            string requestUrl = "https://cdn.wes.cloud/beatstar/bssb/v2-ranked.json";
            //public const String SCRAPED_SCORE_SABER_ALL_JSON_URL = "https://cdn.wes.cloud/beatstar/bssb/v2-all.json";

            string result;

            System.Globalization.NumberStyles style = System.Globalization.NumberStyles.AllowDecimalPoint;

            var resp = await Plugin.WebClient.GetAsync(requestUrl, System.Threading.CancellationToken.None);

            if (resp.IsSuccessStatusCode)
            {
                result = resp.ContentToString();
            }
            else
            {
                Plugin.Log("Failed to get pp");
                pploading = false;
                return;
            }

            //Instance.QueueChatMessage($"Parsing PP Data {result.Length}");

            JSONNode rootNode = JSON.Parse(result);

            listcollection.ClearList("pp.deck");

            foreach (KeyValuePair <string, JSONNode> kvp in rootNode)
            {
                JSONNode difficultyNodes = kvp.Value;

                string id      = "";
                float  maxpp   = 0;
                float  maxstar = 0;

                //Instance.QueueChatMessage($"{kvp.Value}");

                id = difficultyNodes["key"];

                //Instance.QueueChatMessage($"{id}");

                foreach (var innerKvp in difficultyNodes["diffs"])
                {
                    JSONNode node = innerKvp.Value;

                    //Instance.QueueChatMessage($"{node}");

                    float.TryParse(node["pp"], style, System.Globalization.CultureInfo.InvariantCulture, out float pp);
                    if (pp > maxpp)
                    {
                        maxpp = pp;
                    }

                    float.TryParse(node["star"], style, System.Globalization.CultureInfo.InvariantCulture, out float starDifficulty);
                    if (starDifficulty > maxstar)
                    {
                        maxstar = starDifficulty;
                    }
                }

                if (maxpp > 0)
                {
                    //Instance.QueueChatMessage($"{id} = {maxpp}");

                    ppmap.TryAdd(id, (int)(maxpp));

                    if (id != "" && maxpp > 200)
                    {
                        listcollection.add("pp.deck", id);
                    }

                    if (MapDatabase.MapLibrary.TryGetValue(id, out SongMap map))
                    {
                        map.pp = (int)(maxpp);
                        map.song.Add("pp", maxpp);
                        map.IndexSong(map.song);
                    }
                }
            }

            COMMAND.Parse(ChatHandler.Self, "!deck pp", RequestBot.CmdFlags.Local);
            Instance.QueueChatMessage("PP Data indexed");
            pploading = false;
        }
 public static void ScheduledCommand(string command, System.Timers.ElapsedEventArgs e)
 {
     COMMAND.Parse(ChatHandler.Self, command);
 }
Example #6
0
 public static void ScheduledCommand(string command, System.Timers.ElapsedEventArgs e)
 {
     COMMAND.Parse(TwitchWebSocketClient.OurTwitchUser, command);
 }
Example #7
0
            public IEnumerator GetPPData()
            {

            if (pploading) yield break;

            pploading = true;            

            //Instance.QueueChatMessage("Getting PP Data");
            var StarTime = DateTime.UtcNow;


            string requestUrl = "https://cdn.wes.cloud/beatstar/bssb/v2-ranked.json"; 
            //public const String SCRAPED_SCORE_SABER_ALL_JSON_URL = "https://cdn.wes.cloud/beatstar/bssb/v2-all.json";

            


            string result;

            System.Globalization.NumberStyles style = System.Globalization.NumberStyles.AllowDecimalPoint;


            using (var web = UnityWebRequest.Get($"{requestUrl}"))
                {
                    yield return web.SendWebRequest();
                    if (web.isNetworkError || web.isHttpError)
                    {
                        pploading = false;
                        yield break;
                    }

                result = web.downloadHandler.text;
                }

            //Instance.QueueChatMessage($"Parsing PP Data {result.Length}");

            JSONNode rootNode = JSON.Parse(result);

            listcollection.ClearList("pp.deck");

            foreach (KeyValuePair<string, JSONNode> kvp in rootNode)
                {
                    JSONNode difficultyNodes = kvp.Value;



                string id = "";
                    float maxpp = 0;
                    float maxstar = 0;

                //Instance.QueueChatMessage($"{kvp.Value}");

                id = difficultyNodes["key"];

                //Instance.QueueChatMessage($"{id}");

                foreach (var innerKvp in difficultyNodes["diffs"])
                    {
                    JSONNode node = innerKvp.Value;

                    //Instance.QueueChatMessage($"{node}");


                    float pp = 0;

                    float.TryParse(node["pp"], style, System.Globalization.CultureInfo.InvariantCulture, out pp);

 
                    if (pp > maxpp) maxpp = pp;

                    float starDifficulty = 0;
                    float.TryParse(node["star"], style, System.Globalization.CultureInfo.InvariantCulture, out starDifficulty);
                    if (starDifficulty > maxstar) maxstar = starDifficulty;
                    }

                if (maxpp > 0)
                {

                    //Instance.QueueChatMessage($"{id} = {maxpp}");

                    SongMap map;

                    ppmap.TryAdd(id, (int)(maxpp));

                    if (id != "" && maxpp >200) listcollection.add("pp.deck", id);

                    if (MapDatabase.MapLibrary.TryGetValue(id, out map))
                    {
                        map.pp=(int) (maxpp);
                    }
                }
            }

            COMMAND.Parse(TwitchWebSocketClient.OurTwitchUser, "!deck pp");
            Instance.QueueChatMessage("PP Data indexed");
            pploading = false;
        }