diff --git a/DiscordChatExporter/DiscordChatExporter.csproj b/DiscordChatExporter/DiscordChatExporter.csproj
index d76983dd..724651e7 100644
--- a/DiscordChatExporter/DiscordChatExporter.csproj
+++ b/DiscordChatExporter/DiscordChatExporter.csproj
@@ -148,7 +148,6 @@
-
diff --git a/DiscordChatExporter/Models/ExportFormat.cs b/DiscordChatExporter/Models/ExportFormat.cs
index b1447886..acac9cb4 100644
--- a/DiscordChatExporter/Models/ExportFormat.cs
+++ b/DiscordChatExporter/Models/ExportFormat.cs
@@ -2,7 +2,8 @@
{
public enum ExportFormat
{
- Text,
- Html
+ PlainText,
+ HtmlDark,
+ HtmlLight
}
}
\ No newline at end of file
diff --git a/DiscordChatExporter/Models/Extensions.cs b/DiscordChatExporter/Models/Extensions.cs
index 83d0ff32..ef0893b2 100644
--- a/DiscordChatExporter/Models/Extensions.cs
+++ b/DiscordChatExporter/Models/Extensions.cs
@@ -1,14 +1,31 @@
-namespace DiscordChatExporter.Models
+using System;
+
+namespace DiscordChatExporter.Models
{
public static class Extensions
{
public static string GetFileExtension(this ExportFormat format)
{
- if (format == ExportFormat.Text)
+ if (format == ExportFormat.PlainText)
return "txt";
- if (format == ExportFormat.Html)
+ if (format == ExportFormat.HtmlDark)
return "html";
- return null;
+ if (format == ExportFormat.HtmlLight)
+ return "html";
+
+ throw new NotImplementedException();
+ }
+
+ public static string GetDisplayName(this ExportFormat format)
+ {
+ if (format == ExportFormat.PlainText)
+ return "Plain Text";
+ if (format == ExportFormat.HtmlDark)
+ return "HTML (Dark)";
+ if (format == ExportFormat.HtmlLight)
+ return "HTML (Light)";
+
+ throw new NotImplementedException();
}
}
}
\ No newline at end of file
diff --git a/DiscordChatExporter/Models/Theme.cs b/DiscordChatExporter/Models/Theme.cs
deleted file mode 100644
index 54db5c56..00000000
--- a/DiscordChatExporter/Models/Theme.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace DiscordChatExporter.Models
-{
- public enum Theme
- {
- Dark,
- Light
- }
-}
\ No newline at end of file
diff --git a/DiscordChatExporter/Program.cs b/DiscordChatExporter/Program.cs
index 6cead56c..27f84394 100644
--- a/DiscordChatExporter/Program.cs
+++ b/DiscordChatExporter/Program.cs
@@ -1,4 +1,7 @@
using System;
+using System.IO;
+using System.Reflection;
+using System.Resources;
using AmmySidekick;
namespace DiscordChatExporter
@@ -15,5 +18,19 @@ namespace DiscordChatExporter
app.Run();
}
+
+ public static string GetResourceString(string resourcePath)
+ {
+ var assembly = Assembly.GetExecutingAssembly();
+ var stream = assembly.GetManifestResourceStream(resourcePath);
+ if (stream == null)
+ throw new MissingManifestResourceException("Could not find resource");
+
+ using (stream)
+ using (var reader = new StreamReader(stream))
+ {
+ return reader.ReadToEnd();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/DiscordChatExporter/Services/DataService.cs b/DiscordChatExporter/Services/DataService.cs
index e40c8de8..fbd3128f 100644
--- a/DiscordChatExporter/Services/DataService.cs
+++ b/DiscordChatExporter/Services/DataService.cs
@@ -71,7 +71,8 @@ namespace DiscordChatExporter.Services
return channels;
}
- public async Task> GetChannelMessagesAsync(string token, string channelId, DateTime? from, DateTime? to)
+ public async Task> GetChannelMessagesAsync(string token, string channelId,
+ DateTime? from, DateTime? to)
{
var result = new List();
@@ -100,10 +101,12 @@ namespace DiscordChatExporter.Services
}
// If no messages - break
- if (currentMessageId == null) break;
+ if (currentMessageId == null)
+ break;
// If last message is older than from date - break
- if (from != null && result.Last().TimeStamp < from) break;
+ if (from != null && result.Last().TimeStamp < from)
+ break;
// Otherwise offset the next request
beforeId = currentMessageId;
diff --git a/DiscordChatExporter/Services/ExportService.cs b/DiscordChatExporter/Services/ExportService.cs
index 0cae5ded..eb75abc4 100644
--- a/DiscordChatExporter/Services/ExportService.cs
+++ b/DiscordChatExporter/Services/ExportService.cs
@@ -1,8 +1,6 @@
using System;
using System.IO;
using System.Net;
-using System.Reflection;
-using System.Resources;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
@@ -20,7 +18,7 @@ namespace DiscordChatExporter.Services
_settingsService = settingsService;
}
- public async Task ExportAsTextAsync(string filePath, ChannelChatLog log)
+ private async Task ExportAsTextAsync(string filePath, ChannelChatLog log)
{
var dateFormat = _settingsService.DateFormat;
@@ -66,9 +64,8 @@ namespace DiscordChatExporter.Services
}
}
- public async Task ExportAsHtmlAsync(string filePath, ChannelChatLog log, Theme theme)
+ private async Task ExportAsHtmlAsync(string filePath, ChannelChatLog log, string css)
{
- var themeCss = GetThemeCss(theme);
var dateFormat = _settingsService.DateFormat;
using (var writer = new StreamWriter(filePath, false, Encoding.UTF8, 128 * 1024))
@@ -85,7 +82,7 @@ namespace DiscordChatExporter.Services
await writer.WriteLineAsync($"{log.Guild} - {log.Channel}");
await writer.WriteLineAsync("");
await writer.WriteLineAsync("");
- await writer.WriteLineAsync($"");
+ await writer.WriteLineAsync($"");
await writer.WriteLineAsync("");
// Body start
@@ -173,26 +170,30 @@ namespace DiscordChatExporter.Services
await writer.WriteLineAsync("