Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/production' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
IzzyDotExe committed Jun 13, 2023
2 parents 35d6358 + 5d79bb6 commit 1b5cc0d
Show file tree
Hide file tree
Showing 6 changed files with 1,992 additions and 1,687 deletions.
3 changes: 3 additions & 0 deletions ARC/ARC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
<None Update="temp\temp.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="templatecore.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion ARC/Arc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private static async Task StartDiscordBot(IConfigurationRoot settings)
_clientInstance = new DiscordClient(discordConfig)
{

ClientVersion = "2.1"
ClientVersion = "2.2"

};
_serviceProvider = ConfigureServices(settings);
Expand Down
4 changes: 2 additions & 2 deletions ARC/Modules/ModerationModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private async Task DeleteUserNote(ComponentInteractionCreateEventArgs args)
.AddField("Deleted By:", $"{args.User.Mention}", true)
.AddField("Time added:", $"<t:{new DateTimeOffset(note.DateAdded).ToUnixTimeSeconds()}:R>", true)
.AddField("Time deleted:", $"<t:{DateTimeOffset.UtcNow.ToUnixTimeSeconds()}:R>", true)
.WithFooter($"BillieBot v{ClientInstance.ClientVersion} UserNotes", ClientInstance.CurrentUser.GetAvatarUrl(ImageFormat.Auto))
.WithFooter($"ARC v{ClientInstance.ClientVersion} UserNotes", ClientInstance.CurrentUser.GetAvatarUrl(ImageFormat.Auto))
.WithTimestamp(DateTime.UtcNow)
.WithColor(DiscordColor.Red)
.Build();
Expand Down Expand Up @@ -156,7 +156,7 @@ private async Task HandleUserNotesModal(DiscordClient sender, ModalSubmitEventAr
.WithDescription($"```{content}```")
.AddField("Added By:", $"{author.Mention}", true)
.AddField("Time added:", $"<t:{DateTimeOffset.UtcNow.ToUnixTimeSeconds()}:R>", true)
.WithFooter($"BillieBot v{ClientInstance.ClientVersion} UserNotes", ClientInstance.CurrentUser.GetAvatarUrl(ImageFormat.Auto))
.WithFooter($"ARC v{ClientInstance.ClientVersion} UserNotes", ClientInstance.CurrentUser.GetAvatarUrl(ImageFormat.Auto))
.WithTimestamp(dateadded)
.WithColor(DiscordColor.Green)
.Build();
Expand Down
126 changes: 99 additions & 27 deletions ARC/Schema/ArcDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

using System.ComponentModel.DataAnnotations.Schema;
using ARC.Extensions;

using DSharpPlus;
Expand Down Expand Up @@ -241,51 +242,122 @@ public async Task SaveTranscript()

IReadOnlyList<DiscordMessage> msgs = await Channel.GetMessagesAsync(2000);

await File.AppendAllTextAsync($"./temp/transcript-{ModmailId}.html", $@"
<div class=preamble>
<div class=preamble__guild-icon-container><img class=preamble__guild-icon
src='{Guild.GetIconUrl(ImageFormat.Auto)}''
alt='Guild icon' loading=lazy></div>
<div class=preamble__entries-container>
<div class=preamble__entry>{Guild.Name}</div>
<div class=preamble__entry>{Channel.Name}</div>
</div>
</div>
");
DiscordUser? author = null;
for (int i = (msgs.Count - 1); i >= 0; i--)
{
var message = msgs[i];
var newauthor = !message.Author.Equals(author);

if (newauthor)
{
author = message.Author;
await File.AppendAllTextAsync($"./temp/transcript-{ModmailId}.html", $@"
</div>
<div class=chatlog__message-group>
");
}

await File.AppendAllTextAsync($"./temp/transcript-{ModmailId}.html",
$@"
<div id=chatlog__message-container-{message.Id} class=chatlog__message-container
data-message-id={message.Id}>
<div class=chatlog__message>
<div class=chatlog__message-aside>
"
);

$@"
<div class='discord-message'>
<div class='discord-author-avatar'><img src='{message.Author.GetAvatarUrl(ImageFormat.Auto)}' alt='{message.Author.Username}'></div>
<div class='discord-message-content'>
<div><span class='discord-author-info'><span class='discord-author-username' style=''>
{message.Author.Username}
</span></span> <span class='discord-message-timestamp'>
{message.Timestamp.ToString()}
</span>
</div>
<div class='discord-message-body'>
<!---->
{message.Content}
<!---->
</div>
</div>
</div>
if (newauthor)
{
await File.AppendAllTextAsync($"./temp/transcript-{ModmailId}.html",
$@"
<img class=chatlog__avatar
src='{author.GetAvatarUrl(ImageFormat.Auto)}'
alt=Avatar loading=lazy></div>
"
);
}
else
{
await File.AppendAllTextAsync($"./temp/transcript-{ModmailId}.html",
$@"<div class=chatlog__short-timestamp title='{message.Timestamp}'>{message.Timestamp.Hour}:{message.Timestamp.Minute}</div></div>"
);
}

if (newauthor)

);
await File.AppendAllTextAsync($"./temp/transcript-{ModmailId}.html", $@"
<div class=chatlog__message-primary>
<div class=chatlog__header><span class=chatlog__author style=color:rgb(155,89,182) title={author.Username}
data-user-id={author.Id}>{author.Username}</span> <span class=chatlog__timestamp><a
href=#chatlog__message-container-{message.Id}>{message.Timestamp}</a></span>
</div>
<div class='chatlog__content chatlog__markdown'><span class=chatlog__markdown-preserve>{message.Content}</span></div>
");
else


await File.AppendAllTextAsync($"./temp/transcript-{ModmailId}.html", $@"
<div class=chatlog__message-primary>
<div class=chatlog__header>
</div>
<div class='chatlog__content chatlog__markdown'><span class=chatlog__markdown-preserve>{message.Content}</span></div>
");


if (message.Attachments.Count > 0)
{
foreach (var att in message.Attachments)
{
await File.AppendAllTextAsync($"./temp/transcript-{ModmailId}.html", $@"
<div class=chatlog__attachment><a
href={att.Url}>
<img class=chatlog__attachment-media
src={att.Url}
alt='Image attachment' title='Image: {att.FileName} ({att.FileSize})' loading=lazy> </a></div>
");
}
}

await File.AppendAllTextAsync($"./temp/transcript-{ModmailId}.html", $@"
</div>
</div>
</div>
");
}

await File.AppendAllTextAsync($"./temp/transcript-{ModmailId}.html", @"</div>
</body>
</html>");
await File.AppendAllTextAsync($"./temp/transcript-{ModmailId}.html", $@"</div>
<div class=postamble>
<div class=postamble__entry>Saved {MessageCount} message(s)</div>
</div>
</body>
</html>"
);
}

public DiscordUser User => Arc.ClientInstance.GetUserAsync((ulong)UserSnowflake).GetAwaiter().GetResult();
public DiscordWebhook Webhook => Channel.GetWebhooksAsync().GetAwaiter().GetResult()[0];
public DiscordChannel Channel => Arc.ClientInstance.GetChannelAsync((ulong)ChannelSnowflake).GetAwaiter().GetResult();
public DiscordGuild Guild => Arc.ClientInstance.GetGuildAsync(Channel.Guild.Id).GetAwaiter().GetResult();
public DiscordMember Member => Guild.GetMemberAsync(User.Id).GetAwaiter().GetResult();

[NotMapped] public int MessageCount => Channel.GetMessagesAsync().GetAwaiter().GetResult().Count;
private Modmail()
{

Expand Down
Loading

0 comments on commit 1b5cc0d

Please sign in to comment.