Add workarounds for non-default message types

Fixes #16
pull/17/head^2
Alexey Golub 7 years ago
parent 75e8d59cc3
commit 171718989a

@ -92,6 +92,7 @@
<Compile Include="Models\ChannelType.cs" /> <Compile Include="Models\ChannelType.cs" />
<Compile Include="Models\ExportFormat.cs" /> <Compile Include="Models\ExportFormat.cs" />
<Compile Include="Models\Extensions.cs" /> <Compile Include="Models\Extensions.cs" />
<Compile Include="Models\MessageType.cs" />
<Compile Include="Services\IMessageGroupService.cs" /> <Compile Include="Services\IMessageGroupService.cs" />
<Compile Include="Services\MessageGroupService.cs" /> <Compile Include="Services\MessageGroupService.cs" />
<Compile Include="ViewModels\ErrorViewModel.cs" /> <Compile Include="ViewModels\ErrorViewModel.cs" />

@ -0,0 +1,14 @@
namespace DiscordChatExporter.Models
{
public enum MessageType
{
Default,
RecipientAdd,
RecipientRemove,
Call,
ChannelNameChange,
ChannelIconChange,
ChannelPinnedMessage,
GuildMemberJoin
}
}

@ -188,10 +188,23 @@ namespace DiscordChatExporter.Services
var timeStamp = token.Value<DateTime>("timestamp"); var timeStamp = token.Value<DateTime>("timestamp");
var editedTimeStamp = token.Value<DateTime?>("edited_timestamp"); var editedTimeStamp = token.Value<DateTime?>("edited_timestamp");
var content = token.Value<string>("content"); var content = token.Value<string>("content");
var type = (MessageType) token.Value<int>("type");
// Lazy workaround for calls
if (token["call"] != null) // 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."; 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 // Get author
var author = ParseUser(token["author"]); var author = ParseUser(token["author"]);

Loading…
Cancel
Save