- /* full form to add a CBAN */
- /* XXX - checking on chnames */
- chname = parameters[0];
- expiry = 0;
-//TIME + Srv->CalcDuration(parameters[1]);
- reason = parameters[2];
-
- CBan meow(chname, reason, expiry);
- cbans.push_back(meow);
+ // 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.", user->nick.c_str(), parameters[0].c_str());
+ }
+ else
+ {
+ time_t c_requires_crap = duration + ServerInstance->Time();
+ ServerInstance->SNO->WriteToSnoMask('x', "%s added timed CBan for %s, expires on %s", user->nick.c_str(), parameters[0].c_str(),
+ ServerInstance->TimeString(c_requires_crap).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());
+ }
+ }