コード例 #1
0
        internal override async Task ExecuteCommand(SocketMessage message, GuildConfig guild)
        {
            EmbedBuilder embedBuilder = new EmbedBuilder();
            bool         foundDice    = false;

            foreach (Match m in Regex.Matches(message.Content.Substring(6), "(\\d*)(#*)d(\\d+)([+-]\\d+)*"))
            {
                DicePool dice = new DicePool(m);
                embedBuilder.AddField(dice.Label, dice.SummarizeStandardRoll());
                foundDice = true;
            }
            if (!foundDice)
            {
                await Program.SendReply(message, $"Dice syntax is `{guild.commandPrefix}roll [1-100]d[1-100]<+/-[modifier]>` separated by spaces or commas. Separate dice count from number of sides with `#` for individual rolls.");
            }
            else
            {
                await Program.SendReply(message, embedBuilder);
            }
        }
コード例 #2
0
        internal override async Task ExecuteCommand(SocketMessage message, GuildConfig guild)
        {
            EmbedBuilder embedBuilder = new EmbedBuilder();

            if (!Program.IsAuthorized(message.Author, guild.GuildId))
            {
                embedBuilder.Title       = "Unauthorized.";
                embedBuilder.Description = "You are not authorized to use this command.";
            }
            else
            {
                SocketGuildChannel guildChannel = message.Channel as SocketGuildChannel;
                embedBuilder.Title       = "Unknown module.";
                embedBuilder.Description = "Module not found.";
                string[] message_contents = message.Content.Substring(1).Split(" ");

                if (message_contents.Length >= 2)
                {
                    string checkModuleName = message_contents[1].ToLower();
                    foreach (BotModule module in Program.modules)
                    {
                        if (module.moduleName.ToLower().Equals(checkModuleName))
                        {
                            List <string> result = new List <string>();
                            embedBuilder.Title = module.moduleName;
                            if (guild.enabledModules.Contains(module.moduleName))
                            {
                                result.Add($"{module.moduleName} (enabled for this guild)");
                            }
                            else
                            {
                                embedBuilder.Title = $"{module.moduleName} (disabled for this guild)";
                            }
                            embedBuilder.Description = $"{string.Join("\n", result.ToArray())}\n{module.Interrogate()}";
                            break;
                        }
                    }
                }
            }
            await Program.SendReply(message, embedBuilder);
        }
コード例 #3
0
        internal override async Task ExecuteCommand(SocketMessage message, GuildConfig guild)
        {
            ModuleWarframe wf = (ModuleWarframe)parent;

            if (wf.alerts.Count <= 0)
            {
                await Program.SendReply(message, "There are no mission alerts available currently, Tenno.");
            }
            else
            {
                EmbedBuilder embedBuilder = new EmbedBuilder();
                foreach (KeyValuePair <string, Dictionary <string, string> > alertInfo in wf.alerts)
                {
                    if (alertInfo.Value["Expires"] != "unknown")
                    {
                        embedBuilder.AddField($"{alertInfo.Value["Header"]} - {alertInfo.Value["Mission Type"]} ({alertInfo.Value["Faction"]})", $"{alertInfo.Value["Level"]}. Expires in {alertInfo.Value["Expires"]}.\nRewards:{alertInfo.Value["Rewards"]}");
                    }
                }
                await Program.SendReply(message, embedBuilder);
            }
        }
コード例 #4
0
        internal override void ListenTo(SocketMessage message, GuildConfig guild)
        {
            string searchSpace = message.Content.ToLower();

            if (searchSpace.Contains("hek"))
            {
                Task.Run(() => Program.SendReply(message.Channel, hekPostStrings[Program.rand.Next(hekPostStrings.Count)]));
            }
            else if (searchSpace.Contains("ordis"))
            {
                Task.Run(() => Program.SendReply(message.Channel, ordisPostStrings[Program.rand.Next(ordisPostStrings.Count)]));
            }
            else if (searchSpace.Contains("look at them"))
            {
                Task.Run(() => Program.SendReply(message.Channel, vorPostStrings[Program.rand.Next(vorPostStrings.Count)]));
            }
            else if (searchSpace.Contains("hunter") || searchSpace.Contains("simaris") || searchSpace.Contains("sanctuary"))
            {
                Task.Run(() => Program.SendReply(message.Channel, simarisPostStrings[Program.rand.Next(simarisPostStrings.Count)]));
            }
        }
