Exemple #1
0
        private async Task SearchUrban(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
        {
            string search = "";

            if (string.IsNullOrWhiteSpace(args[0]))
            {
                await embedrep.Danger(msg, "Urban", "No entry to look for was given");
            }
            else
            {
                int page = 0;
                if (args.Count > 1)
                {
                    if (!string.IsNullOrWhiteSpace(args[1]))
                    {
                        if (int.TryParse(args[1].Trim(), out int temp))
                        {
                            page = temp - 1;
                        }
                    }
                }

                search = args[0];
                string body = await HTTP.Fetch("http://api.urbandictionary.com/v0/define?term=" + search, this.Log);

                Urban.UGlobal global = JSON.Deserialize <Urban.UGlobal>(body, this.Log);

                if (global == null)
                {
                    await embedrep.Danger(msg, "Err", "There was no data to use for this!");
                }
                else
                {
                    if (global.list.Length == 0)
                    {
                        await embedrep.Danger(msg, "Arf!", "Looks like I couldn't find anything!");
                    }
                    else
                    {
                        if (global.list.Length - 1 >= page && page >= 0)
                        {
                            Urban.UWord wordobj    = global.list[page];
                            bool        hasexample = string.IsNullOrWhiteSpace(wordobj.example);
                            string      smalldef   = wordobj.definition.Length > 300 ? wordobj.definition.Remove(300) + "..." : wordobj.definition;
                            await embedrep.Good(msg, "Definition #" + (page + 1),
                                                "**" + wordobj.permalink + "**\n\n"
                                                + smalldef + (!hasexample ? "\n\nExample:\n\n*" + wordobj.example + "*" : "") + "\n\n" +
                                                ":thumbsup: x" + wordobj.thumbs_up + "\t :thumbsdown: x" + wordobj.thumbs_down);
                        }
                        else
                        {
                            await embedrep.Danger(msg, "uh", "No result for definition n°" + (page + 1));
                        }
                    }
                }
            }
        }
Exemple #2
0
        private async Task SearchE621(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
        {
            if (msg.Channel.IsNsfw)
            {
                Random rand = new Random();
                string body = await HTTP.Fetch("https://e621.net/post/index.json", this.Log);

                List <E621.EPost> posts = JSON.Deserialize <List <E621.EPost> >(body, this.Log);
                E621.EPost        post;

                if (posts == null)
                {
                    await embedrep.Danger(msg, "Err", "There was no data to use sorry!");
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(args[0]))
                    {
                        post = E621.SortingHandler.GetRandom(posts);
                    }
                    else
                    {
                        post = E621.Search.Handle(posts, args);
                    }

                    if (post == null)
                    {
                        await embedrep.Danger(msg, "Nooo", "Seems like I couldn't find anything!");
                    }
                    else
                    {
                        EmbedBuilder embed = new EmbedBuilder
                        {
                            Color       = new Color(110, 220, 110),
                            ImageUrl    = post.sample_url,
                            Title       = "E621 - " + msg.Author.Username,
                            Description = post.sample_url + "\n*Width: " + post.sample_width + "\tHeight: " + post.sample_height + "*"
                        };

                        await embedrep.Send(msg, embed.Build());
                    }
                }
            }
            else
            {
                await embedrep.Danger(msg, "Hum no.", "Haha, did you really believe it would be that easy? :smirk:");
            }
        }
Exemple #3
0
        private async Task BlackWhite(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
        {
            string url  = string.IsNullOrWhiteSpace(args[0]) ? Handler.GetLastPictureURL((msg.Channel as SocketChannel)) : args[0];
            string path = null;

            if (!string.IsNullOrWhiteSpace(url)) //if getlastpicture returns nothing
            {
                path = await ImageProcess.DownloadImage(url);
            }

            if (path != null)
            {
                try
                {
                    ImageProcess.Resize(path);
                    ImageProcess.MakeBlackWhite(path);

                    await msg.Channel.SendFileAsync(path);

                    ImageProcess.DeleteImage(path);
                }catch (Exception e)
                {
                    BotLog.Debug(e.ToString());
                }
            }

            if (path == null)
            {
                await embedrep.Danger(msg, "Ugh", "There's no valid url to use!");
            }
        }
Exemple #4
0
        private async Task ASCII(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
        {
            if (string.IsNullOrWhiteSpace(args[0]))
            {
                await embedrep.Danger(msg, "Nope", "You didn't provide any word or sentence!");
            }
            else
            {
                string body = await HTTP.Fetch("http://artii.herokuapp.com/make?text=" + args[0], Log);

                if (body.Length > 2000)
                {
                    await embedrep.Danger(msg, "ASCII", "The word or sentence you provided is too long!");
                }
                else
                {
                    await msg.Channel.SendMessageAsync("```\n" + body + "\n```");
                }
            }
        }
Exemple #5
0
        private async Task EightBalls(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
        {
            if (string.IsNullOrWhiteSpace(args[0]))
            {
                await embedrep.Danger(msg, "Nope", "You didn't provide any word or sentence!");
            }
            else
            {
                Random   rand    = new Random();
                string[] answers = CommandsData.HeightBallAnswers;
                string   answer  = answers[rand.Next(0, answers.Length - 1)];

                await embedrep.Good(msg, "8ball", answer);
            }
        }
Exemple #6
0
        private async Task Pick(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
        {
            if (string.IsNullOrWhiteSpace(args[0]))
            {
                await embedrep.Danger(msg, "Nope", "You didn't provide any/enough word(s)!");
            }
            else
            {
                string[] answers = CommandsData.PickAnswers;
                Random   rand    = new Random();
                string   choice  = args[rand.Next(0, args.Count - 1)].Trim();
                string   answer  = answers[rand.Next(0, answers.Length - 1)].Replace("<answer>", choice);

                await embedrep.Good(msg, "Pick", answer);
            }
        }
Exemple #7
0
        private async Task Slap(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
        {
            Social.Action action             = new Social.Action();
            string        result             = "";
            IReadOnlyList <SocketUser> users = msg.MentionedUsers as IReadOnlyList <SocketUser>;

            if (!string.IsNullOrWhiteSpace(args[0]) && users.Count > 0)
            {
                result = action.Slap(msg.Author, (msg.MentionedUsers as IReadOnlyList <SocketUser>));
                await embedrep.Good(msg, "Slap!", result);
            }
            else
            {
                await embedrep.Danger(msg, "Aw", "You need to mention the persons you want to slap!");
            }
        }
Exemple #8
0
        private async Task Alerts(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
        {
            string body = await HTTP.Fetch("http://content.warframe.com/dynamic/worldState.php", this.Log);

            WGlobal global = JSON.Deserialize <WGlobal>(body, this.Log);

            if (global == null)
            {
                await embedrep.Danger(msg, "Err", "Looks like I couldn't access date for that!");
            }
            else
            {
                for (int i = 0; i < global.Alerts.Length; i++)
                {
                    WAlert   alert   = global.Alerts[i];
                    WMission minfo   = alert.MissionInfo;
                    WReward  mreward = minfo.missionReward;

                    DateTime endtime = DateTime.Now.Date.AddTicks(alert.Expiry.date.numberLong);
                    DateTime offset  = new DateTime().AddHours(5); //canada time offset (server hosted in germany)
                    DateTime nowtime = new DateTime(DateTime.Now.Subtract(offset).Ticks);

                    string showrewards = "";

                    if (mreward.items != null)
                    {
                        showrewards = "**Items**: \n";
                        for (int j = 0; j < mreward.items.Length; j++)
                        {
                            string[] dirs = mreward.items[j].Split("/");
                            string   name = dirs[dirs.Length - 1];

                            showrewards += "\t\t" + name + "\n";
                        }
                    }

                    await embedrep.Good(msg, "Warframe Alert #" + (i + 1),
                                        "**Level**: " + minfo.minEnemyLevel + " - " + minfo.maxEnemyLevel + "\t**Type**: " + minfo.missionType.Substring(3).ToLower().Replace("_", " ")
                                        + "\t**Enemy**: " + minfo.faction.Substring(3).ToLower() + "\n"
                                        + "**Credits**: " + mreward.credits + "\t**Time Left**: " + (endtime.Subtract(nowtime).Minutes) + "mins\n"
                                        + showrewards
                                        );
                }
            }
        }
Exemple #9
0
        private async Task Markov(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
        {
            if (!string.IsNullOrWhiteSpace(args[0]))
            {
                string sentence = string.Join(",", args.ToArray());

                try
                {
                    string generated = await MarkovHandler.Generate(sentence);

                    await embedrep.Good(msg, "Markov", generated);
                }
                catch (Exception e)
                {
                    await embedrep.Danger(msg, "Markov", "Something went wrong:\n" + e.ToString());
                }
            }
        }
Exemple #10
0
        private async Task Server(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
        {
            if (msg.Channel is IGuildChannel)
            {
                SocketGuild guild = (msg.Channel as IGuildChannel).Guild as SocketGuild;
                RestUser    owner = await this.Handler.RESTClient.GetUserAsync(guild.OwnerId);

                string info = "";
                info += "**ID**: " + guild.Id + "\n";
                info += "**Owner**: " + (owner == null ? "NULL\n" : owner.Username + "#" + owner.Discriminator + "\n");
                info += "**Members**: " + guild.MemberCount + "\n";
                info += "**Region**: " + guild.VoiceRegionId + "\n";

                if (guild.Emotes.Count > 0)
                {
                    info += "\n\n---- Emojis ----\n";

                    int count = 0;
                    foreach (Emote emoji in guild.Emotes)
                    {
                        info += "<:" + emoji.Name + ":" + emoji.Id + ">  ";
                        count++;
                        if (count >= 10)
                        {
                            info += "\n";
                            count = 0;
                        }
                    }
                }

                EmbedBuilder builder = new EmbedBuilder();
                builder.WithThumbnailUrl(guild.IconUrl);
                builder.WithDescription(info);
                builder.WithFooter(guild.Name);
                builder.WithColor(new Color());
                builder.WithAuthor(msg.Author);

                await embedrep.Send(msg, builder.Build());
            }
            else
            {
                await embedrep.Danger(msg, "Hey!", "You can't do that in a DM channel!");
            }
        }
Exemple #11
0
        private async Task Help(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
        {
            string arg = args[0];

            if (!string.IsNullOrWhiteSpace(arg))
            {
                bool retrieved = this.Handler.Commands.TryGetValue(arg.ToLower().Trim(), out Command cmd);
                if (retrieved)
                {
                    await embedrep.Warning(msg, "Help [ " + arg + " ]", cmd.GetHelp());
                }
                else
                {
                    await embedrep.Danger(msg, "Help", "Couldn't find documentation for \"" + arg + "\"");
                }
            }
            else
            {
                if (!(msg.Channel is IDMChannel))
                {
                    await embedrep.Good(msg, "Help", "Check your private messages " + msg.Author.Mention);
                }

                Dictionary <string, Command> cmds = this.Handler.Commands;
                string result = "``";
                uint   count  = 0;
                foreach (KeyValuePair <string, Command> cmd in cmds)
                {
                    result += cmd.Key + ",";
                    count++;
                    if (count > 5)
                    {
                        result += "\n";
                        count   = 0;
                    }
                }
                result  = result.Remove(result.Length - 2);
                result += "``";

                await embedrep.RespondByDM(msg, "Help [ all ]", result, new Color());
            }
        }
Exemple #12
0
        private async Task Wew(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
        {
            string url      = string.IsNullOrWhiteSpace(args[0]) ? Handler.GetLastPictureURL((msg.Channel as SocketChannel)) : args[0];
            string path     = null;
            string maskpath = "Masks/wew.png";

            if (!string.IsNullOrWhiteSpace(url)) //if getlastpicture returns nothing
            {
                path = await ImageProcess.DownloadImage(url);
            }

            if (path != null)
            {
                await embedrep.Good(msg, "WIP", "Sorry this command is under work!");
            }

            if (path == null)
            {
                await embedrep.Danger(msg, "Ugh", "There's no valid url to use!");
            }
        }
Exemple #13
0
        private async Task Lua(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
        {
            string        code    = string.Join(',', args);
            List <Object> returns = new List <object>();
            bool          success = LuaEnv.Run(msg, code, out returns, out string error, this.Log);

            if (success)
            {
                string display = string.Join('\t', returns);
                if (string.IsNullOrWhiteSpace(display))
                {
                    await embedrep.Good(msg, "Lua", ":ok_hand: (nil or no value was returned)");
                }
                else
                {
                    await embedrep.Good(msg, "Lua", display);
                }
            }
            else
            {
                await embedrep.Danger(msg, "Lua", error);
            }
        }