-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better bans #230
base: main
Are you sure you want to change the base?
Better bans #230
Conversation
Instead of using a fire-and-forget goroutine, time-based banning work with additional ban data.
main.go
Outdated
Log.Println("Rejected " + u.Name + " [" + host + "] (banned)") | ||
u.writeln(Devbot, "**You are banned**. If you feel this was a mistake, please reach out to the server admin. Include the following information: [ID "+u.id+"]") | ||
if banInfo.UseTime { | ||
u.writeln(Devbot, "You will be unbaned on "+banInfo.UnbanTime.Format(time.RFC3339)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a duration here instead of an absolute time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like that:
devbot: You will be unbaned in 41 days, 15 hours, 56 minutes, and 8 seconds.
or like that:
devbot: You will be unbaned in 13 seconds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's quite verbose. Which could be fine. But we do also have a pretty duration printer here: https://github.com/Arkaeriit/devzat/blob/c98c58e03fd3703f5d500424e886e5f06fe0768d/util.go#L420
what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ho right, I didn't remember this function. printPrettyDuration
is not very suitable for duration longer than a day, so not great for bans.
But maybe we can merge printPrettyDuration
and formatDuration
to prevent code duplication.
I'll make a proposition of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean. maybe it's better to keep it short but add ability to display days using the unit 'd'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reverted back to using 1 letter units with no space between the numeric value and the unit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's now in the format '9d 4h 3m'.
This makes it easier to remember which key is which.
I added an additional feature of storing names in the DB and displaying them when doing |
This PR adds the following improvement related to bans: