public void ModuleFilenameInitInFolder()
        {
            var result = ModuleUtilities.ModuleFileName("module2");

            Assert.IsNotNull(result);
            Assert.IsTrue(result.EndsWith("__init__.py"));
        }
Exemple #2
0
        public async Task Rankings(string input = "noIm")
        {
            if (input != "noIm" && input != "im")
            {
                input = "noIm";
            }
            dynamic result = ModuleUtilities.GetJsonFromEndpoint(OwlUrl + "rankings");
            //var content = result["content"];
            List <string> teams = OWLUtilities.ParseTeamInfo(result, input);

            if (input == "im")
            {
                foreach (string team in teams)
                {
                    await ReplyAsync(team);
                }
            }
            else if (input == "noIm")
            {
                string outputString = "";
                foreach (string team in teams)
                {
                    outputString += team;
                }
                await ReplyAsync(outputString);
            }
        }
        public void LoadModulesFromLib()
        {
            var context = new BindingEnvironment();

            Assert.IsNotNull(ModuleUtilities.LoadModule("module1", context));
            Assert.IsNotNull(ModuleUtilities.LoadModule("module2", context));
        }
        public void ModuleFilename()
        {
            var result = ModuleUtilities.ModuleFileName("module1");

            Assert.IsNotNull(result);
            Assert.IsTrue(result.EndsWith("module1.py"));
        }
Exemple #5
0
        public async Task Flip([Remainder] string input)
        {
            await ModuleUtilities.DeleteMessage(Context);

            string flippedString = "";

            foreach (char letter in input)
            {
                if (Char.IsLetter(letter))
                {
                    if (Char.IsUpper(letter))
                    {
                        flippedString = Regex.Unescape(SpeakModObjects.flipDicCaps[letter.ToString()]).Normalize() + flippedString;
                    }
                    else
                    {
                        flippedString = Regex.Unescape(SpeakModObjects.flipDicLower[letter.ToString()]).Normalize() + flippedString;
                    }
                }
                else
                {
                    flippedString = letter + flippedString;
                }
            }

            await ReplyAsync(flippedString);
        }
Exemple #6
0
        public List <ModuleInfo> GetModuleInfos()
        {
            var installedModules  = _contentManager.LoadAllModules().ToList();
            var referencedModules = ModuleUtilities.GetLoadedModuleAssemblies();

            var moduleInfos = new List <ModuleInfo>();

            foreach (var referencedModule in referencedModules.Select(m => m.Item1))
            {
                var    moduleName             = _moduleBuilder.GetModuleNameFromAssembly(referencedModule);
                var    installedModule        = installedModules.FirstOrDefault(m => m.Name == moduleName);
                string moduleInstalledVersion = null;
                Guid?  installedModuleId      = null;

                if (installedModule != null)
                {
                    installedModules.Remove(installedModule);
                    moduleInstalledVersion = installedModule.Version;
                    installedModuleId      = installedModule.Id;
                }

                var moduleInfo = new ModuleInfo(moduleName, moduleInstalledVersion, _moduleBuilder.GetModuleVersionFromAssembly(referencedModule), installedModuleId);

                moduleInfos.Add(moduleInfo);
            }

            moduleInfos.AddRange(installedModules.Select(installedModule => new ModuleInfo(installedModule.Name, installedModule.Version, null)));

            return(moduleInfos);
        }
        public void Execute(IContext context)
        {
            Module module = ModuleUtilities.LoadModule(this.modname, context);

            IValues values = context;
            int     nname  = 0;

            foreach (var name in this.names)
            {
                string normname = name.Trim();

                if (nname == this.names.Length - 1)
                {
                    values.SetValue(normname, module);
                }
                else if (!values.HasValue(normname))
                {
                    var mod = new Module(context.GlobalContext);
                    values.SetValue(normname, mod);
                    values = mod;
                }
                else
                {
                    values = (IValues)values.GetValue(normname);
                }

                nname++;
            }
        }
