+ /* syntax: CBAN #channel time :reason goes here */
+ /* 'time' is a human-readable timestring, like 2d3h2s. */
+
+ if (parameters.size() == 1)
+ {
+ if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "CBAN", user))
+ {
+ ServerInstance->SNO->WriteToSnoMask('x',"%s Removed CBan on %s.",user->nick.c_str(),parameters[0].c_str());
+ }
+ else
+ {
+ user->WriteServ("NOTICE %s :*** CBan %s not found in list, try /stats C.",user->nick.c_str(),parameters[0].c_str());
+ }
+
+ return CMD_SUCCESS;
+ }
+ else if (parameters.size() >= 2)
+ {
+ // Adding - XXX todo make this respect <insane> tag perhaps..
+ long duration = ServerInstance->Duration(parameters[1]);
+ CBan *r = NULL;
+
+ try
+ {
+ r = new CBan(ServerInstance, ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str());
+ }
+ catch (...)
+ {
+ ; // Do nothing. If we get here, the regex was fucked up, and they already got told it fucked up.
+ }
+
+ if (r)
+ {
+ if (ServerInstance->XLines->AddLine(r, user))
+ {
+ if (!duration)
+ {
+ ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent CBan for %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str());
+ }
+ else
+ {
+ time_t c_requires_crap = duration + ServerInstance->Time();
+ ServerInstance->SNO->WriteToSnoMask('x', "%s added timed CBan for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
+ }
+
+ ServerInstance->XLines->ApplyLines();
+ }
+ else
+ {
+ delete r;
+ user->WriteServ("NOTICE %s :*** CBan for %s already exists", user->nick.c_str(), parameters[0].c_str());
+ }
+ }
+ }
+
+ return CMD_FAILURE;