mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
feat(bot): add -plaintext flag alongside -raw
This commit is contained in:
parent
3d9be096cb
commit
23fe904464
5 changed files with 322 additions and 162 deletions
|
|
@ -352,7 +352,9 @@ public class ProxiedMessage
|
|||
else if (!await ctx.CheckPermissionsInGuildChannel(channel, PermissionSet.ViewChannel))
|
||||
showContent = false;
|
||||
|
||||
if (ctx.MatchRaw())
|
||||
var format = ctx.MatchFormat();
|
||||
|
||||
if (format != ReplyFormat.Standard)
|
||||
{
|
||||
var discordMessage = await _rest.GetMessageOrNull(message.Message.Channel, message.Message.Mid);
|
||||
if (discordMessage == null || !showContent)
|
||||
|
|
@ -365,21 +367,32 @@ public class ProxiedMessage
|
|||
return;
|
||||
}
|
||||
|
||||
await ctx.Reply($"```{content}```");
|
||||
|
||||
if (Regex.IsMatch(content, "```.*```", RegexOptions.Singleline))
|
||||
if (format == ReplyFormat.Raw)
|
||||
{
|
||||
var stream = new MemoryStream(Encoding.UTF8.GetBytes(content));
|
||||
await ctx.Rest.CreateMessage(
|
||||
ctx.Channel.Id,
|
||||
new MessageRequest
|
||||
{
|
||||
Content = $"{Emojis.Warn} Message contains codeblocks, raw source sent as an attachment."
|
||||
},
|
||||
new[] { new MultipartFile("message.txt", stream, null, null, null) });
|
||||
await ctx.Reply($"```{content}```");
|
||||
|
||||
if (Regex.IsMatch(content, "```.*```", RegexOptions.Singleline))
|
||||
{
|
||||
var stream = new MemoryStream(Encoding.UTF8.GetBytes(content));
|
||||
await ctx.Rest.CreateMessage(
|
||||
ctx.Channel.Id,
|
||||
new MessageRequest
|
||||
{
|
||||
Content = $"{Emojis.Warn} Message contains codeblocks, raw source sent as an attachment."
|
||||
},
|
||||
new[] { new MultipartFile("message.txt", stream, null, null, null) });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (format == ReplyFormat.Plaintext)
|
||||
{
|
||||
var eb = new EmbedBuilder()
|
||||
.Description($"Showing contents of message {message.Message.Mid}");
|
||||
await ctx.Reply(content, embed: eb.Build());
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (isDelete)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue