- if ((!user) || (!chan)) {
- log(DEFAULT,"*** BUG *** TakeBan was given an invalid parameter");
- dest = "";
- return dest;
- }
-
- log(DEBUG,"del_ban: %s %s",chan->name,user->nick);
- for (BanList::iterator i = chan->bans.begin(); i != chan->bans.end(); i++)
- {
- if (!strcasecmp(i->data,dest.c_str()))
- {
- int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnDelBan,OnDelBan(user,chan,dest));
- if (MOD_RESULT)
+ if ((!user) || (!chan))
+ {
+ ServerInstance->Logs->Log("MODE",DEFAULT,"*** BUG *** AddBan was given an invalid parameter");
+ dest.clear();
+ return dest;
+ }
+
+ /* Attempt to tidy the mask */
+ ModeParser::CleanMask(dest);
+ /* If the mask was invalid, we exit */
+ if (dest.empty() || dest.length() > 250)
+ return dest;
+
+ long maxbans = chan->GetMaxBans();
+ if (IS_LOCAL(user) && ((unsigned)chan->bans.size() >= (unsigned)maxbans))
+ {
+ user->WriteServ("478 %s %s :Channel ban list for %s is full (maximum entries for this channel is %ld)",user->nick.c_str(), chan->name.c_str(), chan->name.c_str(), maxbans);
+ dest.clear();
+ return dest;
+ }
+
+ ModResult MOD_RESULT;
+ FIRST_MOD_RESULT(OnAddBan, MOD_RESULT, (user,chan,dest));
+ if (MOD_RESULT == MOD_RES_DENY)
+ {
+ dest.clear();
+ return dest;
+ }
+
+ for (BanList::iterator i = chan->bans.begin(); i != chan->bans.end(); i++)
+ {
+ if (i->data == dest)
+ {
+ /* dont allow a user to set the same ban twice */
+ dest.clear();
+ return dest;
+ }
+ }
+
+ b.set_time = ServerInstance->Time();
+ b.data.assign(dest, 0, MAXBUF);
+ b.set_by.assign(user->nick, 0, 64);
+ chan->bans.push_back(b);
+ return dest;
+}
+
+std::string& ModeChannelBan::DelBan(User *user, std::string& dest, Channel *chan, int)
+{
+ if ((!user) || (!chan))
+ {
+ ServerInstance->Logs->Log("MODE",DEFAULT,"*** BUG *** TakeBan was given an invalid parameter");
+ dest.clear();
+ return dest;
+ }
+
+ for (BanList::iterator i = chan->bans.begin(); i != chan->bans.end(); i++)
+ {
+ if (!strcasecmp(i->data.c_str(), dest.c_str()))
+ {
+ ModResult MOD_RESULT;
+ FIRST_MOD_RESULT(OnDelBan, MOD_RESULT, (user, chan, dest));
+ if (MOD_RESULT == MOD_RES_DENY)