Created
September 6, 2012 20:48
-
-
Save psykzz/3660265 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int Log(string channel="local", int index=1) | |
{ | |
if (channel == "") return 0; | |
try | |
{ | |
FileInfo lastUpdatedFile = GetLastUpdatedFileInDirectory(channel); | |
if (lastUpdatedFile == null) | |
{ | |
MessageBox.Show("Unable to locate gamelogs", "Couldn't Find File"); | |
return 0; | |
} | |
FileStream stream = File.Open(lastUpdatedFile.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); | |
StreamReader sr = new StreamReader(stream); | |
string pattern = @"/Jumping to ([-A-Za-z0-9 ]+) in ([-A-Za-z0-9 ]+) solar system/"; | |
Regex rgxCur = new Regex(pattern, RegexOptions.IgnoreCase); | |
Console.WriteLine(pattern); | |
string input; | |
string currentSystem; | |
string previousSystem; | |
while (sr.Peek() >= 0) | |
{ | |
input = sr.ReadLine(); | |
Console.WriteLine(input); | |
Match Curmatches = rgxCur.Match(input); | |
if (Curmatches.Groups.Count != 0) | |
{ | |
currentSystem = Curmatches.Groups[1].Value; | |
previousSystem = Curmatches.Groups[2].Value; | |
Console.WriteLine(currentSystem); | |
Console.WriteLine(previousSystem); | |
} | |
} | |
sr.Close(); | |
/* TextReader tr = new StreamReader(stream); | |
string lines = tr.ReadToEnd(); | |
lines = lines.Replace("&", ""); | |
lines = lines.Replace("?", ""); | |
lines = lines.Replace("=", ""); | |
lines = lines.Replace("'", ""); | |
string[] line = lines.Split('\n'); | |
if (currentLine[index] != 0 && currentLine[index] != line.Length - 2) | |
{ | |
lastline[index] = null; | |
for (int x = currentLine[index] + 1; x < line.Length - 1; x++) | |
{ | |
lastline[index] += '\n' + line[x]; | |
} | |
currentLine[index] = line.Length - 2; | |
//Console.WriteLine(lastline[index].Remove(1, 1)); | |
SendData(channel, lastline[index].Remove(1, 1)); | |
} | |
else if (currentLine[index] != line.Length - 2) | |
{ | |
lastline[index] = '\n' + line[line.Length - 2]; | |
currentLine[index] = line.Length - 2; | |
//Console.WriteLine(lastline[index].Remove(1, 1)); | |
SendData(channel, lastline[index].Remove(1, 1)); | |
} | |
tr.Close(); | |
* | |
* */ | |
} | |
catch (Exception e) | |
{ | |
Console.WriteLine(e.ToString()); | |
//System.Environment.Exit(0); | |
} | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment