Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion DiscordBot/Data/FuzzTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,28 @@ public class FuzzTable
private List<string> choices = new();
private Queue<string> recent = new();

// By default, multiple equal entries adds weight to their selection.
// If true, duplicates are rejected silently.
//
public bool Unique { get; set; } = false;

public void Clear()
{
choices.Clear();
recent.Clear();
Unique = false;
}

public int Count => choices.Count + recent.Count;

// Add a string as a valid choice from which to pick.
// Note that empty strings or whitespace can be added manually as valid choices.
// Duplicate choices are also allowed for weighting.
// Duplicate choices are also allowed for weighting, unless Unique is set true.
//
public void Add(string choice)
{
if (Unique && choices.Contains(choice))
return;
choices.Add(choice);
}

Expand Down
1 change: 1 addition & 0 deletions DiscordBot/Modules/UserModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ public async Task SlapUser(params IUser[] users)
{
try
{
_slapObjects.Unique = true;
if (_slapObjects.Count == 0)
_slapObjects.Load(Settings.UserModuleSlapObjectsTable);
}
Expand Down
Loading