From 50b8685e442ea228cba9daf5729917bf24f86786 Mon Sep 17 00:00:00 2001 From: Ske Date: Thu, 24 Dec 2020 22:27:03 +0100 Subject: [PATCH] Clarify timeout overflow message --- PluralKit.Bot/Commands/Autoproxy.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/PluralKit.Bot/Commands/Autoproxy.cs b/PluralKit.Bot/Commands/Autoproxy.cs index 91e2debd..39615607 100644 --- a/PluralKit.Bot/Commands/Autoproxy.cs +++ b/PluralKit.Bot/Commands/Autoproxy.cs @@ -154,9 +154,13 @@ 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, @@ -164,6 +168,8 @@ namespace PluralKit.Bot 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