Exemplo n.º 1
0
 private void SetEngine()
 {
     _engine = new RantEngine();
     using (Stream stream = typeof(RantModule).Assembly
         .GetManifestResourceStream(typeof(RantModule).Assembly.GetName().Name + ".Rantionary.rantpkg"))
     {
         _engine.LoadPackage(RantPackage.Load(stream));
     }
 }
Exemplo n.º 2
0
        public TextGenSystem()
        {
            Debug.WriteLine("Initializing Text Generation Engine");

            rant = new RantEngine();
            rant.LoadPackage("Rantionary");

            SetupRantPatterns();

            ActiveTextGenSystem = this;

            Debug.WriteLine("Done Initializing Text Generation Engine");
        }
Exemplo n.º 3
0
 static void Main(string[] args)
 {
     var rant = new RantEngine();
     rant.LoadPackage("Stadtzeug-1.0.0.rantpkg");
     rant.Dictionary.IncludeHiddenClass("nsfw");
     var city = new City(9001, rant);
     Console.WriteLine($"{city.Name}, {city.CurrentTime}\n");
     for (int i = 0; i < 45; i++)
     {
         var crime = rant.DoPackaged("sz/crime/conduct");
         Console.WriteLine($"{crime} (severity: {crime["severity"]})");
     }
     Console.ReadKey();
 }
Exemplo n.º 4
0
        static void Main()
        {
            _bot = new TelegramBot(File.ReadAllText("apikey.txt"));
            _engine = new RantEngine();
            _engine.LoadPackage("Rantionary.rantpkg");
            
            Console.WriteLine("Rant Loaded! {0} dictionaries.", _engine.Dictionary.GetTables().Count());

            historyDictionary = new Dictionary<string, RantPattern>();

            new Task(HandleMessages).Start();

            Console.WriteLine("Press enter to quit.");
            Console.ReadLine();
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;

            Title = "Rant Console" + (Flag("nsfw") ? " [NSFW]" : "");

            var rant = new RantEngine();

            try
            {
                if (!String.IsNullOrEmpty(DIC_PATH)) rant.Dictionary = RantDictionary.FromDirectory(DIC_PATH);
                if (!String.IsNullOrEmpty(PKG_PATH)) rant.LoadPackage(PKG_PATH);
            }
            catch (Exception e)
            {
                ForegroundColor = ConsoleColor.Cyan;
                WriteLine($"Dictionary load error: {e.Message}");
            }

            if (Flag("nsfw")) rant.Dictionary.IncludeHiddenClass("nsfw");

            if (!String.IsNullOrEmpty(FILE))
            {
                try
                {
                    PrintOutput(rant, File.ReadAllText(FILE));
                }
                catch (Exception ex)
                {
                    ForegroundColor = ConsoleColor.Red;
                    WriteLine(ex.Message);
                    ResetColor();
                }

                if (Flag("wait")) ReadKey(true);
                return;
            }

            while (true)
            {
                ForegroundColor = Flag("nsfw") ? ConsoleColor.DarkRed : ConsoleColor.Gray;
                Write("RANT> "); // real number symbol
                ForegroundColor = ConsoleColor.White;
                PrintOutput(rant, ReadLine());
            }
        }
Exemplo n.º 6
0
        private string RunPattern(string pattern, string includeHidden)
        {
            var statusType = "success";
            var statusMessage = "Success";
            RantOutput output = null;
            if (String.IsNullOrWhiteSpace(pattern)) goto skip;

            var rant = new RantEngine();
            rant.LoadPackage(Resources.Package);
            if (!String.IsNullOrWhiteSpace(includeHidden))
                rant.Dictionary.IncludeHiddenClass(includeHidden);

            try
            {
                output = rant.Do(pattern, Config.Current.MaxChars, Config.Current.PatternTimeout);
            }
            catch (RantRuntimeException ex)
            {
                statusType = "runtime-error";
                statusMessage = ex.Message;
            }
            catch (RantCompilerException ex)
            {
                statusType = "compiler-error";
                statusMessage = ex.Message;
            }
            catch (Exception ex)
            {
                statusType = "unknown-error";
                statusMessage = "Unknown error";
                C.WriteLine(ConsoleColor.Red, $"An exception was thrown while running a pattern: {ex}");
            }

            skip:

            var json = new
            {
                statusType,
                statusMessage,
                seed = output?.Seed.ToString() ?? "0",
                output = output?.ToDictionary(oe => oe.Name, oe => oe.Value)
            };
            return JObject.FromObject(json).ToString();
        }
