static async Task Main(string[] args) { _rant.LoadPackage(@"F:\Downloads\Rantionary-master\Rantionary-master\build\Rantionary-3.1.0.rantpkg"); var proxy = new WebProxy { Address = new Uri("http://194.32.239.71:56380"), Credentials = new NetworkCredential { UserName = "******", Password = "******" } }; _client = new TelegramBotClient("1087063556:AAHG7tjOi-r_9auYr8vy7lFka1k1J1z9s_g", proxy); var me = await _client.GetMeAsync(); Console.WriteLine($"{me.Id} running..."); _client.OnMessage += OnMessage; _client.StartReceiving(); Thread.Sleep(int.MaxValue); }
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)); } }
public void PackageModules() { var package = new RantPackage(); var pattern = RantPattern.FromString("[$[.hello_world]:Hello World]"); pattern.Name = "pkg_test"; package.AddPattern(pattern); rant.LoadPackage(package); Assert.AreEqual("Hello World", rant.Do("[use:pkg_test][$pkg_test.hello_world]").Main); }
public Rant_Generator() { rant = new RantEngine(); rng = new RNG(Seed); Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); var package = RantPackage.Load(Package); rant.LoadPackage(package); }
public MessageTextTransformer( ILogger <MessageTextTransformer> logger , IOptions <MessageTextProviderAppSettings> appSettings , IRandomFactGenerator randomFactGenerator ) { _randomFactGenerator = randomFactGenerator; _appSettings = appSettings.Value; var executionPath = AppDomain.CurrentDomain.BaseDirectory; var rantPackagePath = Path.Combine(executionPath, _appSettings.RelativeRantPackagePath); _logger = logger; _rant = new RantEngine(); _rant.LoadPackage(rantPackagePath); }
static void Main(string[] args) { int repetition = 10; string text; var rant = new RantEngine(); rant.LoadPackage("build/AlinhamentoZuado-0.0.1.rantpkg"); var program = RantProgram.CompileFile("alinhamentoZuado.rant"); for (int i = 0; i < repetition; i++) { text = rant.Do(program); Console.WriteLine(text); } }
static void Main(string[] args) { var rant = new RantEngine(); rant.LoadPackage("Rantionary-3.0.20.rantpkg"); rant.Dictionary.IncludeHiddenClass("nsfw"); Console.WriteLine("Press <Enter> to create a list of 1000 groups"); Console.ReadKey(true); Console.Clear(); var pgm = RantProgram.CompileString(@"[rs:1000;\n]{<adj> <adj> <noun.pl>}"); var output = rant.Do(pgm); Console.WriteLine(output.Main); Console.ReadLine(); }
public void SaveLoadRun() { var package = new RantPackage { ID = "TestPackage", Description = "This is a test.", Title = "Test Package?!", Version = new RantPackageVersion(1, 1, 0) }; package.AddResource(RantDictionaryTable.FromStream("nouns", File.Open("Tables/nouns.table", FileMode.Open))); package.AddResource(RantProgram.CompileString("TestProgram", @"[case:title]<noun-food-fruit-yellow> [rs:5;,\s]{[rn]}")); package.Save("TestPackage.rantpkg"); package = RantPackage.Load("TestPackage.rantpkg"); rant.LoadPackage(package); Assert.AreEqual("Banana 1, 2, 3, 4, 5", rant.DoName("TestProgram").Main); Assert.AreEqual("TestPackage", package.ID); Assert.AreEqual("This is a test.", package.Description); Assert.AreEqual("Test Package?!", package.Title); Assert.AreEqual("1.1.0", package.Version.ToString()); }
public RantModule() { rant.LoadPackage("./Rantionary.rantpkg"); }
private static void Main(string[] args) { OutputEncoding = Encoding.UTF8; Title = "Rant Console" + (Flag("nsfw") ? " [NSFW]" : ""); var rant = new RantEngine(); #if !DEBUG try { #endif if (PKG_FILES.Any()) { #if DEBUG Stopwatch timer = Stopwatch.StartNew(); #endif foreach (var pkg in PKG_FILES) { rant.LoadPackage(pkg); } #if DEBUG timer.Stop(); WriteLine($"Package loading: {timer.ElapsedMilliseconds}ms"); #endif } else if (!string.IsNullOrEmpty(PKG_DIR)) { #if DEBUG Stopwatch timer = Stopwatch.StartNew(); #endif foreach (var pkg in Directory.GetFiles(PKG_DIR, "*.rantpkg")) { rant.LoadPackage(pkg); } #if DEBUG timer.Stop(); WriteLine($"Package loading: {timer.ElapsedMilliseconds}ms"); #endif } else { foreach (string 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, true); #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> "); ForegroundColor = ConsoleColor.White; string input = ReadLine(); if (input == null) { return; } PrintOutput(rant, input); } }
static void Main(string[] args) { var rant = new RantEngine(); if (!string.IsNullOrEmpty(PKG_PATH)) { rant.LoadPackage(PKG_PATH); } else { foreach (string pkg in Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.rantpkg", SearchOption.AllDirectories)) { rant.LoadPackage(pkg); } } var stopwatch = new Stopwatch(); // find classes var classes = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.GetMethods().Any(m => m.GetCustomAttributes <Test>().Any())); PrintWithColor($"Displaying averages of {ITERATIONS} runs.", ConsoleColor.Cyan); foreach (var type in classes) { var suiteObj = Activator.CreateInstance(type); var methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly); PrintWithColor(type.ToString() + ":", ConsoleColor.Yellow); foreach (var method in methods) { var test = method.GetCustomAttribute <Test>(); Console.Write("\t" + test.Name + ": "); var totalSpan = new TimeSpan(0, 0, 0, 0, 0); for (var i = 0; i < ITERATIONS; i++) { stopwatch.Reset(); stopwatch.Start(); try { var result = method.Invoke(suiteObj, new object[] { rant }); } catch (TargetInvocationException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); } stopwatch.Stop(); totalSpan += stopwatch.Elapsed; } var avgSpan = TimeSpan.FromMilliseconds(totalSpan.TotalMilliseconds / ITERATIONS); PrintWithColor(avgSpan.ToString("c"), ConsoleColor.Magenta); } PrintWithColor("Done", ConsoleColor.Green); } }
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()); } }