예제 #1
0
        public async Task Wheelspoof(string token = null)
        {
            Authorisationcheck authorisationcheck = new Authorisationcheck();

            if (!authorisationcheck.Check(Context.User.Id, _config))
            {
                return;
            }
            if (Context.Channel.GetType().ToString() != "Discord.WebSocket.SocketDMChannel")
            {
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> Due to its sensitive nature, this command is resticted to dms only");

                await Context.Message.DeleteAsync();

                return;
            }
            if (File.Exists($"wheelspoof/tokens/{Context.User.Id}.37") && token == null)
            {
                token = File.ReadAllText($"wheelspoof/tokens/{Context.User.Id}.37");
            }
            if (token == null)
            {
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> You need to provide your token. If you don't know how to get your token use \"help\" instead of it to get a tutorial.");

                return;
            }
            if (token.ToLower() == "help")
            {
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}>This tutorial only works on desktop. To get your token go to <https://gamblingbot.app> with Chrome or Firefox, sign in with Discord, press f12, go to the \"Application\" tab, click on \"Local Storage\", then \"https://gamblingbot.app/\" and then copy the value for token");

                return;
            }
            if (File.Exists($"wheelspoof/{token}"))
            {
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> This token is currently already being used. If you think this is a mistake contact my owner");

                return;
            }
            DateTime lastreminder = new DateTime();
            await File.WriteAllTextAsync($"wheelspoof/{token}", "uwu");

            try
            {
                HttpClient            client  = new HttpClient();
                Dictionary <int, int> distrib = new Dictionary <int, int>
                {
                    { 0, 0 },
                    { 1, 0 },
                    { 2, 0 },
                    { 3, 0 },
                    { 4, 0 },
                    { 5, 0 },
                    { 6, 0 },
                    { 7, 0 },
                    { 8, 0 },
                    { 9, 0 },
                    { 10, 0 },
                    { 11, 0 },
                };
                List <string> agents = new List <string>()
                {
                    "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0",
                    "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/5352 (KHTML, like Gecko) Chrome/37.0.825.0 Mobile Safari/5352",
                    "Opera/9.79 (X11; Linux i686; en-US) Presto/2.10.342 Version/10.00",
                    "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_2 like Mac OS X; en-US) AppleWebKit/532.43.6 (KHTML, like Gecko) Version/3.0.5 Mobile/8B115 Safari/6532.43.6",
                    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
                };
                client.DefaultRequestHeaders.Add("Accept", "application / json, text / plain, */*");
                client.DefaultRequestHeaders.Add("Accept-Encoding", "gzip, deflate, br");
                client.DefaultRequestHeaders.Add("Accept-Language", "en-US,en;q=0.5");
                client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token}");
                client.DefaultRequestHeaders.Add("Cache-Control", "no-cache");
                client.DefaultRequestHeaders.Add("Connection", "keep-alive");
                client.DefaultRequestHeaders.Add("Host", "gamblingbot.app");
                client.DefaultRequestHeaders.Add("Pragma", "no-cache");
                client.DefaultRequestHeaders.Add("Referer", "https://gamblingbot.app/games/fortune-wheel");
                client.DefaultRequestHeaders.Add("User-Agent", agents[new Random().Next(agents.Count())]);
                DateTime            start             = DateTime.UtcNow;
                bool                mil               = false;
                bool                startconfirmation = false;
                HttpResponseMessage cooldownresponse  = await client.GetAsync("https://gamblingbot.app/api/games/fortune-wheel-free-cooldown");

                if (await cooldownresponse.Content.ReadAsStringAsync() == "invalid user")
                {
                    await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> The allmighty bot didnt like that one. This may be because your token has expired or because the gambling bot is having technical difficulties.");

                    Console.WriteLine("Invalid free cooldown");
                    if (File.Exists($"wheelspoof/{token}"))
                    {
                        File.Delete($"wheelspoof/{token}");
                    }
                    if (File.Exists($"wheelspoof/tokens/{Context.User.Id}.37"))
                    {
                        File.Delete($"wheelspoof/tokens/{Context.User.Id}.37");
                    }
                    return;
                }
                else if (await cooldownresponse.Content.ReadAsStringAsync() == "")
                {
                    string neverrolledresponse = $"<@{Context.User.Id}> I am sorry, but it appears you havent rolled the wheel before. For some reason I can't roll for you if thats the case. Please roll the wheel manually once and come back tomorrow.";
                    if (!File.Exists($"wheelspoof/tokens/{Context.User.Id}.37") || File.ReadAllText($"wheelspoof/tokens/{Context.User.Id}.37") != token)
                    {
                        File.WriteAllText($"wheelspoof/tokens/{Context.User.Id}.37", token);
                        neverrolledresponse += " I have saved your token for you, which means you wont need to provide it next time.";
                    }
                    await Context.Channel.SendMessageAsync(neverrolledresponse);

                    return;
                }
                else
                {
                    DateTimeOffset unixstart = DateTimeOffset.FromUnixTimeMilliseconds(long.Parse(await cooldownresponse.Content.ReadAsStringAsync()));
                    unixstart = unixstart.AddHours(22);
                    if (DateTime.UtcNow.CompareTo(unixstart.UtcDateTime) < 0)
                    {
                        TimeSpan cooldown           = unixstart - DateTime.UtcNow;
                        string   oncooldownresponse = $"<@{Context.User.Id}> Your spin is still on cooldown for {cooldown.Hours} hours, {cooldown.Minutes} minutes and {cooldown.Seconds} seconds. Please try again then.";
                        if (!File.Exists($"wheelspoof/tokens/{Context.User.Id}.37") || File.ReadAllText($"wheelspoof/tokens/{Context.User.Id}.37") != token)
                        {
                            File.WriteAllText($"wheelspoof/tokens/{Context.User.Id}.37", token);
                            oncooldownresponse += " I have saved you token for you, which means you wont need to provide it next time";
                        }
                        if (File.Exists($"wheelspoof/{token}"))
                        {
                            File.Delete($"wheelspoof/{token}");
                        }
                        await Context.Channel.SendMessageAsync(oncooldownresponse);

                        return;
                    }
                }
                int failedrequests = 0;
                while (!mil)
                {
                    HttpResponseMessage response = await client.GetAsync($"https://gamblingbot.app/api/games/fortune-wheel-start");

                    string responsestring = await response.Content.ReadAsStringAsync();

                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        failedrequests = 0;
                        if (responsestring == "invalid user")
                        {
                            await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> The allmighty bot didnt like that one. This may be because your token has expired or because the gambling bot is having technical difficulties.");

                            if (File.Exists($"wheelspoof/{token}"))
                            {
                                File.Delete($"wheelspoof/{token}");
                            }
                            return;
                        }
                        if (!startconfirmation)
                        {
                            string confirmationresponse = $"<@{Context.User.Id}> I have started up the automatic spin feature for you. Be advised that this may take upwards of multiple hours on some days. I will keep you updated around every 15 minutes.";
                            startconfirmation = true;
                            lastreminder      = DateTime.Now;
                            if (!File.Exists($"wheelspoof/tokens/{Context.User.Id}.37") || File.ReadAllText($"wheelspoof/tokens/{Context.User.Id}.37") != token)
                            {
                                File.WriteAllText($"wheelspoof/tokens/{Context.User.Id}.37", token);
                                confirmationresponse += " I have also saved the token for you. If you want to roll with the same token next time you dont have to provide it again";
                            }
                            await Context.Channel.SendMessageAsync(confirmationresponse);
                        }
                        try
                        {
                            int key = int.Parse(responsestring.Replace("{\"win\":", "").Replace("}", ""));
                            distrib[key]++;
                        }
                        catch (FormatException)
                        {
                            int counter = 0;
                            foreach (KeyValuePair <int, int> kvp in distrib)
                            {
                                counter += kvp.Value;
                            }
                            TimeSpan temp = DateTime.UtcNow - start;
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine($"{DateTime.UtcNow}: Error in wheel response for {Context.User.Username}#{Context.User.Discriminator}: \"{responsestring}\"");
                            Console.ResetColor();
                            lservice.LogAsync($"Invalid Response: \"{responsestring}\"", LogLevel.Severe, Context);
                            await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> Oops, i didnt expect the following response after {counter} rolls and {temp.Hours}h {temp.Minutes}m {temp.Seconds}s: \"{responsestring}\" Please contact my owner with this information or try again");

                            File.Delete($"wheelspoof/{token}");
                            return;
                        }
                        if ((DateTime.Now - lastreminder).TotalMinutes > 15)
                        {
                            int counter = 0;
                            foreach (KeyValuePair <int, int> kvp in distrib)
                            {
                                counter += kvp.Value;
                            }
                            TimeSpan temp = DateTime.UtcNow - start;
                            await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> Still rolling! I have been rolling for {temp.Hours} hours, {temp.Minutes} minutes and {temp.Seconds} seconds and missed {counter} times so far :(");

                            lastreminder = DateTime.Now;
                        }
                        if (responsestring == "{\"win\":0}")
                        {
                            mil = true;
                            await Task.Delay(7000);
                        }
                    }
                    else
                    {
                        if (failedrequests < 10)
                        {
                            failedrequests++;
                        }
                        else
                        {
                            int counter = 0;
                            foreach (KeyValuePair <int, int> kvp in distrib)
                            {
                                counter += kvp.Value;
                            }
                            TimeSpan temp = DateTime.UtcNow - start;
                            await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> I'm sorry, but the last 10 requests failed after {counter} sucessfull rolls and a time of {temp.Hours} hours and {temp.Minutes} minutes. The last request failed with the status code \"{response.StatusCode}\" and the response \"{responsestring}\". Please contact my owner with this info or try again later. ");

                            File.Delete($"wheelspoof/{token}");
                            return;
                        }
                    }
                    await Task.Delay(5000 + new Random().Next(-1000, 1000));
                }
                HttpResponseMessage winresponse = await client.GetAsync($"https://gamblingbot.app/api/games/fortune-wheel-ok");

                TimeSpan  ts     = DateTime.UtcNow - start;
                WebClient web    = new WebClient();
                Stream    stream = web.OpenRead($"https://quickchart.io/chart?bkg=white&c={{type:'bar',data:{{labels:['10,000,000','9,000','45,000','11,500','450,000','15,000','60,000','20,000','250,000','30,000','120,000','6,000'],datasets:[{{ label:'Times rolled',data:[{distrib[0]},{distrib[1]},{distrib[2]},{distrib[3]},1{distrib[4]},{distrib[5]},{distrib[6]},{distrib[7]},{distrib[8]},{distrib[9]},{distrib[10]},{distrib[11]}]}}]}}}}");
                Bitmap    bitmap = new Bitmap(stream);
                bitmap.Save($"wheelspoof/barcharts/{Context.Message.Id}.png", System.Drawing.Imaging.ImageFormat.Png);
                File.Delete($"wheelspoof/{token}");
                int finalcounter = 0;
                foreach (KeyValuePair <int, int> kvp in distrib)
                {
                    finalcounter += kvp.Value;
                }
                File.WriteAllText($"wheelspoof/autoroll/{Context.User.Id}.37", DateTime.UtcNow.ToString());
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> Success! After {ts.Hours} hours, {ts.Minutes} minutes, {ts.Seconds} seconds and {finalcounter} rolls I have managed to make a winning roll! Raw response: \"{await winresponse.Content.ReadAsStringAsync()}\"  Distribution chart: ");

                await Context.Channel.SendFileAsync($"wheelspoof/barcharts/{Context.Message.Id}.png");

                File.Delete($"wheelspoof/barcharts/{Context.Message.Id}.png");
            }
            catch (Exception e)
            {
                if (File.Exists($"wheelspoof/{token}"))
                {
                    File.Delete($"wheelspoof/{token}");
                }
                throw e;
            }
        }
예제 #2
0
        public async Task MemeCommandAsync(string mp3 = null, [Remainder] string user = null)
        {
            Authorisationcheck authorisationcheck = new Authorisationcheck();

            if (!authorisationcheck.Check(Context.User.Id, _config))
            {
                return;
            }

            if (mp3 == null || user == null)
            {
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> You need to provide a sound as well as a username");

                return;
            }
            if (!File.Exists($"audio/{mp3}.wav"))
            {
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> I'm sorry, but the audio file you requested doesnt exist (yet)");

                return;
            }

            string id       = null;
            string username = "";
            var    guilds   = _client.Guilds;

            foreach (SocketGuild guild in guilds)
            {
                foreach (SocketUser user1 in guild.Users)
                {
                    if (user1.Username.ToLower() == user.ToLower())
                    {
                        id       = user1.Id.ToString();
                        username = user1.Username;
                    }
                }
            }
            if (id == null)
            {
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> I'm having trouble finding that user, please try again");

                return;
            }

            File.WriteAllText($"prank/{id}.37", mp3);
            await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> Successfully queued the user for a meme!");

            EmbedBuilder builder = new EmbedBuilder();

            builder.WithFooter("No copyright infringement intended Kappa", "https://cdn.discordapp.com/avatars/329650083819814913/33b46ac7c4bfa97c6df65b108fd8c008.png?size=512");
            var    tfile  = TagLib.File.Create($"audio/{mp3}.wav");
            string song   = tfile.Tag.Title;
            string artist = tfile.Tag.Performers.FirstOrDefault();
            string thumb  = tfile.Tag.Comment;

            builder.WithThumbnailUrl(thumb);
            builder.WithTitle($"Queued meme for user **{username}**");
            builder.WithDescription($"**{song}** by **{artist}**");
            Colorpicker picker = new Colorpicker();

            builder.WithColor(picker.Pick());
            await Context.Channel.SendMessageAsync("", false, builder.Build());
        }
