public void NewConsoleOuput(object sender, ConsoleReadEventArgs e) { string output = e.Response; // Check if response contains a steamid var regex = new Regex(@"(?<=STEAM_)([^\s]*)"); if (regex.IsMatch(output)) { Console.WriteLine("STATUS: STEAM_" + regex.Match(output).Groups[1].Value); Log.AddPlayer("STEAM_" + regex.Match(output).Groups[1].Value); Program.GameData.MatchInfo.AddSteamId("STEAM_" + regex.Match(output).Groups[1].Value); } // Read NickName from Console var nameRegex = new Regex(@"(?<=name\"" = \"")(.*)(?=\"" \()"); if (nameRegex.IsMatch(output)) { Console.WriteLine("NickName From Console"); Player.NickName = nameRegex.Match(output).ToString(); } // Read Map name from Console as fallback var mapRegex = new Regex(@"(?<=Map\: )(.*)"); var mapRegex2 = new Regex(@"(?<=map \: )(.*)"); if (mapRegex.IsMatch(output)) { MatchInfo.ConsoleMapName = mapRegex.Match(output).ToString(); } else if (mapRegex2.IsMatch(output)) { MatchInfo.ConsoleMapName = mapRegex2.Match(output).ToString(); } // Read MatchID from Console as fallback var matchIdRegex = new Regex(@"(?<=Connected to \=)(.*)"); if (matchIdRegex.IsMatch(output)) { MatchInfo.ConsoleMatchID = matchIdRegex.Match(output).ToString(); } // Read if game is wingman or not from console if (output.Contains("players :") && output.Contains("/4 max)")) { MatchInfo.IsWingman = true; } }
/* This is probably the ugliest thing i ever coded... but since changing to the telnet * method i rely on reading the console for some things to work so had to add a super hacky way to * read the console if for some reason the cheater telnet method is not working and it has to use this backup way */ private void fileReader(Object source, ElapsedEventArgs e) { try { if (Program.GameConsole.client != null && Program.GameConsole.client.Connected == true) { return; } if (Helper.PathToCSGO == "") { return; } ConsoleReadEventArgs args = new ConsoleReadEventArgs(); SendCommand("condump; clear;"); Thread.Sleep(1000); // dump console to file string dumpPath = Helper.PathToCSGO + @"\condump000.txt"; if (File.Exists(dumpPath)) { // Read condump line by line StreamReader reader = new StreamReader(dumpPath); string line; while ((line = reader.ReadLine()) != null) { if (line != "") { // Simulate by sending line back to new method and pretend its read like it was via telnet args.Response = line; Program.GameConsole.OnConsoleRead(args); } } reader.Close(); Thread.Sleep(1000); // delete con dump File.Delete(Helper.PathToCSGO + @"\condump000.txt"); } } catch (Exception ex) { } }
private static void interpreter_OnConsoleRead(object sender, ConsoleReadEventArgs e) { string c = Console.Read().ToString(); Console.Write("\b"); interpreter.Input = c; }
public virtual void OnConsoleRead(ConsoleReadEventArgs e) { EventHandler <ConsoleReadEventArgs> handler = ConsoleRead; handler?.Invoke(this, e); }
public void ConsoleReader() { while (true) { try { if (client == null || client.Connected == false) { Thread.Sleep(100); continue; } using (StreamReader sr = new StreamReader(stream)) { string line; while ((line = sr.ReadLine()) != null) { if (line != "") { ConsoleReadEventArgs args = new ConsoleReadEventArgs(); args.Response = line; OnConsoleRead(args); if (line.Contains("telnet_success")) { Log.AddEntry(new LogEntry() { LogTypes = new List <LogTypes> { LogTypes.Analytics }, IncludeTimeAndTick = false, AnalyticsCategory = "Console", AnalyticsAction = "TelnetSuccess" }); TelnetTestSuccess = true; } if (line.Contains("Recording to")) { Log.AddEntry(new LogEntry() { LogTypes = new List <LogTypes> { LogTypes.Analytics }, AnalyticsCategory = "Replays", AnalyticsAction = "RecordingStarted" }); } if (line.Contains("Completed demo")) { Log.AddEntry(new LogEntry() { LogTypes = new List <LogTypes> { LogTypes.Analytics }, AnalyticsCategory = "Replays", AnalyticsAction = "CompletedDemo" }); } } } } } catch (Exception ex) { Log.AddEntry(new LogEntry() { LogTypes = new List <LogTypes> { LogTypes.Analytics }, IncludeTimeAndTick = false, AnalyticsCategory = "Error", AnalyticsAction = "ConsoleReadException", AnalyticsLabel = ex.Message }); } } }
protected virtual void OnConsoleRead(ConsoleReadEventArgs e) { EventHandler<ConsoleReadEventArgs> handler = ConsoleRead; if (handler != null) handler(this, e); }