mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-16 02:30:11 +00:00
Clarify timeout overflow message
This commit is contained in:
parent
4e67c79154
commit
50b8685e44
1 changed files with 6 additions and 0 deletions
|
|
@ -154,9 +154,13 @@ 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)
|
if (newTimeoutHours > 100000)
|
||||||
|
{
|
||||||
// sanity check to prevent seconds overflow if someone types in 999999999
|
// sanity check to prevent seconds overflow if someone types in 999999999
|
||||||
|
overflow = newTimeoutHours;
|
||||||
newTimeoutHours = 0;
|
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,
|
||||||
|
|
@ -164,6 +168,8 @@ namespace PluralKit.Bot
|
||||||
|
|
||||||
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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue