- std::vector<std::string> setban;
- setban.push_back(parameters[0]);
- setban.push_back("+b");
- setban.push_back(parameters[2]);
- // use CallCommandHandler to make it so that the user sets the mode
- // themselves
- ServerInstance->CallCommandHandler("MODE",setban,user);
- for (BanList::iterator i = channel->bans.begin(); i != channel->bans.end(); i++)
- if (!strcasecmp(i->data.c_str(), mask.c_str()))
- goto found;
- return CMD_FAILURE;
-found:
+ bool isextban = ((mask.size() > 2) && (mask[1] == ':'));
+ if (!isextban && !InspIRCd::IsValidMask(mask))
+ mask.append("!*@*");
+
+ Modes::ChangeList setban;
+ setban.push_add(ServerInstance->Modes->FindMode('b', MODETYPE_CHANNEL), mask);
+ // Pass the user (instead of ServerInstance->FakeClient) to ModeHandler::Process() to
+ // make it so that the user sets the mode themselves
+ ServerInstance->Modes->Process(user, channel, NULL, setban);
+ if (ServerInstance->Modes->GetLastParse().empty())
+ {
+ user->WriteNotice("Invalid ban mask");
+ return CMD_FAILURE;
+ }
+