Exemple #8
0
        public async Task Player(string player = "default")
        {
            dynamic result     = ModuleUtilities.GetJsonFromEndpoint(OwlUrl + "players");
            string  playerData = OWLUtilities.GetPlayerData(result, player);

            await ReplyAsync(playerData)
            ;
        }
        public void Span(int startLine, int startColumn, int endLine, int endColumn,
                         int expectedStartLine, int expectedStartColumn, int expectedEndLine, int expectedEndColumn)
        {
            var actual   = ModuleUtilities.ToSourceSpan(new DkmTextSpan(StartLine: startLine, EndLine: endLine, StartColumn: startColumn, EndColumn: endColumn));
            var expected = new SourceSpan(expectedStartLine, expectedStartColumn, expectedEndLine, expectedEndColumn);

            Assert.Equal(expected, actual);
        }
        public void LoadCachedModule()
        {
            var context = new BindingEnvironment();
            var module  = ModuleUtilities.LoadModule("setvar", context);
            var module2 = ModuleUtilities.LoadModule("setvar", context);

            Assert.IsNotNull(module);
            Assert.AreEqual(module, module2);
        }
        public void LoadSimpleModule()
        {
            var context = new BindingEnvironment();
            var module  = ModuleUtilities.LoadModule("setvar", context);

            Assert.IsNotNull(module);
            Assert.AreEqual(context, module.GlobalContext);
            Assert.IsNotNull(module.GetValue("a"));
            Assert.AreEqual("setvar module", module.GetValue("__doc__"));
        }
        public void Execute(Machine machine, BindingEnvironment environment)
        {
            Parser   parser  = new Parser(new StreamReader(ModuleUtilities.ModuleFileName(this.modname)));
            ICommand command = parser.CompileCommandList();

            BindingEnvironment modenv = new BindingEnvironment();

            command.Execute(machine, modenv);

            environment.SetValue(this.modname, modenv);
        }
Exemple #13
0
        public async Task Muddle([Remainder] string input)
        {
            await ModuleUtilities.DeleteMessage(Context);

            List <string> words = input.Split(' ').ToList();

            string muddledSentance = "";

            //golf it because
            //having it in the select like that, must do some sort of caching, same result for same input in string every time, desirable?
            muddledSentance += String.Join(String.Empty, words.Select(w => { return(Scramble(w) + " "); }));
            await ReplyAsync(muddledSentance);
        }
Exemple #14
0
        public async Task MockBob([Remainder] string input)
        {
            await ModuleUtilities.DeleteMessage(Context);

            string oldMsg = input;

            string newMsg = "";

            newMsg += Context.User.Username.ToString() + ": ";

            for (int i = 0; i < oldMsg.Length; i++)
            {
                newMsg += (i % 2 == 0 ? Char.ToUpper(oldMsg[i]) : Char.ToLower(oldMsg[i]));
            }
            await ReplyAsync(newMsg + "\n\r" + "http://i.imgflip.com/1rn9v3.jpg");
        }
Exemple #15
0
        public async Task MemSpeak([Remainder] string input)
        {
            await ModuleUtilities.DeleteMessage(Context);

            string oldMsg = input;
            string newMsg = "";

            newMsg += Context.User.Username.ToString() + ": ";

            for (int i = 0; i < oldMsg.Length; i++)
            {
                newMsg += oldMsg[i] + (i < oldMsg.Length - 1 ? "(" : "");
            }
            newMsg += new string(')', oldMsg.Length - 1);
            await ReplyAsync(newMsg);
        }
        public void Execute(IContext context)
        {
            Module module = ModuleUtilities.LoadModule(this.modname, context);

            if (this.names != null)
            {
                foreach (string name in this.names)
                {
                    context.SetValue(name, module.GetValue(name));
                }
            }
            else
            {
                foreach (string name in module.GetNames())
                {
                    context.SetValue(name, module.GetValue(name));
                }
            }
        }
Exemple #17
0
        public async Task Scrust(int maxChars, [Remainder] string input)
        {
            await ModuleUtilities.DeleteMessage(Context);

            string oldMsg = input;

            string newMsg = "";

            newMsg += Context.User.Username.ToString() + ": ";

            string[] diacriticalPrefixes = { @"\u030", @"\u031", @"\u032", @"\u033", @"\u034", @"\u035", @"\u036" };

            Random random        = new Random();
            var    scrustyString = "";

            foreach (char c in input)
            {
                if (c == ' ')
                {
                    scrustyString += " ";
                    continue;
                }
                string modChar  = c.ToString();
                int    toAdd    = random.Next(0, maxChars);
                var    diaCrits = "";
                for (int i = 0; i < toAdd; i++)
                {
                    var firstPart  = diacriticalPrefixes[random.Next(0, 7)];
                    var secondPart = random.Next(0, 16).ToString("X");
                    diaCrits = Regex.Unescape((diaCrits + (firstPart + secondPart))).Normalize();
                    ;
                }
                modChar        = Regex.Unescape((modChar + diaCrits)).Normalize();
                scrustyString += modChar;
            }
            await ReplyAsync(scrustyString);
        }
 public void UnknownModule()
 {
     Assert.IsNull(ModuleUtilities.ModuleFileName("spam"));
 }