Skip to content

Commit

Permalink
🐛 Fix bugs and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ali4heydari committed Jun 11, 2019
1 parent 90db59a commit 3f5c301
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
13 changes: 11 additions & 2 deletions TelegramChatParser/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using CommandLine;
using E2.Utils;

Expand All @@ -16,16 +17,24 @@ public static void Main(string[] args)
.ParseArguments<TgParser>(args)
.WithParsed<TgParser>(o =>
{
if (!File.Exists(o.InputHtmlPath))
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Error: inputHtml dose not exists! aborting...");
Console.ForegroundColor = ConsoleColor.White;
return;
}
TgParser tgParser = new TgParser(o.InputHtmlPath, o.CsvFilePath, o.Verbose, o.Append);
tgParser.CreateCsv();
});
}
catch (Exception e)
{
Console.BackgroundColor = ConsoleColor.Red;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"Exception thrown: \nMessage -> {e.Message}\nStackTrace -> {e.StackTrace}");
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.White;
}
}
}
Expand Down
17 changes: 5 additions & 12 deletions TelegramChatParser/TgParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,11 @@ public TgParser()

public TgParser(string inputHtmlPath, string csvFilePath, bool verbose = false, bool append = false)
{
if (Append == true && !File.Exists(CsvFilePath))
if (append == true && !File.Exists(csvFilePath))
{
Console.BackgroundColor = ConsoleColor.Yellow;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Warning: Csv file not exists, Creating new file...");
Console.BackgroundColor = ConsoleColor.Black;
}

if (!File.Exists(inputHtmlPath))
{
Console.BackgroundColor = ConsoleColor.Red;
Console.WriteLine("Error: inputHtml dose not exists! aborting...");
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.White;
}

Verbose = verbose;
Expand Down Expand Up @@ -107,9 +100,9 @@ private List<Message> GetMessages()
}
catch (Exception e)
{
Console.BackgroundColor = ConsoleColor.Red;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"Exception thrown: \nMessage -> {e.Message}\nStackTrace -> {e.StackTrace}");
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.White;
}

return messagesStack.ToList();
Expand Down

0 comments on commit 3f5c301

Please sign in to comment.