コード例 #5
0
ファイル: CommandFate.cs プロジェクト: MistakeNot4892/Agatha2
        internal override async Task ExecuteCommand(SocketMessage message, GuildConfig guild)
        {
            EmbedBuilder embedBuilder = new EmbedBuilder();
            int          mod          = 0;
            Match        m            = Regex.Match(message.Content, "([-+])(\\d+)");

            if (m.Success)
            {
                mod = Convert.ToInt32(m.Groups[2].ToString());
                if (m.Groups[1].ToString().Equals("-"))
                {
                    mod = -(mod);
                }
            }

            DicePool dice        = new DicePool($"4d3", "FATE");
            int      resultValue = (dice.CountAtOrAbove(3) - dice.CountAtOrBelow(1)) + mod;
            string   modString   = (resultValue >= 0) ? $"+{mod}" : $"{mod}";
            string   descriptiveResult;

            if (resultValue > 7)
            {
                descriptiveResult = $"+{resultValue}, Legendary!";
            }
            else if (resultValue < -2)
            {
                descriptiveResult = $"{resultValue}, Abysmal...";
            }
            else
            {
                string resultKey = (resultValue < 0) ? $"{resultValue}" : $"+{resultValue}";
                descriptiveResult = $"{resultKey}, {fateTiers[resultKey]}";
            }

            embedBuilder.Description = descriptiveResult;
            embedBuilder.AddField("Rolled", $"{dice.SummarizePoolRoll(-2)} ({modString})");
            await Program.SendReply(message, embedBuilder);
        }
コード例 #6
0
ファイル: CommandSS13status.cs プロジェクト: Lohikar/Agatha2
 internal override async Task ExecuteCommand(SocketMessage message, GuildConfig guild)
 {
     await message.Channel.SendMessageAsync("Not implemented, sorry.");
 }
コード例 #7
0
 internal override async Task ExecuteCommand(SocketMessage message, GuildConfig guild)
 {
     await message.Channel.SendMessageAsync($"{message.Author.Mention}: {Program.ApplyCypher(message.Content.Substring(message.Content.Split(" ")[0].Length), "grineer")}");
 }
