mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-24 19:54:22 -04:00
parent
4a986fe5df
commit
ab46361489
6 changed files with 62 additions and 30 deletions
|
@ -6,12 +6,15 @@
|
|||
|
||||
public string Name { get; }
|
||||
|
||||
public string Topic { get; }
|
||||
|
||||
public ChannelType Type { get; }
|
||||
|
||||
public Channel(string id, string name, ChannelType type)
|
||||
public Channel(string id, string name, string topic, ChannelType type)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
Topic = topic;
|
||||
Type = type;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ namespace DiscordChatExporter.Models
|
|||
|
||||
public string Name { get; }
|
||||
|
||||
public string FullyQualifiedName => $"{Name}#{Discriminator:0000}";
|
||||
|
||||
public string AvatarHash { get; }
|
||||
|
||||
public string AvatarUrl => AvatarHash.IsNotBlank()
|
||||
|
@ -26,7 +28,7 @@ namespace DiscordChatExporter.Models
|
|||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Name}#{Discriminator}";
|
||||
return FullyQualifiedName;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,9 @@ a {
|
|||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover { text-decoration: underline; }
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
div.pre {
|
||||
background-color: #2F3136;
|
||||
|
@ -37,7 +39,9 @@ div#info {
|
|||
max-width: 100%;
|
||||
}
|
||||
|
||||
div#log { max-width: 100%; }
|
||||
div#log {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
img.guild-icon {
|
||||
max-height: 64px;
|
||||
|
@ -51,15 +55,22 @@ div.info-right {
|
|||
|
||||
div.guild-name {
|
||||
color: #FFFFFF;
|
||||
font-size: 1.4rem;
|
||||
font-size: 1.4em;
|
||||
}
|
||||
|
||||
div.channel-name {
|
||||
color: #FFFFFF;
|
||||
font-size: 1.2rem;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
div.misc { margin-top: 2px; }
|
||||
div.channel-topic {
|
||||
margin-top: 2px;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
div.channel-messagecount {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
div.msg {
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.04);
|
||||
|
@ -88,23 +99,23 @@ div.msg-right {
|
|||
|
||||
span.msg-user {
|
||||
color: #FFFFFF;
|
||||
font-size: 1rem;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
span.msg-date {
|
||||
color: rgba(255, 255, 255, 0.2);
|
||||
font-size: .75rem;
|
||||
font-size: .75em;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
span.msg-edited {
|
||||
color: rgba(255, 255, 255, 0.2);
|
||||
font-size: .8rem;
|
||||
font-size: .8em;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
div.msg-content {
|
||||
font-size: .9375rem;
|
||||
font-size: .9375em;
|
||||
padding-top: 5px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,9 @@ a {
|
|||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover { text-decoration: underline; }
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
div.pre {
|
||||
background-color: #F9F9F9;
|
||||
|
@ -37,7 +39,9 @@ div#info {
|
|||
max-width: 100%;
|
||||
}
|
||||
|
||||
div#log { max-width: 100%; }
|
||||
div#log {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
img.guild-icon {
|
||||
max-height: 64px;
|
||||
|
@ -51,15 +55,22 @@ div.info-right {
|
|||
|
||||
div.guild-name {
|
||||
color: #2F3136;
|
||||
font-size: 1.4rem;
|
||||
font-size: 1.4em;
|
||||
}
|
||||
|
||||
div.channel-name {
|
||||
color: #2F3136;
|
||||
font-size: 1.2rem;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
div.misc { margin-top: 2px; }
|
||||
div.channel-topic {
|
||||
margin-top: 2px;
|
||||
color: #2F3136;
|
||||
}
|
||||
|
||||
div.channel-messagecount {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
div.msg {
|
||||
border-top: 1px solid #ECEEEF;
|
||||
|
@ -88,23 +99,23 @@ div.msg-right {
|
|||
|
||||
span.msg-user {
|
||||
color: #2F3136;
|
||||
font-size: 1rem;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
span.msg-date {
|
||||
color: #99AAB5;
|
||||
font-size: .75rem;
|
||||
font-size: .75em;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
span.msg-edited {
|
||||
color: #99AAB5;
|
||||
font-size: .8rem;
|
||||
font-size: .8em;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
div.msg-content {
|
||||
font-size: .9375rem;
|
||||
font-size: .9375em;
|
||||
padding-top: 5px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ namespace DiscordChatExporter.Services
|
|||
// Get basic data
|
||||
var id = token.Value<string>("id");
|
||||
var type = (ChannelType) token.Value<int>("type");
|
||||
var topic = token.Value<string>("topic");
|
||||
|
||||
// Extract name based on type
|
||||
string name;
|
||||
|
@ -65,7 +66,7 @@ namespace DiscordChatExporter.Services
|
|||
name = token.Value<string>("name");
|
||||
}
|
||||
|
||||
return new Channel(id, name, type);
|
||||
return new Channel(id, name, topic, type);
|
||||
}
|
||||
|
||||
private Message ParseMessage(JToken token)
|
||||
|
@ -129,7 +130,7 @@ namespace DiscordChatExporter.Services
|
|||
.Select(m => m.Groups[1].Value)
|
||||
.ExceptBlank()
|
||||
.Select(i => _channelCache.GetOrDefault(i) ??
|
||||
new Channel(i, "deleted-channel", ChannelType.GuildTextChat))
|
||||
new Channel(i, "deleted-channel", null, ChannelType.GuildTextChat))
|
||||
.ToArray();
|
||||
|
||||
return new Message(id, type, author, timeStamp, editedTimeStamp, content, attachments,
|
||||
|
|
|
@ -28,8 +28,9 @@ namespace DiscordChatExporter.Services
|
|||
|
||||
// Guild and channel info
|
||||
await writer.WriteLineAsync('='.Repeat(48));
|
||||
await writer.WriteLineAsync($"Guild: {log.Guild}");
|
||||
await writer.WriteLineAsync($"Channel: {log.Channel}");
|
||||
await writer.WriteLineAsync($"Guild: {log.Guild.Name}");
|
||||
await writer.WriteLineAsync($"Channel: {log.Channel.Name}");
|
||||
await writer.WriteLineAsync($"Topic: {log.Channel.Topic}");
|
||||
await writer.WriteLineAsync($"Messages: {log.TotalMessageCount:N0}");
|
||||
await writer.WriteLineAsync('='.Repeat(48));
|
||||
await writer.WriteLineAsync();
|
||||
|
@ -38,7 +39,7 @@ namespace DiscordChatExporter.Services
|
|||
foreach (var group in log.MessageGroups)
|
||||
{
|
||||
var timeStampFormatted = group.TimeStamp.ToString(_settingsService.DateFormat);
|
||||
await writer.WriteLineAsync($"{group.Author} [{timeStampFormatted}]");
|
||||
await writer.WriteLineAsync($"{group.Author.FullyQualifiedName} [{timeStampFormatted}]");
|
||||
|
||||
// Messages
|
||||
foreach (var message in group.Messages)
|
||||
|
@ -75,7 +76,7 @@ namespace DiscordChatExporter.Services
|
|||
|
||||
// HEAD
|
||||
await writer.WriteLineAsync("<head>");
|
||||
await writer.WriteLineAsync($"<title>{log.Guild} - {log.Channel}</title>");
|
||||
await writer.WriteLineAsync($"<title>{log.Guild.Name} - {log.Channel.Name}</title>");
|
||||
await writer.WriteLineAsync("<meta charset=\"utf-8\" />");
|
||||
await writer.WriteLineAsync("<meta name=\"viewport\" content=\"width=device-width\" />");
|
||||
await writer.WriteLineAsync($"<style>{css}</style>");
|
||||
|
@ -90,9 +91,11 @@ namespace DiscordChatExporter.Services
|
|||
await writer.WriteLineAsync($"<img class=\"guild-icon\" src=\"{log.Guild.IconUrl}\" />");
|
||||
await writer.WriteLineAsync("</div>"); // info-left
|
||||
await writer.WriteLineAsync("<div class=\"info-right\">");
|
||||
await writer.WriteLineAsync($"<div class=\"guild-name\">{log.Guild}</div>");
|
||||
await writer.WriteLineAsync($"<div class=\"channel-name\">{log.Channel}</div>");
|
||||
await writer.WriteLineAsync($"<div class=\"misc\">{log.TotalMessageCount:N0} messages</div>");
|
||||
await writer.WriteLineAsync($"<div class=\"guild-name\">{log.Guild.Name}</div>");
|
||||
await writer.WriteLineAsync($"<div class=\"channel-name\">{log.Channel.Name}</div>");
|
||||
await writer.WriteLineAsync($"<div class=\"channel-topic\">{log.Channel.Topic}</div>");
|
||||
await writer.WriteLineAsync(
|
||||
$"<div class=\"channel-messagecount\">{log.TotalMessageCount:N0} messages</div>");
|
||||
await writer.WriteLineAsync("</div>"); // info-right
|
||||
await writer.WriteLineAsync("</div>"); // info
|
||||
|
||||
|
@ -106,7 +109,8 @@ namespace DiscordChatExporter.Services
|
|||
await writer.WriteLineAsync("</div>");
|
||||
|
||||
await writer.WriteLineAsync("<div class=\"msg-right\">");
|
||||
await writer.WriteAsync($"<span class=\"msg-user\" title=\"{HtmlEncode(group.Author)}\">");
|
||||
await writer.WriteAsync(
|
||||
$"<span class=\"msg-user\" title=\"{HtmlEncode(group.Author.FullyQualifiedName)}\">");
|
||||
await writer.WriteAsync(HtmlEncode(group.Author.Name));
|
||||
await writer.WriteLineAsync("</span>");
|
||||
var timeStampFormatted = HtmlEncode(group.TimeStamp.ToString(_settingsService.DateFormat));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue