Add Optional Duration Argument to Kickban Command - #227
Open
MrCoolPotato wants to merge 2 commits into
Open
Conversation
Author
|
I forgot to add this in the PR description, but this was AI-assisted with Claude because I suck at Perl. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add optional duration argument to
!kickbanSummary
Adds an optional
<duration>argument to the!kickbancommand:<duration>is in minutes, in [0,60]. If duration is omitted then the server default of 15 minutes is used.If an already banned player is banned again, this will change it so the newer ban takes precedence whereas before both bans took effect, effectively setting the ban duration to be the max of the two.
This is done with a SPADS plugin that overrides the kickban command handler. It checks if a duration argument was specified, if so then it updates the config to equal that duration, calls the spads hkickban then resets the config to its previous value.
It also checks for runtime errors or version differences and will run the original kickban handler in its place if either of these are present. This allows the old kickban command to work if this code breaks in the future.
Why
This would be helpful to keep out people spamming in chat for longer, or it could also be used as an unban command via !kickban player_name 0 to reset their ban duration to 0 minutes allowing them to rejoin a lobby.
This has been requested by players: https://discordapp.com/channels/549281623154229250/1524568970336669851
Adding an optional argument would not remove any existing functionality and !kickban player_name works (almost) the same as it did before.
Details
Before anything is done, it checks the current spads version against the last version the plugin was manually tested against, and if spads version is newer it calls the previous kickban handler. Also if there are runtime errors it calls the previous handler
If a player already on the banned list is banned again, before this would create a new entry in the list and one player would have 2 entries and would only become unbanned once both expire. In order to allow for unbanning, This code will remove any existing ban entry which could have been added by a kickban command (the remaining duration is <=60) and then it will issue the new kickban. This is practically the same as the old behavior.
The actual banning is implemented by temporarily changing the banDuration config value, calling the previous handler and then changing the value back to what it was
Potential Issues
Testing
Each of these have been verified in a local Teiserver and SPADS environment
-when duration is omitted, server default is used.
-when duration is specified, it is actually used in place of server default
-when duration is specified for a user that is already banned, the new duration takes precedence
-version difference and error fallbacks both work as intended
-after a kickban of a different duration, the config default is restored