- nick++;
- // fetch the user's current silence list
- silencelist* sl = (silencelist*)user->GetExt("silence_list");
- // what, they dont have one??? WE'RE ALL GONNA DIE! ...no, we just create an empty one.
- if (!sl)
+ // one or more parameters, add or delete entry from the list (only the first parameter is used)
+ std::string mask = parameters[0] + 1;
+ char action = *parameters[0];
+
+ if (!mask.length())
+ {
+ // 'SILENCE +' or 'SILENCE -', assume *!*@*
+ mask = "*!*@*";
+ }
+
+ ModeParser::CleanMask(mask);
+
+ if (action == '-')
+ {
+ // fetch their silence list
+ silencelist* sl;
+ user->GetExt("silence_list", sl);
+ // does it contain any entries and does it exist?
+ if (sl)
+ {
+ if (sl->size())
+ {
+ for (silencelist::iterator i = sl->begin(); i != sl->end(); i++)
+ {
+ // search through for the item
+ irc::string listitem = i->c_str();
+ if (listitem == mask)
+ {
+ sl->erase(i);
+ user->WriteServ("950 %s %s :Removed %s from silence list",user->nick, user->nick, mask.c_str());
+ break;
+ }
+ }
+ }
+ else
+ {
+ // tidy up -- if a user's list is empty, theres no use having it
+ // hanging around in the user record.
+ DELETE(sl);
+ user->Shrink("silence_list");
+ }
+ }
+ }
+ else if (action == '+')