Skip to content

Commit 3f5c301

Browse files
committed
🐛 Fix bugs and improvements
1 parent 90db59a commit 3f5c301

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

TelegramChatParser/Program.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.IO;
23
using CommandLine;
34
using E2.Utils;
45

@@ -16,16 +17,24 @@ public static void Main(string[] args)
1617
.ParseArguments<TgParser>(args)
1718
.WithParsed<TgParser>(o =>
1819
{
20+
if (!File.Exists(o.InputHtmlPath))
21+
{
22+
Console.ForegroundColor = ConsoleColor.Red;
23+
Console.WriteLine("Error: inputHtml dose not exists! aborting...");
24+
Console.ForegroundColor = ConsoleColor.White;
25+
return;
26+
}
27+
1928
TgParser tgParser = new TgParser(o.InputHtmlPath, o.CsvFilePath, o.Verbose, o.Append);
2029

2130
tgParser.CreateCsv();
2231
});
2332
}
2433
catch (Exception e)
2534
{
26-
Console.BackgroundColor = ConsoleColor.Red;
35+
Console.ForegroundColor = ConsoleColor.Red;
2736
Console.WriteLine($"Exception thrown: \nMessage -> {e.Message}\nStackTrace -> {e.StackTrace}");
28-
Console.BackgroundColor = ConsoleColor.Black;
37+
Console.ForegroundColor = ConsoleColor.White;
2938
}
3039
}
3140
}

TelegramChatParser/TgParser.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,11 @@ public TgParser()
3939

4040
public TgParser(string inputHtmlPath, string csvFilePath, bool verbose = false, bool append = false)
4141
{
42-
if (Append == true && !File.Exists(CsvFilePath))
42+
if (append == true && !File.Exists(csvFilePath))
4343
{
44-
Console.BackgroundColor = ConsoleColor.Yellow;
44+
Console.ForegroundColor = ConsoleColor.Yellow;
4545
Console.WriteLine("Warning: Csv file not exists, Creating new file...");
46-
Console.BackgroundColor = ConsoleColor.Black;
47-
}
48-
49-
if (!File.Exists(inputHtmlPath))
50-
{
51-
Console.BackgroundColor = ConsoleColor.Red;
52-
Console.WriteLine("Error: inputHtml dose not exists! aborting...");
53-
Console.BackgroundColor = ConsoleColor.Black;
46+
Console.ForegroundColor = ConsoleColor.White;
5447
}
5548

5649
Verbose = verbose;
@@ -107,9 +100,9 @@ private List<Message> GetMessages()
107100
}
108101
catch (Exception e)
109102
{
110-
Console.BackgroundColor = ConsoleColor.Red;
103+
Console.ForegroundColor = ConsoleColor.Red;
111104
Console.WriteLine($"Exception thrown: \nMessage -> {e.Message}\nStackTrace -> {e.StackTrace}");
112-
Console.BackgroundColor = ConsoleColor.Black;
105+
Console.ForegroundColor = ConsoleColor.White;
113106
}
114107

115108
return messagesStack.ToList();

0 commit comments

Comments
 (0)