Exemplo n.º 1
0
        private void Updater_Elapsed(object sender, ElapsedEventArgs e)
        {
            foreach (Data.osuUser OUser in osuInfo.osuUsers)
            {
                try
                {
                    if (_client.GetServer(155403174142803969).GetUser(OUser.discordID).Status.Value.Equals(UserStatus.Online.Value))
                    {
                        dynamic dict = Data.osuUser.userStats(OUser.ident.ToString(), OUser.mainMode);
                        if (OUser.pp < double.Parse(dict["pp_raw"], CultureInfo.InvariantCulture))
                        {
                            string query = Information.readURL($"https://osu.ppy.sh/api/get_user_recent?u={OUser.ident}&{OUser.mainMode}&limit=1&k={apiKey}");
                            query = query.Remove(0, 1);
                            query = query.Remove(query.Length - 1, 1);

                            var jss   = new JavaScriptSerializer();
                            var dict2 = jss.Deserialize <dynamic>(query);

                            string beatmap_ID = dict2["beatmap_id"];
                            query = Information.readURL($@"https://osu.ppy.sh/api/get_scores?b={beatmap_ID}&{OUser.mainMode}&u={OUser.username}&limit=1&k={apiKey}");
                            query = query.Remove(0, 1);
                            query = query.Remove(query.Length - 1, 1);

                            var dict3 = jss.Deserialize <dynamic>(query);

                            _client.GetServer(155403174142803969).GetChannel(219423083537235968).SendMessage($"Recieved pp change of `+{Math.Round(double.Parse(dict["pp_raw"], CultureInfo.InvariantCulture) - OUser.pp, 2)}` by **{OUser.username}**  ({Math.Round(double.Parse(dict["pp_raw"], CultureInfo.InvariantCulture), 2)}pp)\n\nOn https://osu.ppy.sh/b/{dict2["beatmap_id"]}&{OUser.mainMode}\nScore: {string.Format("{0:n0}", int.Parse(dict2["score"]))}  ({calcAcc(dict3, OUser.mainMode)}% , {dict2["maxcombo"]}x)\n{dict2["rank"]}, `{dict3["pp"]}pp`");

                            OUser.updateStats(dict);
                        }
                    }
                }
                catch { }
            }
        }
Exemplo n.º 2
0
        private void Updater_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (osuInfo == null && owInfo == null)
            {
                updater.Interval = 60000;
                osuInfo          = new Data.Osu_Data();
                owInfo           = new Data.Overwatch_Data();
                return;
            }

            foreach (Data.osuUser OUser in osuInfo.osuUsers)
            {
                try
                {
                    if (OUser.channels[0].GetUser(OUser.discordID).Status.Value.Equals(UserStatus.Online.Value) || OUser.channels[0].Id.Equals(226499471683485697))
                    {
                        dynamic dict = Data.osuUser.userStats(OUser.ident.ToString(), OUser.mainMode);
                        if (OUser.pp + 1 <= double.Parse(dict["pp_raw"], CultureInfo.InvariantCulture))
                        {
                            string query = Information.readURL($"https://osu.ppy.sh/api/get_user_recent?u={OUser.ident}&{OUser.mainMode}&limit=1&k={apiKey}");
                            query = query.Remove(0, 1);
                            query = query.Remove(query.Length - 1, 1);

                            var jss   = new JavaScriptSerializer();
                            var dict2 = jss.Deserialize <dynamic>(query);

                            string beatmap_ID = dict2["beatmap_id"];
                            query = Information.readURL($@"https://osu.ppy.sh/api/get_scores?b={beatmap_ID}&{OUser.mainMode}&u={OUser.username}&limit=1&k={apiKey}");
                            query = query.Remove(0, 1);
                            query = query.Remove(query.Length - 1, 1);

                            var dict3 = jss.Deserialize <dynamic>(query);

                            string output = $"Recieved pp change of `+{Math.Round(double.Parse(dict["pp_raw"], CultureInfo.InvariantCulture) - OUser.pp, 2)}` by **{OUser.username}**  ({Math.Round(double.Parse(dict["pp_raw"], CultureInfo.InvariantCulture), 2)}pp)\n\nOn https://osu.ppy.sh/b/{dict2["beatmap_id"]}&{OUser.mainMode}\nScore: {string.Format("{0:n0}", int.Parse(dict2["score"]))}  ({calcAcc(dict3, OUser.mainMode)}% , {dict2["maxcombo"]}x)\n{dict2["rank"]}, `{dict3["pp"]}pp`";

                            foreach (Channel ch in OUser.channels)
                            {
                                ch.SendMessage(output);
                            }

                            OUser.updateStats(dict);
                        }
                        else if (OUser.pp < double.Parse(dict["pp_raw"], CultureInfo.InvariantCulture))
                        {
                            OUser.updateStats(dict);
                        }
                    }
                }
                catch { }
            }

            //foreach (Data.OW_User user in owInfo.OW_Users)
            //{
            //    if (!user.channels[0].GetUser(user.discordID).Status.Value.Equals(UserStatus.Offline.Value)
            //        && user.channels[0].GetUser(user.discordID).CurrentGame.Value.Equals("Overwatch"))
            //    {
            //        string tracker = user.trackChange();

            //        if (!tracker.Equals(""))
            //            foreach (Channel ch in user.channels)
            //                ch.SendMessage(tracker);
            //    }
            //}
        }