- }
- TimedBan T;
- std::string channelname = parameters[0];
- unsigned long expire = Srv->CalcDuration(parameters[1]) + time(NULL);
- if (Srv->CalcDuration(parameters[1]) < 1)
- {
- Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :Invalid ban time");
+ for (timedbans::iterator i = TimedBanList.begin(); i < TimedBanList.end(); i++)
+ {
+ irc::string listitem = i->mask.c_str();
+ irc::string target = parameters[2];
+ irc::string listchan = i->channel.c_str();
+ irc::string targetchan = parameters[0];
+ if ((listitem == target) && (listchan == targetchan))
+ {
+ Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :The ban "+std::string(parameters[2])+" is already on the banlist of "+std::string(parameters[0]));
+ return;
+ }
+ }
+ TimedBan T;
+ std::string channelname = parameters[0];
+ unsigned long expire = Srv->CalcDuration(parameters[1]) + time(NULL);
+ if (Srv->CalcDuration(parameters[1]) < 1)
+ {
+ Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :Invalid ban time");
+ return;
+ }
+ char duration[MAXBUF];
+ snprintf(duration,MAXBUF,"%lu",Srv->CalcDuration(parameters[1]));
+ std::string mask = parameters[2];
+ const char *setban[32];
+ setban[0] = parameters[0];
+ setban[1] = "+b";
+ setban[2] = parameters[2];
+ // use CallCommandHandler to make it so that the user sets the mode
+ // themselves
+ Srv->CallCommandHandler("MODE",setban,3,user);
+ T.channel = channelname;
+ T.mask = mask;
+ T.expire = expire;
+ TimedBanList.push_back(T);
+ Srv->SendChannelServerNotice(Srv->GetServerName(),channel,"NOTICE "+std::string(channel->name)+" :"+std::string(user->nick)+" added a timed ban on "+mask+" lasting for "+std::string(duration)+" seconds.");