Exemplo n.º 7
0
        public Bot()
        {
            WebAgent.UserAgent = "NotABot 1.0 by Backplague";

            reddit = new Reddit();

            rant = new RantEngine();
            rant.LoadPackage("Rantionary.rantpkg");
            patterns = new List<RantPattern>();
            rand = new Random();

            if (!Directory.Exists("Patterns"))
                throw new BotException("Missing Patterns directory");

            foreach (string file in Directory.EnumerateFiles("Patterns").Where(f => Path.GetExtension(f) == ".txt"))
                patterns.Add(RantPattern.FromFile(file));

            Console.WriteLine($"Loaded {patterns.Count} patterns");
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            //Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;

            Title = "Rant Console" + (Flag("nsfw") ? " [NSFW]" : "");

            var rant = new RantEngine();

#if !DEBUG
            try
            {
#endif
	            if (!String.IsNullOrEmpty(DIC_PATH))
	            {
		            rant.Dictionary = RantDictionary.FromDirectory(DIC_PATH);
	            }
	            else
	            {
		            foreach (var dic in Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.dic", SearchOption.AllDirectories))
		            {
			            rant.Dictionary.AddTable(RantDictionaryTable.FromFile(dic));
		            }
	            }

	            if (!String.IsNullOrEmpty(PKG_PATH))
	            {
#if DEBUG
                    Stopwatch timer = Stopwatch.StartNew();
#endif
		            rant.LoadPackage(PKG_PATH);
#if DEBUG
                    timer.Stop();
                    WriteLine($"Package loading: {timer.ElapsedMilliseconds}ms");
#endif
	            }
	            else
	            {
		            foreach (var pkg in Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.rantpkg", SearchOption.AllDirectories))
		            {
			            rant.LoadPackage(pkg);
		            }
	            }
#if !DEBUG
            }
            catch (Exception e)
            {
                ForegroundColor = ConsoleColor.Cyan;
                WriteLine($"Dictionary load error: {e.Message}");
            }
#endif
            if (Flag("nsfw")) rant.Dictionary.IncludeHiddenClass("nsfw");

            if (!String.IsNullOrEmpty(FILE))
            {
#if !DEBUG
                try
                {
#endif
                    PrintOutput(rant, File.ReadAllText(FILE));
#if !DEBUG
                }
                catch (Exception ex)
                {
                    ForegroundColor = ConsoleColor.Red;
                    WriteLine(ex.Message);
                    ResetColor();
                }
#endif

                if (Flag("wait")) ReadKey(true);
                return;
            }

            while (true)
            {
                ForegroundColor = Flag("nsfw") ? ConsoleColor.DarkRed : ConsoleColor.Gray;
                Write("RANT> "); // real number symbol
                ForegroundColor = ConsoleColor.White;
                PrintOutput(rant, ReadLine());
            }
        }
Exemplo n.º 9
0
        static void StartIrrgen()
        {
            var rand = new Random(0);
            Thread.Sleep(400);
            C.WriteLine("#YIRRGEN Simulation Constant Calculator v1.4.53.3967495a");
            C.WriteLine("Copyright (c) 1993 Eugene Glass, Jason Fisch");
            C.WriteLine();
            Thread.Sleep(600);
            Loading("INIT: #Y[libhypermathlib2000 v5.7.8453]", 24, 30, true);
            Loading("INIT: #Y[lib-libsagan84 v1.4.9b]", 24, 30, true);
            Loading("INIT: #Y[libcalculalgebra v6.7.69]", 24, 30, true);
            Loading("INIT: #Y[libfuccboiGDX (Professional Edition)]", 24, 30, true);
            Loading("INIT: #Y[libMEGAphp-vm v8.6.0]", 24, 30, true);
            Loading("INIT: #Y[lib-interdimensional-grasse v1.2.1]", 24, 30, true);
            Loading("INIT: #Y[libfischingrod v0.2.0]", 24, 30, true);
            Loading("INIT: #Y[librant4unix v3.0.0]", 24, 30, true);
            Loading("INIT: #Y[libMirrorScript v5.6.Eyes-Real?]", 24, 30, true);
            Loading("INIT: #Y[libtimespacepapaya v3.0.2]", 24, 30, true);
            C.WriteLine("\n#GSubmodules initialized!\n");
            C.WriteLine("#YAllocating output buffers 0-255");
            Count(0, 255);
            C.WriteLine("\nPartitioning math cache\n");
            Thread.Sleep(500);
            for (int i = 0; i < 8; i++)
            {
                C.WriteLine(new string('=', 48));
                C.WriteLine($"#MPARTITION CREATED @ 0x{rand.Next():X8} ({rand.Next(500, 1001)}K)");
                C.WriteLine(new string('=', 48));
                C.WriteLine();
                Thread.Sleep(200);
            }
            C.WriteLine("#GAll systems ready.");
            C.WriteLine("#YProceed? (Y/n)");
            Console.ReadLine();
            Console.CursorVisible = false;
            Thread.Sleep(350);
            C.Write("#RLET'S DO THIS SHIT");
            for (int i = 0; i < 35; i++)
            {
                C.Write("#R>");
                Thread.Sleep(20);
            }
            C.WriteLine();
            Console.Clear();

            for (int i = 0; i < 4; i++)
            {
                Console.WriteLine("........................\n");
                Thread.Sleep(300);
            }

            C.Write("#YCALCULATION START ");
            Spinner();
            C.WriteLine('\n');

            int delayBase = 1;
            float delayOffset = 1000f;
            C.Write("5.");
            var colors = new[] { 'W', 'R', 'G', 'B', 'Y', 'C', 'M' };
            var bcolors = new[]
            {
                ConsoleColor.DarkBlue, ConsoleColor.DarkCyan, ConsoleColor.DarkGreen, ConsoleColor.DarkRed, ConsoleColor.DarkYellow, ConsoleColor.DarkBlue,
                ConsoleColor.DarkMagenta, ConsoleColor.DarkGray, ConsoleColor.Black
            };
            var rant = new RantEngine();
            rant.LoadPackage("Rantionary");
            rant.Dictionary.IncludeHiddenClass("nsfw");
            var rngRant = new RNG(0);
            var pattern = RantPattern.FromString(@"
            [rs:[n:1;8];{\s|:|--|\(|\);|\;|*|@|?!|...|_|::|\#|$|%|^|&\~|\u2591|\u2592|\u2593|\}|\{|\""|'|,|/|\\|\`|\|*|+|\< |\> |__|++|--|\<\< |\>\> |!!}]
            [before:[case:{upper|lower|none|word}]]
            {{<adj>\s|}<noun>|<place>|<verb.nom>|<name>|<adv>|<state>|<element>|<unit>|<country>|the|entity|
            pointer|object|int|void|reference|bool|boolean|byte|char|protected|private|public|internal|static|
            unsigned|operator|delete|const|float|double|dword|return|namespace|nullptr|class|template|exec|auto|
            \#include \<[`[^\w\d]`i:{<noun>|<verb.nom>};_].h\>|
            \#define __[case:upper]<noun>[case:none] [rs:[n:1;4];\s]{<noun>|<adj>|and|or|the|<verb>}
            [n:1;1k]|\#{W|R|G|Y|C|M|B}|[r:[n:1;16]]{\w}|0x\8,X|{<noun>|<verb>}\(\)|[numfmt:verbal-en;[n:1;1M]]}"
            );
            int l = 13000;
            int corruptPoint = 7500;
            int unstablePoint = 6000;
            for (int i = 0; i < l; i++)
            {
                if (i < corruptPoint)
                {
                    for (int j = 0; j < i / 100 + 1; j++)
                    {
                        if (i > unstablePoint && rand.Next(0, (corruptPoint - i) / 10 + 2) == 0)
                        {
                            C.Write(' ');
                        }
                        else
                        {
                            C.Write(rand.Next(0, 10));
                        }
                    }
                }
                else if (i == corruptPoint)
                {
                    SpinnerActive = false;
                    for (int k = 0; k < 75; k++)
                    {
                        C.WriteLine($"#R==== FATAL ERROR ==== @ 0x{rngRant.NextRaw():X16}, 0x{rngRant.NextRaw():X16}");
                        Thread.Sleep(5);
                    }
                }
                else
                {
                    switch (rand.Next(0, 2))
                    {
                        case 0:
                            C.Write($"#{colors[rand.Next(colors.Length)]}{rand.Next(0, 10)}", false);
                            break;
                        case 1:
                            if (i > 9000)
                            {
                                Console.BackgroundColor = bcolors[rand.Next(bcolors.Length)];
                            }
                            C.Write(rant.Do(pattern, rngRant), false);
                            break;
                    }

                    switch (rand.Next(700))
                    {
                        case 0:
                            Thread.Sleep(125);
                            break;
                        case 1:
                        case 2:
                        case 3:
                        case 4:
                        case 5:
                            Console.MoveBufferArea(0, 0, 6, 8, rand.Next(Console.BufferWidth - 6), Console.CursorTop - 8, '\u2592', ConsoleColor.Black, ConsoleColor.Black);
                            break;
                    }
                }

                Thread.Sleep(delayBase + (int)delayOffset);
                delayOffset *= 0.845f;
            }
            Console.BackgroundColor = ConsoleColor.Green;
            Console.Clear();
            for (int i = 0; i < Console.BufferWidth; i++)
            {
                if (i % 3 == 2) continue;
                Console.MoveBufferArea(Console.WindowHeight, 0, 1, Console.WindowHeight, i, 0, '\u2592', ConsoleColor.Blue, ConsoleColor.Magenta);
                for(int j = 0; j < 4; j++)
                    Console.MoveBufferArea(0, 0, 1, 1, rand.Next(Console.WindowWidth), rand.Next(Console.WindowHeight), '\u2591', ConsoleColor.Yellow, ConsoleColor.Black);
            }
        }