コード例 #8
0
        internal override async Task ExecuteCommand(SocketMessage message, GuildConfig guild)
        {
            EmbedBuilder embedBuilder = new EmbedBuilder();

            embedBuilder.Title       = "Riven price checker";
            embedBuilder.Description = "Oops! Something broke.";

            try
            {
                if (rivenDataCache == null || lastRivenUpdate == null || lastRivenUpdate.Date.CompareTo(DateTime.UtcNow.Date) != 0)
                {
                    lastRivenUpdate = DateTime.UtcNow;
                    WebClient client = new WebClient();
                    rivenDataCache = JArray.Parse((string)client.DownloadString("http://n9e5v4d8.ssl.hwcdn.net/repos/weeklyRivensPC.json"));
                    Program.WriteToLog($"Riven data refreshed.");
                }

                string fullMsg     = message.Content.ToString().ToLower();
                int    searchPoint = fullMsg.IndexOf(' ');
                string rivenName;
                if (searchPoint >= 0)
                {
                    rivenName = fullMsg.Substring(searchPoint).Trim();
                    if (rivenName != null && rivenName != "")
                    {
                        List <string> matches = new List <string>();
                        foreach (JToken riven in rivenDataCache)
                        {
                            /*
                             *      {
                             *              "itemType" : "Melee Riven Mod",
                             *              "compatibility" : null,
                             *              "rerolled" : false,
                             *              "avg" : 36.11,
                             *              "stddev" : 68.23,
                             *              "min" : 2,
                             *              "max" : 4260,
                             *              "pop" : 97,
                             *              "median" : 35
                             *      },
                             */

                            string checkingName      = riven["compatibility"]?.ToString();
                            string cleanCheckingName = checkingName?.ToLower();
                            if (cleanCheckingName != null && cleanCheckingName.IndexOf(rivenName) >= 0 && !matches.Contains(checkingName))
                            {
                                matches.Add(checkingName);
                            }
                        }

                        if (matches.Count > 1)
                        {
                            embedBuilder.Description = $"There were several possible Rivens for your search term. Did you mean: {string.Join(", ", matches.ToArray())}?";
                        }
                        else if (matches.Count == 1)
                        {
                            string rivenTitle = matches[0];
                            int    entries    = 0;
                            int    hig        = 0;
                            int    low        = 0;
                            int    sld        = 0;
                            double avg        = 0;

                            foreach (JToken riven in rivenDataCache)
                            {
                                if (rivenTitle.CompareTo(riven["compatibility"]?.ToString()) != 0)
                                {
                                    continue;
                                }
                                entries++;
                                int rivMin = (int)riven["min"];
                                if (low == 0 || rivMin <= low)
                                {
                                    low = rivMin;
                                }
                                int rivMax = (int)riven["max"];
                                if (rivMax >= hig)
                                {
                                    hig = rivMax;
                                }
                                sld += (int)riven["pop"];
                                avg += (double)riven["median"];
                            }
                            avg /= entries;
                            embedBuilder.Title       = rivenTitle;
                            embedBuilder.Description = "Here are your search results, Tenno.";
                            embedBuilder.AddField("Highest price", $"{hig}");
                            embedBuilder.AddField("Lowest price", $"{low}");
                            embedBuilder.AddField("Sold today", $"{sld}");
                        }
                        else
                        {
                            embedBuilder.Description = "There were no Rivens matching your string sold today, Tenno. Maybe try riven.market?";
                        }
                    }
                    else
                    {
                        embedBuilder.Description = "Please specify a name or partial name of the Riven you wish to search for.";
                    }
                }
                else
                {
                    embedBuilder.Description = "Please specify a name or partial name of the Riven you wish to search for.";
                }
            }
            catch (Exception e)
            {
                Program.WriteToLog($"Exception when showing riven prices: {e.ToString()}.");
                embedBuilder.Description = "Something broke, sorry. Try again later.";
            }
            await Program.SendReply(message.Channel, embedBuilder);
        }
