+ if (!ServerInstance->IsValidMask(parameters[2]))
{
{
- Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :Invalid ban mask");
- return;
+ user->WriteServ("NOTICE "+std::string(user->nick)+" :Invalid ban mask");
+ return CMD_FAILURE;
}
for (BanList::iterator i = channel->bans.begin(); i != channel->bans.end(); i++)
{
if (!strcasecmp(i->data,parameters[2]))
{
}
for (BanList::iterator i = channel->bans.begin(); i != channel->bans.end(); i++)
{
if (!strcasecmp(i->data,parameters[2]))
{
- 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;
+ user->WriteServ("NOTICE "+std::string(user->nick)+" :The ban "+std::string(parameters[2])+" is already on the banlist of "+std::string(parameters[0]));
+ return CMD_FAILURE;
}
}
TimedBan T;
std::string channelname = parameters[0];
}
}
TimedBan T;
std::string channelname = parameters[0];
- unsigned long expire = Srv->CalcDuration(parameters[1]) + time(NULL);
- if (Srv->CalcDuration(parameters[1]) < 1)
+ unsigned long expire = ServerInstance->Duration(parameters[1]) + time(NULL);
+ if (ServerInstance->Duration(parameters[1]) < 1)
{
{
- Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :Invalid ban time");
- return;
+ user->WriteServ("NOTICE "+std::string(user->nick)+" :Invalid ban time");
/* Check if the ban was actually added (e.g. banlist was NOT full) */
bool was_added = false;
for (BanList::iterator i = channel->bans.begin(); i != channel->bans.end(); i++)
/* Check if the ban was actually added (e.g. banlist was NOT full) */
bool was_added = false;
for (BanList::iterator i = channel->bans.begin(); i != channel->bans.end(); i++)
@@ -98,14+102,16 @@ class cmd_tban : public command_t
T.mask = mask;
T.expire = expire;
TimedBanList.push_back(T);
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.");
+ channel->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s added a timed ban on %s lasting for %s seconds.", channel->name, user->nick, mask.c_str(), duration);
+ return CMD_SUCCESS;
}
}
- return;
+ return CMD_FAILURE;
}
}
- else WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, channel->name);
- return;
+ else user->WriteServ("482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, channel->name);
+ return CMD_FAILURE;
}
}
- WriteServ(user->fd,"401 %s %s :No such channel",user->nick, parameters[0]);
+ user->WriteServ("401 %s %s :No such channel",user->nick, parameters[0]);
+ return CMD_FAILURE;
}
};
}
};
@@ -113,12+119,12 @@ class ModuleTimedBans : public Module
{
cmd_tban* mycommand;
public:
{
cmd_tban* mycommand;
public:
- ModuleTimedBans(Server* Me)
+ ModuleTimedBans(InspIRCd* Me)
: Module::Module(Me)
{
: Module::Module(Me)
{
- Srv = Me;
- mycommand = new cmd_tban();
- Srv->AddCommand(mycommand);
+
+ mycommand = new cmd_tban(ServerInstance);
+ ServerInstance->AddCommand(mycommand);
TimedBanList.clear();
}
TimedBanList.clear();
}
@@ -134,11+140,13 @@ class ModuleTimedBans : public Module
virtual int OnDelBan(userrec* source, chanrec* chan, const std::string &banmask)
{
virtual int OnDelBan(userrec* source, chanrec* chan, const std::string &banmask)
{
+ irc::string listitem = banmask.c_str();
+ irc::string thischan = chan->name;
for (timedbans::iterator i = TimedBanList.begin(); i < TimedBanList.end(); i++)
{
for (timedbans::iterator i = TimedBanList.begin(); i < TimedBanList.end(); i++)
{
- irc::string listitem = banmask.c_str();
irc::string target = i->mask.c_str();
irc::string target = i->mask.c_str();
- if (listitem == target)
+ irc::string tchan = i->channel.c_str();
+ if ((listitem == target) && (tchan == thischan))
{
TimedBanList.erase(i);
break;
{
TimedBanList.erase(i);
break;
@@ -157,11+165,11 @@ class ModuleTimedBans : public Module