Make /CBAN behave like documented.

This commit is contained in:
Sadie Powell 2025-01-17 17:36:47 +00:00
parent 6cb0f8a6d1
commit b63a7a4d22
2 changed files with 7 additions and 8 deletions

View File

@ -571,7 +571,7 @@ Sends a message to all users with the +g snomask.
"> ">
<helptopic key="cban" title="/CBAN <channelmask> [<duration> [:<reason>]]" value=" <helptopic key="cban" title="/CBAN <channelmask> [<duration> [:<reason>]]" value="
Sets or removes a global channel based ban. You must specify all three parameters Sets or removes a global channel based ban. You must specify two or more parameters
to add a ban, and one parameter to remove a ban (just the channelmask). to add a ban, and one parameter to remove a ban (just the channelmask).
The duration may be specified in seconds, or in the format The duration may be specified in seconds, or in the format

View File

@ -125,26 +125,25 @@ public:
else else
{ {
// Adding - XXX todo make this respect <insane> tag perhaps.. // Adding - XXX todo make this respect <insane> tag perhaps..
unsigned long duration; unsigned long duration = 0;
if (!Duration::TryFrom(parameters[1], duration)) if (parameters.size() > 2 && !Duration::TryFrom(parameters[1], duration))
{ {
user->WriteNotice("*** Invalid duration for CBan."); user->WriteNotice("*** Invalid duration for CBan.");
return CmdResult::FAILURE; return CmdResult::FAILURE;
} }
const char* reason = (parameters.size() > 2) ? parameters[2].c_str() : "No reason supplied"; auto* r = new CBan(ServerInstance->Time(), duration, user->nick, parameters.back(), parameters[0]);
auto* r = new CBan(ServerInstance->Time(), duration, user->nick, reason, parameters[0]);
if (ServerInstance->XLines->AddLine(r, user)) if (ServerInstance->XLines->AddLine(r, user))
{ {
if (!duration) if (!duration)
{ {
ServerInstance->SNO.WriteToSnoMask('x', "{} added a permanent CBan on {}: {}", user->nick, parameters[0], reason); ServerInstance->SNO.WriteToSnoMask('x', "{} added a permanent CBan on {}: {}",
user->nick, parameters[0], r->reason);
} }
else else
{ {
ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed CBan on {}, expires in {} (on {}): {}", ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed CBan on {}, expires in {} (on {}): {}",
user->nick, parameters[0], Duration::ToString(duration), user->nick, parameters[0], Duration::ToString(duration), Time::FromNow(duration), r->reason);
Time::FromNow(duration), reason);
} }
} }
else else