コード例 #9
0
ファイル: CommandReadnews.cs プロジェクト: Lohikar/Agatha2
        internal override async Task ExecuteCommand(SocketMessage message, GuildConfig guild)
        {
            ModuleAetolia aetolia = (ModuleAetolia)parent;

            string[] message_contents = message.Content.Substring(1).Split(" ");
            string   result;

            if (message_contents.Length < 2)
            {
                result = "Please specify a news section name.";
            }
            else if (message_contents.Length < 3)
            {
                result = "Please specify an article number.";
            }
            else
            {
                result = "Invalid article number or news section.";
                string postSection = message_contents[1].ToLower();
                string postNumber  = message_contents[2].ToLower();

                if (postSection.Equals("random") || postNumber.Equals("random"))
                {
                    HttpWebResponse newsInfo = aetolia.GetAPIResponse("news");
                    if (newsInfo != null)
                    {
                        var s = newsInfo.GetResponseStream();
                        if (s != null)
                        {
                            Dictionary <string, string> sections = new Dictionary <string, string>();
                            StreamReader sr = new StreamReader(s);
                            foreach (var x in JToken.Parse(sr.ReadToEnd()))
                            {
                                sections.Add(x["name"].ToString().ToLower(), x["total"].ToString());
                            }
                            if (postSection.Equals("random"))
                            {
                                int randInd = Program.rand.Next(sections.Count);
                                postSection = sections.ElementAt(randInd).Key.ToString();
                            }
                            if (postNumber.Equals("random") && sections.ContainsKey(postSection))
                            {
                                int tempValue = Convert.ToInt32(sections[postSection]);
                                postNumber = Program.rand.Next(tempValue).ToString();
                            }
                        }
                    }
                }

                HttpWebResponse aetInfo = aetolia.GetAPIResponse($"news/{postSection}/{postNumber}");
                if (aetInfo != null)
                {
                    var s = aetInfo.GetResponseStream();
                    if (s != null)
                    {
                        StreamReader sr       = new StreamReader(s);
                        JObject      postInfo = JObject.Parse(sr.ReadToEnd());
                        JToken       ci       = postInfo["post"];
                        DateTime     postDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                        postDate = postDate.AddSeconds((int)ci["date"]);

                        result = $"```\n{ci["section"].ToString().ToUpper()} NEWS {ci["id"].ToString().ToUpper()}";
                        result = $"{result}\nDate: {postDate}";
                        result = $"{result}\nFrom: {ci["from"]}";
                        result = $"{result}\nTo:   {ci["to"]}";
                        result = $"{result}\nSubj: {ci["subject"]}\n";
                        string postString = ci["message"].ToString();
                        if (postString.Length > 1500)
                        {
                            string newsURL = $"https://www.aetolia.com/news/?game=Aetolia&section={ci["section"].ToString()}&number={ci["id"].ToString()}";
                            postString = $"{postString.Substring(0,1500)}...```\nPost has been trimmed for Discord: see the full text at {newsURL}.";
                        }
                        else
                        {
                            postString = $"{postString}```";
                        }
                        result = $"{result}\n{postString}";
                    }
                }
            }
            await message.Channel.SendMessageAsync($"{message.Author.Mention}: {result}");
        }
コード例 #10
0
ファイル: BotModule.cs プロジェクト: MistakeNot4892/Agatha2
 internal virtual void ListenTo(SocketMessage message, GuildConfig guild)
 {
 }
コード例 #11
0
        internal override async Task ExecuteCommand(SocketMessage message, GuildConfig guild)
        {
            SocketGuildChannel guildChannel = message.Channel as SocketGuildChannel;
            EmbedBuilder       embedBuilder = new EmbedBuilder();
            string             result       = $"{Program.modules.Count} modules loaded.";

            string[] message_contents = message.Content.Substring(1).Split(" ");
            if (message_contents.Length < 2)
            {
                string moduleList = "";
                foreach (BotModule module in Program.modules)
                {
                    string tmpModName = module.moduleName.ToString();
                    if (guild.enabledModules.Contains(tmpModName))
                    {
                        moduleList = $"{moduleList}{tmpModName}\n";
                    }
                    else
                    {
                        moduleList = $"{moduleList}~~{tmpModName}~~ (disabled for this guild)\n";
                    }
                }
                embedBuilder.AddField("Modules", (moduleList == null || moduleList == "") ? "No modules available." : moduleList);
            }
            else
            {
                string    checkModuleName = message_contents[1].ToLower();
                BotModule foundModule     = null;
                foreach (BotModule module in Program.modules)
                {
                    if (module.moduleName.ToLower().Equals(checkModuleName))
                    {
                        foundModule = module;
                        break;
                    }
                }

                if (foundModule == null)
                {
                    embedBuilder.Title       = "Unknown module.";
                    embedBuilder.Description = "Module not found.";
                }
                else if (message_contents.Length >= 3)
                {
                    embedBuilder.Title = foundModule.moduleName;
                    if (message_contents[2].ToLower().Equals("enable") || message_contents[2].ToLower().Equals("disable"))
                    {
                        if (!Program.IsAuthorized(message.Author, guildChannel.Guild.Id))
                        {
                            embedBuilder.Description = "This command can only be used by a bot admin, sorry.";
                        }
                        else
                        {
                            GuildConfig checkGuild   = Program.GetGuildConfig(guildChannel.Guild.Id);
                            bool        enableModule = message_contents[2].ToLower().Equals("enable");
                            if (enableModule)
                            {
                                embedBuilder.Description = checkGuild.EnableModule(foundModule);
                            }
                            else
                            {
                                embedBuilder.Description = checkGuild.DisableModule(foundModule);
                            }
                        }
                    }
                    else if (message_contents[2].ToLower().Equals("config"))
                    {
                        embedBuilder.Description = "Sorry, not implemented.";
                    }
                    else
                    {
                        embedBuilder.Description = "Valid options are `enable`, `disable` and `config`.";
                    }
                }
                else
                {
                    if (guild.enabledModules.Contains(foundModule.moduleName))
                    {
                        embedBuilder.Title = $"{foundModule.moduleName} (enabled for this guild)";
                    }
                    else
                    {
                        embedBuilder.Title = $"{foundModule.moduleName} (disabled for this guild)";
                    }
                    embedBuilder.Description = foundModule.description;
                    string cmds = "";
                    foreach (BotCommand command in Program.commands)
                    {
                        if (command.parent == foundModule)
                        {
                            cmds = $"{cmds}{command.aliases[0].ToString()}\n";
                        }
                    }
                    if (!cmds.Equals(""))
                    {
                        embedBuilder.AddField("Commands", cmds);
                    }
                }
            }
            await Program.SendReply(message, embedBuilder);
        }
