Compare commits

...

4 Commits
4.2.5 ... 4.2.6

7 changed files with 31 additions and 7 deletions

View File

@@ -113,6 +113,7 @@ docker-build:
# Use the official docker image. # Use the official docker image.
image: docker:latest image: docker:latest
stage: build stage: build
allow_failure: true
services: services:
- docker:dind - docker:dind
before_script: before_script:

View File

@@ -3,6 +3,12 @@
Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
## [4.2.6] - 22.06.2022
### Fixed
- Patron system should now properly by disabled on selfhosts by default.
## [4.2.5] - 18.06.2022 ## [4.2.5] - 18.06.2022
### Fixed ### Fixed

View File

@@ -7,7 +7,7 @@ namespace NadekoBot.Modules.Utility.Patronage;
public partial class PatronConfigData : ICloneable<PatronConfigData> public partial class PatronConfigData : ICloneable<PatronConfigData>
{ {
[Comment("DO NOT CHANGE")] [Comment("DO NOT CHANGE")]
public int Version { get; set; } = 1; public int Version { get; set; } = 2;
[Comment("Whether the patronage feature is enabled")] [Comment("Whether the patronage feature is enabled")]
public bool IsEnabled { get; set; } public bool IsEnabled { get; set; }

View File

@@ -18,5 +18,19 @@ public class PatronageConfig : ConfigServiceBase<PatronConfigData>
x => x.IsEnabled, x => x.IsEnabled,
bool.TryParse, bool.TryParse,
ConfigPrinters.ToString); ConfigPrinters.ToString);
Migrate();
}
private void Migrate()
{
ModifyConfig(c =>
{
if (c.Version == 1)
{
c.Version = 2;
c.IsEnabled = false;
}
});
} }
} }

View File

@@ -3,6 +3,7 @@ using LinqToDB.EntityFrameworkCore;
using NadekoBot.Common.ModuleBehaviors; using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Db.Models; using NadekoBot.Db.Models;
using OneOf; using OneOf;
using OneOf.Types;
using StackExchange.Redis; using StackExchange.Redis;
using CommandInfo = Discord.Commands.CommandInfo; using CommandInfo = Discord.Commands.CommandInfo;
@@ -500,8 +501,8 @@ public sealed class PatronageService
if (!confData.IsEnabled) if (!confData.IsEnabled)
return default; return default;
if (_creds.IsOwner(userId)) // if (_creds.IsOwner(userId))
return default; // return default;
// get user tier // get user tier
var patron = await GetPatronAsync(userId); var patron = await GetPatronAsync(userId);
@@ -558,7 +559,9 @@ public sealed class PatronageService
data.TryGetValue(QuotaPer.PerMonth, out var monthly) ? monthly : null data.TryGetValue(QuotaPer.PerMonth, out var monthly) ? monthly : null
); );
return quotaCheckResult.Match(_ => default, x => x); return quotaCheckResult.Match<OneOf<Success, InsufficientTier, QuotaLimit>>(
_ => new Success(),
x => x);
} }
private bool TryGetTierDataOrLower<T>( private bool TryGetTierDataOrLower<T>(

View File

@@ -7,7 +7,7 @@ namespace NadekoBot.Services;
public sealed class StatsService : IStatsService, IReadyExecutor, INService public sealed class StatsService : IStatsService, IReadyExecutor, INService
{ {
public const string BOT_VERSION = "4.2.5"; public const string BOT_VERSION = "4.2.6";
public string Author public string Author
=> "Kwoth#2452"; => "Kwoth#2452";

View File

@@ -1,7 +1,7 @@
# DO NOT CHANGE # DO NOT CHANGE
version: 1 version: 2
# Whether the patronage feature is enabled # Whether the patronage feature is enabled
isEnabled: true isEnabled: false
# List of patron only features and relevant quota data # List of patron only features and relevant quota data
quotas: quotas:
# Dictionary of feature names with their respective limits. Set to null for unlimited # Dictionary of feature names with their respective limits. Set to null for unlimited