예제 #3
0
        public async Task ActivitycommandAsync(string type = "reset", [Remainder] string activity = null)
        {
            Authorisationcheck authorisationcheck = new Authorisationcheck();

            if (!authorisationcheck.Check(Context.User.Id, _config))
            {
                return;
            }
            switch (type)
            {
            case "reset":
                Activitypicker picker = new Activitypicker();
                picker.Pick((DiscordSocketClient)Context.Client);
                handler.customFalse();
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> The activity has been reset!");

                break;

            case "playing":
                if (activity == null)
                {
                    await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> You need to provide an activity");

                    break;
                }
                await _client.SetGameAsync(activity, null, ActivityType.Playing);

                handler.customTrue();
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> The activity has been sucessfully set to \"Playing {activity}\"!");

                break;

            case "watching":
                if (activity == null)
                {
                    await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> You need to provide an activity");

                    break;
                }
                await _client.SetGameAsync(activity, null, ActivityType.Watching);

                handler.customTrue();
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> The activity has been sucessfully set to \"Watching {activity}\"!");

                break;

            case "listening":
                if (activity == null)
                {
                    await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> You need to provide an activity");

                    break;
                }
                if (activity.StartsWith("to "))
                {
                    activity = activity.Remove(0, 3);
                }
                handler.customTrue();
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> The activity has been sucessfully set to \"Listening to {activity}\"!");

                await _client.SetGameAsync(activity, null, ActivityType.Listening);

                break;

            case "streaming":
                if (activity == null)
                {
                    await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> You need to provide an activity");

                    break;
                }
                try
                {
                    _ = activity.Split("@")[1];
                }
                catch (IndexOutOfRangeException)
                {
                    await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> I know the help commmand doesnt say it, but this activity is special. You need to provide the activity in the following syntax: \"<activity>@<yt or twitch link>\"");

                    break;
                }
                await _client.SetGameAsync(activity.Split("@")[0], activity.Split("@")[1].Replace("<", "").Replace(">", ""), ActivityType.Streaming);

                handler.customTrue();
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> The activity has been sucessfully set to \"Streaming {activity.Split("@")[0]}\" with the link <{activity.Split("@")[1].Replace("<", "").Replace(">", "")}>!");

                break;

            default:
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> Invalid argument!");

                return;
            }
        }
