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="
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).
The duration may be specified in seconds, or in the format

View File

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