Merge branch 'main' into newdiscord

This commit is contained in:
Ske 2021-01-15 10:35:20 +01:00
commit 04109a133f
6 changed files with 27 additions and 9 deletions

View File

@ -4,9 +4,7 @@ on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:

View File

@ -157,16 +157,26 @@ namespace PluralKit.Bot
else if (ctx.Match("reset", "default")) newTimeoutHours = -1;
else if (!int.TryParse(ctx.RemainderOrNull(), out newTimeoutHours)) throw new PKError("Duration must be a number of hours.");
int? overflow = null;
if (newTimeoutHours > 100000)
{
// sanity check to prevent seconds overflow if someone types in 999999999
overflow = newTimeoutHours;
newTimeoutHours = 0;
}
var newTimeout = newTimeoutHours > -1 ? Duration.FromHours(newTimeoutHours) : (Duration?) null;
await _db.Execute(conn => _repo.UpdateSystem(conn, ctx.System.Id,
new SystemPatch { LatchTimeout = (int?) newTimeout?.TotalSeconds }));
if (newTimeoutHours == -1)
await ctx.Reply($"{Emojis.Success} Latch timeout reset to default ({ProxyMatcher.DefaultLatchExpiryTime.ToTimeSpan().Humanize()}).");
else if (newTimeoutHours == 0 && overflow != null)
await ctx.Reply($"{Emojis.Success} Latch timeout disabled. Latch mode autoproxy will never time out. ({overflow} hours is too long)");
else if (newTimeoutHours == 0)
await ctx.Reply($"{Emojis.Success} Latch timeout disabled. Latch mode autoproxy will never time out.");
else
await ctx.Reply($"{Emojis.Success} Latch timeout set to {newTimeout.Value!.ToTimeSpan().Humanize()} hours.");
await ctx.Reply($"{Emojis.Success} Latch timeout set to {newTimeout.Value!.ToTimeSpan().Humanize()}.");
}
public async Task AutoproxyAccount(Context ctx)

View File

@ -112,11 +112,16 @@ namespace PluralKit.Bot
if (trigger.MessageReference?.ChannelId == trigger.ChannelId)
{
var repliedTo = await FetchReplyOriginalMessage(trigger.MessageReference);
if (repliedTo != null)
{
var embed = CreateReplyEmbed(repliedTo);
if (embed != null)
embeds.Add(embed);
}
// TODO: have a clean error for when message can't be fetched instead of just being silent
}
// Send the webhook
var content = match.ProxyContent;
if (!allowEmbeds) content = content.BreakLinkEmbeds();

View File

@ -76,7 +76,7 @@ namespace PluralKit.Bot
if (e is WebhookExecutionErrorOnDiscordsEnd) return false;
// Socket errors are *not our problem*
if (e is SocketException) return false;
if (e.GetBaseException() is SocketException) return false;
// Tasks being cancelled for whatver reason are, you guessed it, also not our problem.
if (e is TaskCanceledException) return false;

View File

@ -16,7 +16,7 @@ namespace PluralKit.Core
[JsonIgnore] public string ProxyString => $"{Prefix ?? ""}text{Suffix ?? ""}";
public bool IsEmpty => Prefix == null && Suffix == null;
[JsonIgnore] public bool IsEmpty => Prefix == null && Suffix == null;
public bool Equals(ProxyTag other) => Prefix == other.Prefix && Suffix == other.Suffix;

View File

@ -12,6 +12,11 @@ Accompanying it is an [OpenAPI v3.0 definition](https://github.com/xSke/PluralKi
PluralKit has a basic HTTP REST API for querying and modifying your system.
The root endpoint of the API is `https://api.pluralkit.me/v1/`.
#### Authorization header token example
```
Authorization: z865MC7JNhLtZuSq1NXQYVe+FgZJHBfeBCXOPYYRwH4liDCDrsd7zdOuR45mX257
```
Endpoints will always return all fields, using `null` when a value is missing. On `PATCH` endpoints,
missing fields from the JSON request will be ignored and preserved as is, but on `POST` endpoints will
be set to `null` or cleared.