From 171718989ac9b23d4c88e3e73f1f7276ccaaa48e Mon Sep 17 00:00:00 2001 From: Alexey Golub Date: Thu, 26 Oct 2017 22:14:50 +0300 Subject: [PATCH] Add workarounds for non-default message types Fixes #16 --- .../DiscordChatExporter.csproj | 1 + DiscordChatExporter/Models/MessageType.cs | 14 ++++++++++++++ DiscordChatExporter/Services/DataService.cs | 19 ++++++++++++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 DiscordChatExporter/Models/MessageType.cs diff --git a/DiscordChatExporter/DiscordChatExporter.csproj b/DiscordChatExporter/DiscordChatExporter.csproj index 724651e..b206f0a 100644 --- a/DiscordChatExporter/DiscordChatExporter.csproj +++ b/DiscordChatExporter/DiscordChatExporter.csproj @@ -92,6 +92,7 @@ + diff --git a/DiscordChatExporter/Models/MessageType.cs b/DiscordChatExporter/Models/MessageType.cs new file mode 100644 index 0000000..8ad4490 --- /dev/null +++ b/DiscordChatExporter/Models/MessageType.cs @@ -0,0 +1,14 @@ +namespace DiscordChatExporter.Models +{ + public enum MessageType + { + Default, + RecipientAdd, + RecipientRemove, + Call, + ChannelNameChange, + ChannelIconChange, + ChannelPinnedMessage, + GuildMemberJoin + } +} \ No newline at end of file diff --git a/DiscordChatExporter/Services/DataService.cs b/DiscordChatExporter/Services/DataService.cs index c72a9d9..711b3bf 100644 --- a/DiscordChatExporter/Services/DataService.cs +++ b/DiscordChatExporter/Services/DataService.cs @@ -188,10 +188,23 @@ namespace DiscordChatExporter.Services var timeStamp = token.Value("timestamp"); var editedTimeStamp = token.Value("edited_timestamp"); var content = token.Value("content"); - - // Lazy workaround for calls - if (token["call"] != null) + var type = (MessageType) token.Value("type"); + + // Workarounds for non-default types + if (type == MessageType.RecipientAdd) + content = "Added a recipient."; + else if (type == MessageType.RecipientRemove) + content = "Removed a recipient."; + else if (type == MessageType.Call) content = "Started a call."; + else if (type == MessageType.ChannelNameChange) + content = "Changed the channel name."; + else if (type == MessageType.ChannelIconChange) + content = "Changed the channel icon."; + else if (type == MessageType.ChannelPinnedMessage) + content = "Pinned a message."; + else if (type == MessageType.GuildMemberJoin) + content = "Joined the server."; // Get author var author = ParseUser(token["author"]);