예제 #4
0
        public async Task Help()
        {
            List <CommandInfo> commands     = Cservice.Commands.ToList();
            EmbedBuilder       embedBuilder = new EmbedBuilder();

            embedBuilder.WithAuthor("37 Help", "https://cdn.discordapp.com/app-icons/737060692527415466/c64109fbdff1a1f6dfd7515eaec5198d.png?size=512", "https://bit.ly/37status");
            foreach (CommandInfo command in commands)
            {
                // Get the command Summary attribute information
                if (command.Remarks == "all")
                {
                    string embedFieldText = command.Summary ?? "No description available\n";
                    embedBuilder.AddField(command.Name, embedFieldText, true);
                }
            }
            Authorisationcheck check = new Authorisationcheck();

            if (check.Check(Context.User.Id, _config))
            {
                embedBuilder.AddField("Admin Commands", "You have access to these command because you're authorized", false);
                foreach (CommandInfo command in commands)
                {
                    if (command.Remarks == "authorized")
                    {
                        string embedFieldText = command.Summary ?? "No description available\n";
                        embedBuilder.AddField(command.Name, embedFieldText, true);
                    }
                }
            }
            if (Context.User.Id.ToString() == _config["AdminUserID"])
            {
                embedBuilder.AddField("Owner Commands", "You have access to these command because you're the bot's owner", false);
                foreach (CommandInfo command in commands)
                {
                    if (command.Remarks == "owner")
                    {
                        string embedFieldText = command.Summary ?? "No description available\n";
                        embedBuilder.AddField(command.Name, embedFieldText, true);
                    }
                }
            }
            var    guildList = _client.Guilds;
            string admin     = "";

            foreach (SocketGuild guild in guildList)
            {
                foreach (SocketUser user in guild.Users)
                {
                    if (Convert.ToString(user.Id) == _config["AdminUserID"])
                    {
                        admin = user.Username + "#" + user.Discriminator;
                        goto stop;
                    }
                }
            }
            stop :;
            Colorpicker colorpicker = new Colorpicker();

            embedBuilder.WithColor(colorpicker.Pick());
            embedBuilder.WithFooter($"If you encounter any issues contact {admin}", "https://cdn.discordapp.com/avatars/329650083819814913/33b46ac7c4bfa97c6df65b108fd8c008.png?size=512");
            await ReplyAsync(null, false, embedBuilder.Build());
        }
