Exemple #1
0
 public static Data.Individual.User findDataUser(User user)
 {
     userScores = new Data.UserScore();
     for (int i = 0; i < userScores.users.Count; i++)
     {
         if (userScores.users[i].ID == user.Id)
         {
             return(userScores.users[i]);
         }
     }
     Data.Individual.User insert = new Data.Individual.User(user.Id, 0, 0, 0, 0, 0);
     userScores.users.Add(insert);
     return(insert);
 }
Exemple #2
0
        void IModule.Install(ModuleManager manager)
        {
            _client = manager.Client;

            info             = new Data.TextInformation();
            updater          = new Timer(10000);
            updater.Elapsed += Updater_Elapsed;
            updater.Start();

            _client.MessageReceived += _client_MessageReceived;

            manager.CreateCommands("quote", group =>
            {
                group.PublicOnly();

                group.CreateCommand("get")
                .Description("Gets the Quote at Index or Random if no Index is given")
                .Parameter("Index", ParameterType.Optional)
                .Do(async e =>
                {
                    if (e.Args[0] == "")
                    {
                        await e.Channel.SendMessage($"Quote[{new Random().Next(0, info.quotes.Count)}]:\n{info.quotes[new Random().Next(0, info.quotes.Count)]}");
                    }
                    else
                    {
                        await e.Channel.SendMessage($"Quote[{e.Args[0]}]:\n{info.quotes[int.Parse(e.Args[0])]}");
                    }
                });

                group.CreateCommand("search")
                .Description("Searches all Quote containing the keyword")
                .Parameter("keyword", ParameterType.Unparsed)
                .Do(async e =>
                {
                    string output = "";

                    for (int i = 0; i < info.quotes.Count; i++)
                    {
                        if (info.quotes[i].ToString().ToLower().Contains(e.Args[0].ToLower()))
                        {
                            output += $"Quote[{i}]:\n{info.quotes[i]}\n\n";
                        }
                    }

                    await e.Channel.SendMessage(output);
                });

                group.CreateCommand("add")
                .Description("Adds a Quote at the end of the List")
                .Parameter("Quote", ParameterType.Unparsed)
                .Do(async e =>
                {
                    info.quotes.Add($"{e.Args[0]}");
                    info.writeInformation();
                    await e.Channel.SendMessage($"Added Quote[{info.quotes.Count - 1}]");
                });

                group.CreateCommand("de")
                .Description("Removes Quote at Index")
                .Parameter("Index")
                .Do(async e =>
                {
                    info.quotes.RemoveAt(int.Parse(e.Args[0]));
                    info.writeInformation();
                    await e.Channel.SendMessage($"Removed Quote[{e.Args[0]}]");
                });
            });

            manager.CreateCommands("", group =>
            {
                group.CreateCommand("giveCookie")
                .Description("You make me survive for a few minutes longer!")
                .Do(async e =>
                {
                    info.cookies++;
                    info.writeInformation();
                    await e.Channel.SendMessage($"Up to now, I have been fed {info.cookies} cookies!");
                });

                group.CreateCommand("hug")
                .Description("SQUEEZE THEM")
                .Parameter("People", ParameterType.Unparsed)
                .Do(async e =>
                {
                    string output = "";

                    foreach (var r in e.Message.MentionedRoles)
                    {
                        output += "Every Member of the " + r.Name + " role (";

                        foreach (User u in r.Members)
                        {
                            if (!e.User.Equals(u))
                            {
                                Data.Individual.User botUser = Game.findDataUser(u);
                                Game.userScores.users.First(x => x.ID == botUser.ID).hugged += 1;
                                Game.userScores.writeScore();
                                output += $"`{u.Name}` ";
                            }
                        }
                        output += ") has been hugged by **" + e.User.Name + "**\n";
                    }

                    foreach (User u in e.Message.MentionedUsers)
                    {
                        if (!e.User.Equals(u))
                        {
                            Data.Individual.User botUser = Game.findDataUser(u);
                            Game.userScores.users.First(x => x.ID == botUser.ID).hugged += 1;
                            Game.userScores.writeScore();
                            output += $"**{u.Name}** has been hugged by **{e.User.Name}**\nAww. They have already been hugged `{Game.userScores.users.First(x => x.ID == botUser.ID).hugged}` times.\n\n";
                        }
                    }

                    await e.Channel.SendMessage(output);
                });

                group.CreateCommand("punch")
                .Description("F**k that asshole up!")
                .Parameter("People", ParameterType.Unparsed)
                .Do(async e =>
                {
                    string output = "";

                    foreach (var r in e.Message.MentionedRoles)
                    {
                        output += "Every Member of the " + r.Name + " role (";

                        foreach (User u in r.Members)
                        {
                            if (!e.User.Equals(u))
                            {
                                Data.Individual.User botUser = Game.findDataUser(u);
                                Game.userScores.users.First(x => x.ID == botUser.ID).punched += 1;
                                Game.userScores.writeScore();
                                output += $"`{u.Name}` ";
                            }
                        }
                        output += ") has been punched by **" + e.User.Name + "**\n";
                    }

                    foreach (User u in e.Message.MentionedUsers)
                    {
                        if (!e.User.Equals(u))
                        {
                            Data.Individual.User botUser = Game.findDataUser(u);
                            Game.userScores.users.First(x => x.ID == botUser.ID).punched += 1;
                            Game.userScores.writeScore();
                            output += $"**{u.Name}** has been punched by **{e.User.Name}**\nThey have already been f****d up `{Game.userScores.users.First(x => x.ID == botUser.ID).punched}` times.\n\n";
                        }
                    }

                    await e.Channel.SendMessage(output);
                });

                group.CreateCommand("kiss")
                .Description("Suck their soul out! HAHA")
                .Parameter("People", ParameterType.Unparsed)
                .Do(async e =>
                {
                    string output = "";

                    foreach (var r in e.Message.MentionedRoles)
                    {
                        output += "Every Member of the " + r.Name + " role (";

                        foreach (User u in r.Members)
                        {
                            if (!e.User.Equals(u))
                            {
                                Data.Individual.User botUser = Game.findDataUser(u);
                                Game.userScores.users.First(x => x.ID == botUser.ID).kissed += 1;
                                Game.userScores.writeScore();
                                output += $"`{u.Name}` ";
                            }
                        }
                        output += ") has been kissed by **" + e.User.Name + "**\n";
                    }

                    foreach (User u in e.Message.MentionedUsers)
                    {
                        if (!e.User.Equals(u))
                        {
                            Data.Individual.User botUser = Game.findDataUser(u);
                            Game.userScores.users.First(x => x.ID == botUser.ID).kissed += 1;
                            Game.userScores.writeScore();
                            output += $"**{u.Name}** has been kissed by **{e.User.Name}**\nDo I smell love? They have already been kissed `{Game.userScores.users.First(x => x.ID == botUser.ID).kissed}` times.\n\n";
                        }
                    }

                    await e.Channel.SendMessage(output);
                });

                group.CreateCommand("cat")
                .Description("CATS WOOF!")
                .Do(async e =>
                {
                    var jss  = new JavaScriptSerializer();
                    var dict = jss.Deserialize <dynamic>(Information.readURL("http://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC&tag=cat&fmt=json"));

                    await e.Channel.SendMessage(dict["data"]["url"]);
                });

                group.CreateCommand("gif")
                .Description("Returns random giphy gif")
                .Parameter("keyword", ParameterType.Unparsed)
                .Hide()
                .Do(async e =>
                {
                    string request = e.GetArg("keyword").Replace(' ', '+');

                    var jss  = new JavaScriptSerializer();
                    var dict = jss.Deserialize <dynamic>(Information.readURL($"http://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC&tag={request}&fmt=json"));

                    await e.Channel.SendMessage(dict["data"]["url"]);
                });
            });

            manager.CreateCommands("osu", group =>
            {
                group.CreateCommand("user")
                .Description("test")
                .Parameter("name")
                .Do(async e =>
                {
                    var dict = Module.Data.osuUser.userStats(e.GetArg("name"));

                    try { await e.Channel.SendMessage($"http://osusig.ppy.sh/image5.png?uid={dict["user_id"]}&m=15"); } catch (Exception ex) { await e.Channel.SendMessage(ex.Message); }
                });

                group.CreateCommand("signup")
                .Description("Signs you up into the Osu! Database")
                .Parameter("name")
                .Do(async e =>
                {
                    if (osuInfo.osuUsers.Exists(x => x.discordID == e.User.Id))
                    {
                        osuInfo.osuUsers.Find(x => x.discordID == e.User.Id).channels.Add(e.Channel);
                    }

                    else
                    {
                        var dict = Module.Data.osuUser.userStats(e.GetArg("name"));

                        osuInfo.osuUsers.Add(new Data.osuUser(e.User.Id, dict["user_id"], e.Channel));
                    }

                    osuInfo.writeInformation();

                    await e.Channel.SendMessage($"Signed you up on {e.Channel.Id} ({e.Channel.Name})\n" +
                                                $"Keeping track of your **{osuInfo.osuUsers.Find(x => x.discordID == e.User.Id).modeToString()}** pp.\n" +
                                                $"Change the game mode by using the !setMainMode command.");
                });

                group.CreateCommand("setMainMode")
                .Description("0 = Standard, 1 = Taiko, 2 = CtB, 3 = Mania")
                .Parameter("Mode")
                .Do(async e =>
                {
                    if (!osuInfo.osuUsers.Exists(x => x.discordID == e.User.Id))
                    {
                        return;
                    }

                    osuInfo.osuUsers.Find(x => x.discordID == e.User.Id).mainMode = "m=" + e.GetArg("Mode");
                    osuInfo.osuUsers.Find(x => x.discordID == e.User.Id).updateStats();

                    osuInfo.writeInformation();

                    await e.Channel.SendMessage("Set mode to " + e.GetArg("Mode"));
                });

                group.CreateCommand("getStats")
                .Description("Fetches and updates your Data from the DataBase")
                .Do(async e =>
                {
                    Data.osuUser OUser = osuInfo.osuUsers.Find(x => x.discordID == e.User.Id);
                    OUser.updateStats();

                    await e.Channel.SendMessage($"Name: {OUser.username}\nScore: {OUser.score} ({Math.Round(OUser.accuracy, 2)}%)\nPP: {OUser.pp}  {OUser.mainMode}\n\nhttps://osu.ppy.sh/u/{OUser.ident}");
                });

                group.CreateCommand("ranking")
                .Description("returns pp leaderboard")
                .Do(async e =>
                {
                    await e.Channel.SendMessage(osuInfo.drawDiagram(e.Server));
                });
            });

            manager.CreateCommands("overwatch", group =>
            {
                group.CreateCommand("user")
                .Description("Returns user stats")
                .Parameter("Battletag")
                .Do(async e =>
                {
                    await e.Channel.SendMessage(Data.OW_User.statsToString(e.GetArg("Battletag")));
                });

                group.CreateCommand("signup")
                .Description("In development")
                .Parameter("Battletag")
                .Do(async e =>
                {
                    if (owInfo == null)
                    {
                        await e.Channel.SendMessage("Try again in around a minute o3o");
                    }

                    if (owInfo.OW_Users.Exists(x => x.discordID == e.User.Id))
                    {
                        owInfo.OW_Users.Find(x => x.discordID == e.User.Id).channels.Add(e.Channel);
                    }

                    else
                    {
                        owInfo.OW_Users.Add(new Data.OW_User(e.User.Id, e.GetArg("Battletag"), e.Channel));
                    }

                    owInfo.writeInformation();

                    await e.Channel.SendMessage($"Signed you up on {e.Channel.Id} ({e.Channel.Name})\n" +
                                                $"Keeping track of your **IN DEVELOPMENT**");
                });

                group.CreateCommand("getStats")
                .Description("Returns your OW stats")
                .Do(async e =>
                {
                    await e.Channel.SendMessage(owInfo.OW_Users.Find(x => x.discordID == e.User.Id).statsToString());
                });

                group.CreateCommand("ranking")
                .Description("Returns top limit ranked users")
                .Parameter("Limit")
                .Do(async e =>
                {
                    await e.Channel.SendMessage(owInfo.drawDiagram(int.Parse(e.GetArg("Limit"))));
                });
            });
        }