Ejemplo n.º 1
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!");
            }
        }
Ejemplo n.º 2
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));
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private async Task Ping(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
        {
            DateTimeOffset createtimestamp = msg.CreatedAt;
            DateTimeOffset timestamp       = msg.Timestamp;

            int diff = timestamp.Millisecond / 10;


            await embedrep.Good(msg, "Pong!", ":alarm_clock: Discord: " + diff + "ms\n" +
                                ":clock1: Bot: " + this.Handler.Client.Latency + "ms");
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
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:");
            }
        }
Ejemplo n.º 6
0
        private async Task Describe(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
        {
            string[]   adjs   = CommandsData.Adjectives;
            string[]   nouns  = CommandsData.Nouns;
            SocketUser toping = msg.Author;

            if (!string.IsNullOrWhiteSpace(args[0]) && msg.MentionedUsers.Count > 0)
            {
                IReadOnlyList <SocketUser> users = msg.MentionedUsers as IReadOnlyList <SocketUser>;
                toping = users[0];
            }

            Random random = new Random();
            int    times  = random.Next(1, 4);
            string result = "";

            for (int i = 0; i < times; i++)
            {
                bool of = random.Next(1, 100) > 50;
                if (of)
                {
                    result += adjs[random.Next(0, adjs.Length)] + " ";
                    result += nouns[random.Next(0, nouns.Length)].ToLower();
                    result += " of ";
                    result += nouns[random.Next(0, nouns.Length)].ToLower();
                }
                else
                {
                    string randadj = adjs[random.Next(0, adjs.Length)];
                    result += randadj;
                }
                result += " ";
            }
            result += nouns[random.Next(0, nouns.Length)].ToLower();

            bool isvowel = false;

            string[] vowels = CommandsData.Vowels;
            for (int i = 0; i < vowels.Length; i++)
            {
                if (result.StartsWith(vowels[i]))
                {
                    isvowel = true;
                    break;
                }
            }
            await embedrep.Good(msg, "Description", toping.Mention + " is " + (isvowel ? "an" : "a") + " " + result);
        }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
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!");
            }
        }
Ejemplo n.º 9
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
                                        );
                }
            }
        }
Ejemplo n.º 10
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());
                }
            }
        }
Ejemplo n.º 11
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!");
            }
        }
Ejemplo n.º 12
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());
            }
        }
Ejemplo n.º 13
0
        private async Task Avatar(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
        {
            SocketUser user = msg.Author;

            if (!string.IsNullOrWhiteSpace(args[0]))
            {
                IReadOnlyList <SocketUser> users = msg.MentionedUsers as IReadOnlyList <SocketUser>;
                user = users[0];
            }

            string       url     = user.GetAvatarUrl(ImageFormat.Png, 512);
            EmbedBuilder builder = new EmbedBuilder();

            builder.WithAuthor(msg.Author);
            builder.WithColor(new Color());
            builder.WithImageUrl(url);
            builder.WithFooter("Avatar");

            await embedrep.Send(msg, builder.Build());
        }
Ejemplo n.º 14
0
        private async Task Letters(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
        {
            string input     = args[0];
            string indicator = ":regional_indicator_";
            string result    = "";

            for (int i = 0; i < input.Length; i++)
            {
                string letter = input[i].ToString().ToLower();
                if (Regex.IsMatch(letter, @"[A-Za-z]"))
                {
                    result += indicator + letter + ": ";
                }
                else if (Regex.IsMatch(letter, @"\s"))
                {
                    result += "\t";
                }
            }
            await embedrep.Good(msg, "Letters", result);
        }
Ejemplo n.º 15
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```");
                }
            }
        }
Ejemplo n.º 16
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!");
            }
        }
Ejemplo n.º 17
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);
            }
        }
Ejemplo n.º 18
0
        private async Task Info(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
        {
            ClientInfo info = await ClientMemoryStream.GetClientInfo();

            string desc = "";

            desc += "**Name**: " + info.Name + "\n";
            desc += "**Prefix**: " + info.Prefix + "\n";
            desc += "**Commands**: " + info.CommandAmount + "\n";
            desc += "**Servers**: " + info.GuildAmount + "\n";
            desc += "**Users**: " + info.UserAmount + "\n";
            desc += "**Owner**: " + info.Owner + "\n";

            EmbedBuilder builder = new EmbedBuilder();

            builder.WithFooter("Info");
            builder.WithThumbnailUrl(info.Avatar);
            builder.WithDescription(desc);
            builder.WithColor(new Color());
            builder.WithAuthor(msg.Author);

            await embedrep.Send(msg, builder.Build());
        }
Ejemplo n.º 19
0
 private async Task Invite(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
 {
     string invite = "https://discordapp.com/oauth2/authorize?client_id=" + EBotCredentials.BOT_ID_MAIN + "&scope=bot&permissions=0";
     await embedrep.Good(msg, "Invite", invite);
 }
Ejemplo n.º 20
0
 private async Task LuaReset(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
 {
     LuaEnv.Reset((msg.Channel as SocketChannel));
     await embedrep.Good(msg, "LuaReset", "Lua state was reset for this channel");
 }
Ejemplo n.º 21
0
 private async Task Say(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
 {
     string tosay = string.Join(",", args.ToArray());
     await embedrep.Good(msg, "Say", tosay);
 }
Ejemplo n.º 22
0
 private async Task Google(CommandReplyEmbed embedrep, SocketMessage msg, List <string> args)
 {
     string apikey = EBotCredentials.GOOGLE_API_KEY;
 }