mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 04:22:04 -04:00
Added a feature to make juicers way less generous for loser users
This commit is contained in:
@@ -13,7 +13,7 @@ public class JuiceCommand : ICommand
|
||||
public List<Regex> Patterns => [new Regex("^juiceme")];
|
||||
public string HelpText => "Get juice!";
|
||||
public bool HideFromHelp => false;
|
||||
public UserRight RequiredRight => UserRight.Guest;
|
||||
public UserRight RequiredRight => UserRight.Loser;
|
||||
public TimeSpan Timeout => TimeSpan.FromSeconds(10);
|
||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx)
|
||||
{
|
||||
@@ -21,9 +21,10 @@ public class JuiceCommand : ICommand
|
||||
// Have to attach the entity because it is coming from another DB context
|
||||
// https://stackoverflow.com/questions/52718652/ef-core-sqlite-sqlite-error-19-unique-constraint-failed
|
||||
db.Users.Attach(user);
|
||||
var juicerSettings = await Helpers.GetMultipleValues([BuiltIn.Keys.JuiceAmount, BuiltIn.Keys.JuiceCooldown]);
|
||||
var juicerSettings = await Helpers.GetMultipleValues([BuiltIn.Keys.JuiceAmount, BuiltIn.Keys.JuiceCooldown, BuiltIn.Keys.JuiceLoserDivision]);
|
||||
var cooldown = juicerSettings[BuiltIn.Keys.JuiceCooldown].ToType<int>();
|
||||
var amount = juicerSettings[BuiltIn.Keys.JuiceAmount].ToType<int>();
|
||||
if (user.UserRight == UserRight.Loser) amount /= juicerSettings[BuiltIn.Keys.JuiceLoserDivision].ToType<int>();
|
||||
var lastJuicer = (await db.Juicers.Where(j => j.User == user).ToListAsync(ctx)).OrderByDescending(j => j.JuicedAt).Take(1).ToList();
|
||||
if (lastJuicer.Count == 0)
|
||||
{
|
||||
|
||||
@@ -479,6 +479,16 @@ public static class BuiltIn
|
||||
Default = "10",
|
||||
IsSecret = false,
|
||||
CacheDuration = TimeSpan.FromHours(1)
|
||||
},
|
||||
new BuiltInSettingsModel
|
||||
{
|
||||
Key = Keys.JuiceLoserDivision,
|
||||
Regex = @"\d+",
|
||||
Description = "Amount to divide the juice by if the user's rack is Loser",
|
||||
Default = "5",
|
||||
IsSecret = false,
|
||||
CacheDuration = TimeSpan.FromHours(1)
|
||||
},
|
||||
new BuiltInSettingsModel
|
||||
{
|
||||
Key = Keys.CrackedZalgoFuckUpMode,
|
||||
@@ -541,6 +551,7 @@ public static class BuiltIn
|
||||
public static string TwitchShillRestreamOnCommercial = "Twitch.ShillRestreamOnCommercial";
|
||||
public static string KiwiFarmsInactivityTimeout = "KiwiFarms.InactivityTimeout";
|
||||
public static string KiwiFarmsPingInterval = "KiwiFarms.PingInterval";
|
||||
public static string JuiceLoserDivision = "Juice.LoserDivision";
|
||||
public static string CrackedZalgoFuckUpMode = "Cracked.ZalgoFuckUpMode";
|
||||
public static string CrackedZalgoFuckUpPosition = "Cracked.ZalgoFuckUpPosition";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user