Merge branch 'main' into newdiscord
This commit is contained in:
commit
04109a133f
2
.github/workflows/dotnetcore.yml
vendored
2
.github/workflows/dotnetcore.yml
vendored
@ -4,9 +4,7 @@ on: [push, pull_request]
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
with:
|
with:
|
||||||
|
@ -157,16 +157,26 @@ namespace PluralKit.Bot
|
|||||||
else if (ctx.Match("reset", "default")) newTimeoutHours = -1;
|
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.");
|
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;
|
var newTimeout = newTimeoutHours > -1 ? Duration.FromHours(newTimeoutHours) : (Duration?) null;
|
||||||
await _db.Execute(conn => _repo.UpdateSystem(conn, ctx.System.Id,
|
await _db.Execute(conn => _repo.UpdateSystem(conn, ctx.System.Id,
|
||||||
new SystemPatch { LatchTimeout = (int?) newTimeout?.TotalSeconds }));
|
new SystemPatch { LatchTimeout = (int?) newTimeout?.TotalSeconds }));
|
||||||
|
|
||||||
if (newTimeoutHours == -1)
|
if (newTimeoutHours == -1)
|
||||||
await ctx.Reply($"{Emojis.Success} Latch timeout reset to default ({ProxyMatcher.DefaultLatchExpiryTime.ToTimeSpan().Humanize()}).");
|
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)
|
else if (newTimeoutHours == 0)
|
||||||
await ctx.Reply($"{Emojis.Success} Latch timeout disabled. Latch mode autoproxy will never time out.");
|
await ctx.Reply($"{Emojis.Success} Latch timeout disabled. Latch mode autoproxy will never time out.");
|
||||||
else
|
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)
|
public async Task AutoproxyAccount(Context ctx)
|
||||||
|
@ -112,9 +112,14 @@ namespace PluralKit.Bot
|
|||||||
if (trigger.MessageReference?.ChannelId == trigger.ChannelId)
|
if (trigger.MessageReference?.ChannelId == trigger.ChannelId)
|
||||||
{
|
{
|
||||||
var repliedTo = await FetchReplyOriginalMessage(trigger.MessageReference);
|
var repliedTo = await FetchReplyOriginalMessage(trigger.MessageReference);
|
||||||
var embed = CreateReplyEmbed(repliedTo);
|
if (repliedTo != null)
|
||||||
if (embed != null)
|
{
|
||||||
embeds.Add(embed);
|
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
|
// Send the webhook
|
||||||
|
@ -76,7 +76,7 @@ namespace PluralKit.Bot
|
|||||||
if (e is WebhookExecutionErrorOnDiscordsEnd) return false;
|
if (e is WebhookExecutionErrorOnDiscordsEnd) return false;
|
||||||
|
|
||||||
// Socket errors are *not our problem*
|
// 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.
|
// Tasks being cancelled for whatver reason are, you guessed it, also not our problem.
|
||||||
if (e is TaskCanceledException) return false;
|
if (e is TaskCanceledException) return false;
|
||||||
|
@ -16,7 +16,7 @@ namespace PluralKit.Core
|
|||||||
|
|
||||||
[JsonIgnore] public string ProxyString => $"{Prefix ?? ""}text{Suffix ?? ""}";
|
[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;
|
public bool Equals(ProxyTag other) => Prefix == other.Prefix && Suffix == other.Suffix;
|
||||||
|
|
||||||
@ -31,4 +31,4 @@ namespace PluralKit.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.
|
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/`.
|
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,
|
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
|
missing fields from the JSON request will be ignored and preserved as is, but on `POST` endpoints will
|
||||||
be set to `null` or cleared.
|
be set to `null` or cleared.
|
||||||
|
Loading…
Reference in New Issue
Block a user