예제 #5
0
        public async Task AddactivitycommandAsync(string type = null, [Remainder] string activity = null)
        {
            Authorisationcheck authorisationcheck = new Authorisationcheck();

            if (!authorisationcheck.Check(Context.User.Id, _config))
            {
                return;
            }
            switch (type)
            {
            case "playing":
                if (activity == null)
                {
                    await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> You need to provide an activity");

                    break;
                }
                if (!File.Exists("db/activities.37"))
                {
                    File.WriteAllText("db/activities.37", $"p {activity}");
                }
                else
                {
                    var acts = File.ReadAllText("db/activities.37");
                    File.WriteAllText("db/activities.37", acts + $"\np {activity}");
                }
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> The activity \"Playing {activity}\" has successfully been added!");

                break;

            case "watching":
                if (activity == null)
                {
                    await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> You need to provide an activity");

                    break;
                }
                if (!File.Exists("db/activities.37"))
                {
                    File.WriteAllText("db/activities.37", $"p {activity}");
                }
                else
                {
                    var acts = File.ReadAllText("db/activities.37");
                    File.WriteAllText("db/activities.37", acts + $"\nw {activity}");
                }
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> The activity \"Watching {activity}\" has successfully been added!");

                break;

            case "listening":
                if (activity == null)
                {
                    await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> You need to provide an activity");

                    break;
                }
                if (activity.StartsWith("to "))
                {
                    activity = activity.Remove(0, 3);
                }
                if (!File.Exists("db/activities.37"))
                {
                    File.WriteAllText("db/activities.37", $"l {activity}");
                }
                else
                {
                    var acts = File.ReadAllText("db/activities.37");
                    File.WriteAllText("db/activities.37", acts + $"\nl {activity}");
                }
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> The activity \"Listening {activity}\" has successfully been added!");

                break;

            default:
                await Context.Channel.SendMessageAsync($"<@{Context.User.Id}> Invalid argument!");

                return;
            }
        }