Пример #1
0
        public bool CheckIfDiscordIdIsLinked(string DiscordId)
        {
            var DutchAccountsPath  = "../../../DutchAccounts.txt";
            var GlobalAccountsPath = "../../../GlobalAccounts.txt";

            var DutchAccounts  = JsonExtension.GetJsonData(DutchAccountsPath);
            var GlobalAccounts = JsonExtension.GetJsonData(GlobalAccountsPath);

            if (DutchAccounts == null && GlobalAccounts == null)
            {
                return(false);
            }

            if (DutchAccounts.Count == 0 && GlobalAccounts.Count == 0)
            {
                return(false);
            }

            var condition = false;

            if (DutchAccounts == null)
            {
                return(false);
            }

            foreach (var user in DutchAccounts)
            {
                if (user.Key == DiscordId)
                {
                    condition = true;
                }
            }

            if (GlobalAccounts == null)
            {
                return(false);
            }

            foreach (var user in GlobalAccounts)
            {
                if (user.Key == DiscordId)
                {
                    condition = true;
                }
            }

            return(condition);
        }
Пример #2
0
        public ulong GetDiscordIdWithScoresaberId(string scoresaberId)
        {
            string GlobalAccountsPath = "../../../DutchAccounts.txt";
            var    account            = new Dictionary <string, object>();

            account = JsonExtension.GetJsonData(GlobalAccountsPath);

            if (account == null || account.Count == 0)
            {
                return(0);
            }
            foreach (var player in account)
            {
                if (player.Value.ToString() == scoresaberId)
                {
                    return(ulong.Parse(player.Key));
                }
            }

            return(0);
        }
Пример #3
0
        public string GetScoresaberIdWithDiscordId(string DiscordId)
        {
            var DutchAccountsPath  = "../../../DutchAccounts.txt";
            var GlobalAccountsPath = "../../../GlobalAccounts.txt";

            var DutchAccounts  = JsonExtension.GetJsonData(DutchAccountsPath);
            var GlobalAccounts = JsonExtension.GetJsonData(GlobalAccountsPath);

            if (DutchAccounts == null && GlobalAccounts == null)
            {
                return("0");
            }

            if (DutchAccounts.Count == 0 && GlobalAccounts.Count == 0)
            {
                return("0");
            }

            var condition = "0";

            foreach (var player in DutchAccounts)
            {
                if (player.Key == DiscordId)
                {
                    return(player.Value.ToString());
                }
            }

            foreach (var player in GlobalAccounts)
            {
                if (player.Key == DiscordId)
                {
                    return(player.Value.ToString());
                }
            }

            return("0");
        }
Пример #4
0
        public async Task <bool> LinkAccount(string discordId, string scoresaberId)
        {
            var GlobalAccountsPath = "../../../DutchAccounts.txt";

            //command: linkaccount
            string DiscordId    = discordId;
            string ScoresaberId = scoresaberId;

            var account = new Dictionary <string, object>();

            account = JsonExtension.GetJsonData(GlobalAccountsPath);

            if (account == null || account.Count == 0)
            {
                account = new Dictionary <string, object>();
            }


            foreach (var acc in account)
            {
                if (acc.Key == DiscordId && acc.Value.ToString() == ScoresaberId)
                {
                    return(false);
                }
            }

            account.Add(DiscordId, ScoresaberId);

            using (var file = File.CreateText(GlobalAccountsPath))
            {
                var serializer = new JsonSerializer();
                serializer.Serialize(file, account);
            }

            //await message.DeleteAsync();
            return(true);
        }
Пример #5
0
        private async Task Init()
        {
            try
            {
                await log("Discord Bot is now Connected.");

                _startTime = DateTime.Now;
                _logger    = new Logger(discordSocketClient);
                var settingData = JsonExtension.GetJsonData("../../../BeatSaberSettings.txt");
                await discordSocketClient.SetGameAsync(settingData.GetValueOrDefault("gamePlaying").ToString());

                //DutchHourCounter = new BeatSaberHourCounter(discordSocketClient);

                var updater = new UpdateTimer(discordSocketClient);
                updater.Start(() => updater.DutchDiscordUserCount(_startTime), 1);
                updater.Start(() => updater.EventNotification(), 1);
                //updater.Start(() => updater.DutchWeeklyEndHoursCheck(), 1);

                _reactionWatcher = new Dictionary <string, string>
                {
                    { "<:windows:553375150138195968>", "WMR" },
                    { "❕", "NSFW" },
                    { "<:AYAYA:509158069809315850>", "Weeb" },
                    { "<:minecraft:600768239261319217>", "Minecraft" },
                    { "<:osu:578679882553491493>", "Osu!" },
                    { "<:vrchat:537413837100548115>", "VRChat" },
                    { "<:pavlov:593542245022695453>", "Pavlov" },
                    { "🗺", "Mapper" },
                    { "💻", "Modder" },
                    { "<:terebilo:508313942297280518>", "Normale-Grip" },
                    { "<:miitchelW:557923575944970241>", "Botchal-Grip" },
                    { "🆕", "Overige-Grip" },
                    { "🇹", "Tracker Sabers" },
                    { "🇵", "Palm-Grip" },
                    { "🇨", "Claw-Grip" },
                    { "🇫", "F-Grip" },
                    { "🇷", "R-Grip" },
                    { "🇰", "K-Grip" },
                    { "🇻", "V-Grip" },
                    { "🇧", "B-Grip" },
                    { "🇽", "X-Grip" },
                    { "<:oculus:537368385206616075>", "Oculus" },
                    { "<:vive:537368500277084172>", "Vive" },
                    { "<:indexvr:589754441545154570>", "Index" },
                    { "<:pimax:614170153185312789>", "Pimax" },
                    { "<:megaotherway:526402963372245012>", "Event" },
                    { "<:skyToxicc:479251361028898828>", "Toxic" },
                    { "<:BeatSaberTime:633400410400489487>", "Beat saber multiplayer" },
                    { "🎮", "Andere games multiplayer" },
                    { "<:owopeak:401481118165237760>", "IRL event" },

                    //Provincies
                    { "<:peepoGroningen:600782037325971458>", "Groningen" },
                    { "<:peepoFriesland:600782036923449344>", "Friesland" },
                    { "<:peepoDrenthe:600782037556920372>", "Drenthe" },
                    { "<:peepoOverijssel:600782037649063947>", "Overijssel" },
                    { "<:peepoFlevoland:600782037812772870>", "Flevoland" },
                    { "<:peepoGelderland:600782037590474780>", "Gelderland" },
                    { "<:peepoUtrecht:600782037472903169>", "Utrecht" },
                    { "<:peepoNoordHolland:600782038035070986>", "Noord-Holland" },
                    { "<:peepoZuidHolland:600782037682749448>", "Zuid-Holland" },
                    { "<:peepoZeeland:600782037049409547>", "Zeeland" },
                    { "<:peepoBrabant:600782036642430986>", "Noord-Brabant" },
                    { "<:peepoLimburg:600782036919123968>", "Limburg" },

                    //Silverhaze's server
                    { "<:AWEE:588758943686328330>", "Anime" },
                    { "<:silverGasm:628988811329929276>", "NSFW" }
                };


                try
                {
                    //var RankingFeedThread = new Thread(() => RankFeedTimer(new CancellationToken()));
                    //RankingFeedThread.Start();
                    //TimerRunning(new CancellationToken());
                }
                catch
                {
                    _logger.Log(Logger.LogCode.error, "Thread exeption");
                }
            }
            catch (Exception ex)
            {
                _logger.Log(Logger.LogCode.error, "Init Exception!! \n" + ex);
            }
        }
        public static async Task UpdateNLAsync(DiscordSocketClient discord, SocketMessage message)
        {
            var embed = await message.Channel.SendMessageAsync("Starting Roles update");

            await Task.Delay(1000);

            Console.WriteLine("Starting updating roles from linked NL accounts");
            var    accounts          = new Dictionary <string, object>();
            string DutchAccountsPath = "../../../DutchAccounts.txt";

            accounts = JsonExtension.GetJsonData(DutchAccountsPath);

            if (accounts == null || accounts.Count == 0)
            {
                accounts = new Dictionary <string, object>();
            }

            var client = new HttpClient();

            var LoadingSpaceCount    = 0;
            var spaceCount           = accounts.Count;
            var accountsProcessCount = 0;

            string staticUrl = "https://scoresaber.com/u/";

            foreach (var account in accounts)
            {
                string url  = staticUrl + account.Value.ToString();
                int    rank = 0;

                string html = await client.GetStringAsync(url);

                var doc = new HtmlDocument();
                doc.LoadHtml(html);
                try
                {
                    string rankUnfixed = doc.DocumentNode.SelectSingleNode("//a[@href='/global?country=nl']").InnerText;
                    rank = int.Parse(rankUnfixed.Replace("(", "").Replace(")", "").Replace("#", "").Replace(",", "").Trim());
                }
                catch
                {
                    var Logger = new Logger(discord);
                    Logger.Log(Logger.LogCode.debug, "Cant get rank info from: " + url);
                }

                try
                {
                    if (rank == 0)
                    {
                        await DutchRankFeed.GiveRole(account.Value.ToString(), "Koos Rankloos", discord);

                        continue;
                    }

                    if (rank == 1)
                    {
                        await DutchRankFeed.GiveRole(account.Value.ToString(), "Nummer 1", discord);
                    }
                    else if (rank <= 3)
                    {
                        await DutchRankFeed.GiveRole(account.Value.ToString(), "Top 3", discord);
                    }
                    else if (rank <= 10)
                    {
                        await DutchRankFeed.GiveRole(account.Value.ToString(), "Top 10", discord);
                    }
                    else if (rank <= 25)
                    {
                        await DutchRankFeed.GiveRole(account.Value.ToString(), "Top 25", discord);
                    }
                    else if (rank <= 50)
                    {
                        await DutchRankFeed.GiveRole(account.Value.ToString(), "Top 50", discord);
                    }
                    else if (rank <= 100)
                    {
                        await DutchRankFeed.GiveRole(account.Value.ToString(), "Top 100", discord);
                    }
                    else if (rank <= 250)
                    {
                        await DutchRankFeed.GiveRole(account.Value.ToString(), "Top 250", discord);
                    }
                    else if (rank <= 500)
                    {
                        await DutchRankFeed.GiveRole(account.Value.ToString(), "Top 500", discord);
                    }
                    else if (rank > 500)
                    {
                        await DutchRankFeed.GiveRole(account.Value.ToString(), "Top 501+", discord);
                    }
                }
                catch
                {
                    Console.WriteLine("Delete " + account.Value.ToString() + "He left the discord");
                }

                await embed.ModifyAsync(x =>
                                        x.Content = "Loading... \n*" + accountsProcessCount + "* ||  " + GiveSpaces(accountsProcessCount).Item1 + "||" + GiveSpaces(accountsProcessCount).Item2 + "*" + accounts.Count.ToString() + "*");

                accountsProcessCount += 1;


                (string, string) GiveSpaces(int count)
                {
                    var l = "";
                    var s = "";

                    for (var i = 0; i < count; i++)
                    {
                        l += " ";
                    }

                    for (var i = 0; i < accounts.Count - count; i++)
                    {
                        s += " ";
                    }

                    return(l, s);
                }
            }

            client.Dispose();

            Console.WriteLine("Done updating accounts NL");
        }