Re-enable proxy attachments
This commit is contained in:
parent
58cdb04ab9
commit
5ff32ea6b4
@ -201,8 +201,7 @@ namespace PluralKit.Bot
|
||||
private async Task UpdatePeriodic()
|
||||
{
|
||||
// Change bot status
|
||||
// await _client.SetGameAsync($"pk;help | in {_client.Guilds.Count} servers");
|
||||
await _client.SetGameAsync($"Attachments disabled for tonight, sorry | in {_client.Guilds.Count} servers");
|
||||
await _client.SetGameAsync($"pk;help | in {_client.Guilds.Count} servers");
|
||||
|
||||
await _collector.CollectStats();
|
||||
|
||||
|
@ -95,7 +95,7 @@ namespace PluralKit.Bot
|
||||
if (!await EnsureBotPermissions(channel)) return;
|
||||
|
||||
// Can't proxy a message with no content and no attachment
|
||||
if (match.InnerText.Trim().Length == 0/* && message.Attachments.Count == 0*/) // TODO: undo when adding attachments back
|
||||
if (match.InnerText.Trim().Length == 0 && message.Attachments.Count == 0)
|
||||
return;
|
||||
|
||||
// Get variables in order and all
|
||||
|
@ -60,13 +60,12 @@ namespace PluralKit.Bot
|
||||
};
|
||||
if (avatarUrl != null) mfd.Add(new StringContent(avatarUrl), "avatar_url");
|
||||
|
||||
/*var attachmentChunks = ChunkAttachmentsOrThrow(attachments, 8 * 1024 * 1024);
|
||||
var attachmentChunks = ChunkAttachmentsOrThrow(attachments, 8 * 1024 * 1024);
|
||||
if (attachmentChunks.Count > 0)
|
||||
{
|
||||
_logger.Information("Invoking webhook with {AttachmentCount} attachments totalling {AttachmentSize} MiB in {AttachmentChunks} chunks", attachments.Count, attachments.Select(a => a.Size).Sum() / 1024 / 1024, attachmentChunks.Count);
|
||||
await AddAttachmentsToMultipart(mfd, attachmentChunks.First());
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
var timerCtx = _metrics.Measure.Timer.Time(BotMetrics.WebhookResponseTime);
|
||||
using var response = await _client.PostAsync($"{DiscordConfig.APIUrl}webhooks/{webhook.Id}/{webhook.Token}?wait=true", mfd);
|
||||
@ -93,21 +92,21 @@ namespace PluralKit.Bot
|
||||
}
|
||||
|
||||
// If we have any leftover attachment chunks, send those
|
||||
/*if (attachmentChunks.Count > 1)
|
||||
if (attachmentChunks.Count > 1)
|
||||
{
|
||||
// Deliberately not adding a content, just the remaining files
|
||||
foreach (var chunk in attachmentChunks.Skip(1))
|
||||
{
|
||||
mfd = new MultipartFormDataContent();
|
||||
mfd.Add(new StringContent(FixClyde(name).Truncate(80)), "username");
|
||||
if (avatarUrl != null) mfd.Add(new StringContent(avatarUrl), "avatar_url");
|
||||
await AddAttachmentsToMultipart(mfd, chunk);
|
||||
using var mfd2 = new MultipartFormDataContent();
|
||||
mfd2.Add(new StringContent(FixClyde(name).Truncate(80)), "username");
|
||||
if (avatarUrl != null) mfd2.Add(new StringContent(avatarUrl), "avatar_url");
|
||||
await AddAttachmentsToMultipart(mfd2, chunk);
|
||||
|
||||
// Don't bother with ?wait, we're just kinda firehosing this stuff
|
||||
// also don't error check, the real message itself is already sent
|
||||
await _client.PostAsync($"{DiscordConfig.APIUrl}webhooks/{webhook.Id}/{webhook.Token}", mfd);
|
||||
await _client.PostAsync($"{DiscordConfig.APIUrl}webhooks/{webhook.Id}/{webhook.Token}", mfd2);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
// At this point we're sure we have a 2xx status code, so just assume success
|
||||
// TODO: can we do this without a round-trip to a string?
|
||||
|
Loading…
Reference in New Issue
Block a user