コード例 #12
0
 internal override async Task ExecuteCommand(SocketMessage message, GuildConfig guild)
 {
     await Program.SendReply(message, comments[Program.rand.Next(comments.Count)]);
 }
コード例 #13
0
 internal override async Task ExecuteCommand(SocketMessage message, GuildConfig guild)
 {
     await Program.SendReply(message, "Not implemented, sorry.");
 }
コード例 #14
0
 internal abstract Task ExecuteCommand(SocketMessage message, GuildConfig guild);
コード例 #15
0
ファイル: CommandAltprompt.cs プロジェクト: Lohikar/Agatha2
        internal override async Task ExecuteCommand(SocketMessage message, GuildConfig guild)
        {
            EmbedBuilder embedBuilder = new EmbedBuilder();
            string       aetHis       = "Their";
            string       aethis       = "their";
            string       aetHe        = "They";
            string       aethe        = "they";
            string       aethim       = "them";
            string       aetIs        = "are";
            string       aetLives     = "live";

            List <string> _genders = new List <string>()
            {
                "a male", "a female", "an androgynous", "a genderfluid"
            };
            string aetGender = _genders[Program.rand.Next(4)];

            if (aetGender.Equals("a female"))
            {
                aetHis   = "Her";
                aethis   = "her";
                aetHe    = "She";
                aethe    = "she";
                aethim   = "her";
                aetIs    = "is";
                aetLives = "lives";
            }
            else if (aetGender.Equals("a male"))
            {
                aetHis   = "His";
                aethis   = "his";
                aetHe    = "He";
                aethe    = "he";
                aethim   = "him";
                aetIs    = "is";
                aetLives = "lives";
            }

            List <string> _races = new List <string>()
            {
                "Arqeshi", "Atavian", "Dwarf", "Grecht", "Grook", "Human", "Horkval", "Imp", "Kelki", "Kobold", "Mhun", "Nazetu", "Ogre", "Orc", "Rajamala", "Troll", "Tsol'aa", "Xoran"
            };
            string aetRace = _races[Program.rand.Next(_races.Count)];

            List <string> _regions = new List <string>()
            {
                "Mournhold", "Arbothia", "Tasur'ke", "Siha Dylis", "Tainhelm", "Kentorakro", "Stormcaller Crag", "Jaru", "the wilderness", "the eastern isles", "another continent", "another plane", "the western isles", "the deep forests", "the tundra", "the mountains", "the desert", "the southern coast", "the eastern coast", "the western coast", "beneath the hills", "a bustling town"
            };
            string aetRegion = _regions[Program.rand.Next(_regions.Count)];

            List <string> _backgrounds = new List <string>()
            {
                "an outcast", "a noble", "a farmer", "a hunter", "a guard", "a tracker", "a serf", "a slave", "a trader", "a feral child", "a nomad", "an apprentice smith", "an unwanted burden"
            };
            string aetBackground = _backgrounds[Program.rand.Next(_backgrounds.Count)];

            List <string> _cities = new List <string>()
            {
                "in Spinesreach", "in Enorian", "in Duiran", "in Bloodloch", "in Delve", "in Esterport", "nowhere in particular"
            };
            string        aetCity = _cities[Program.rand.Next(_cities.Count)];
            List <string> _guilds;

            switch (aetCity)
            {
            case "in Spinesreach":
                _guilds = new List <string>()
                {
                    "Archivists", "Sciomancers", "Syssin", "Praenomen"
                };
                break;

            case "in Enorian":
                _guilds = new List <string>()
                {
                    "Ascendril", "Templars", "Illuminai"
                };
                break;

            case "in Bloodloch":
                _guilds = new List <string>()
                {
                    "Carnifex", "Indorani", "Teradrim", "Praenomen"
                };
                break;

            case "in Duiran":
                _guilds = new List <string>()
                {
                    "Shamans", "Sentinels", "Monks"
                };
                break;

            default:
                _guilds = new List <string>()
                {
                    "Archivists", "Sciomancers", "Syssin", "Ascendril", "Templars", "Illuminai", "Carnifex", "Indorani", "Teradrim", "Praenomen", "Shamans", "Sentinels", "Monks"
                };
                break;
            }
            string aetGuild = _guilds[Program.rand.Next(_guilds.Count)];

            string otherClass = "";

            if (Program.rand.Next(4) == 4)
            {
                List <string> _otherClasses = new List <string>()
                {
                    "Werecroc", "Wereboar", "Wereraven", "Werebear", "Werewolf", "Wayfarer"
                };
                otherClass = $" However, despite {aethis} guild membership, {aethe} {aetIs} actually a {_otherClasses[Program.rand.Next(_otherClasses.Count)]}.";
            }

            List <string> _interests = new List <string>()
            {
                "architecture", "art", "beauty", "friendship", "gadgetry", "knowledge", "magic", "mining", "money", "nature", "politics", "power", "stories", "tomfoolery", "gemstones", "science", "exploration", "adventure", "agriculture", "pranks", "music", "dancing", "swimming", "philosophy"
            };

            _interests = Shuffle(_interests);
            string aetInterestOne   = _interests[0];
            string aetInterestTwo   = _interests[1];
            string aetInterestThree = _interests[2];

            List <string> _personality = new List <string>()
            {
                "agreeable", "neurotic", "calm", "foolish", "focused", "witty", "blunt", "dull", "arrogant", "awesome", "depressed", "easily distracted", "eccentric", "gullible", "hyperactive", "insulting", "irrational", "joyful", "lazy", "mysterious", "shy", "stupid", "violent", "warlike", "weird", "naive", "timid", "rambunctious", "swindling", "helpful", "brazen", "neurotic", "impressionable", "blithe", "forgetful", "uncoordinated"
            };

            _personality = Shuffle(_personality);
            string aetPersonalityOne   = _personality[0];
            string aetPersonalityTwo   = _personality[1];
            string aetPersonalityThree = _personality[2];

            string result = $"You should play {aetGender} {aetRace} from {aetRegion}.";

            result = $"{result}\n{aetHe} grew up as {aetBackground} and now {aetLives} {aetCity} as a member of the {aetGuild}.{otherClass}";
            result = $"{result}\n{aetHe} {aetIs} interested in {aetInterestOne}, {aetInterestTwo} and {aetInterestThree}.";
            result = $"{result}\n{aetHis} friends describe {aethim} as {aetPersonalityOne}, {aetPersonalityTwo} and {aetPersonalityThree}.";
            embedBuilder.Description = result;
            await message.Channel.SendMessageAsync($"{message.Author.Mention}:", false, embedBuilder);
        }