- if (action == '-')
- {
- std::string decomppattern = DecompPattern(pattern);
- // fetch their silence list
- silencelist* sl = ext.get(user);
- // does it contain any entries and does it exist?
- if (sl)
- {
- for (silencelist::iterator i = sl->begin(); i != sl->end(); i++)
- {
- // search through for the item
- irc::string listitem = i->first.c_str();
- if (listitem == mask && i->second == pattern)
- {
- sl->erase(i);
- user->WriteNumeric(950, "%s %s :Removed %s %s from silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), decomppattern.c_str());
- if (!sl->size())
- {
- ext.unset(user);
- }
- return CMD_SUCCESS;
- }
- }
- }
- user->WriteNumeric(952, "%s %s :%s %s does not exist on your silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), decomppattern.c_str());
- }
- else if (action == '+')
- {
- // fetch the user's current silence list
- silencelist* sl = ext.get(user);
- if (!sl)
- {
- sl = new silencelist;
- ext.set(user, sl);
- }
- if (sl->size() > maxsilence)
- {
- user->WriteNumeric(952, "%s %s :Your silence list is full",user->nick.c_str(), user->nick.c_str());
- return CMD_FAILURE;
- }
-
- std::string decomppattern = DecompPattern(pattern);
- for (silencelist::iterator n = sl->begin(); n != sl->end(); n++)
- {
- irc::string listitem = n->first.c_str();
- if (listitem == mask && n->second == pattern)
- {
- user->WriteNumeric(952, "%s %s :%s %s is already on your silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), decomppattern.c_str());
- return CMD_FAILURE;
- }
- }
- if (((pattern & SILENCE_EXCLUDE) > 0))
- {
- sl->push_front(silenceset(mask,pattern));
- }
- else
- {
- sl->push_back(silenceset(mask,pattern));
- }
- user->WriteNumeric(951, "%s %s :Added %s %s to silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), decomppattern.c_str());
- return CMD_SUCCESS;
- }
- }
- return CMD_SUCCESS;
+ // The default if no flags have been specified.
+ SF_DEFAULT = SF_NOTICE_CHANNEL | SF_NOTICE_USER | SF_PRIVMSG_CHANNEL | SF_PRIVMSG_USER | SF_TAGMSG_CHANNEL |
+ SF_TAGMSG_USER | SF_CTCP_CHANNEL | SF_CTCP_USER | SF_INVITE
+ };
+
+ // The flags that this mask is silenced for.
+ uint32_t flags;
+
+ // The mask which is silenced (e.g. *!*@example.com).
+ std::string mask;
+
+ SilenceEntry(uint32_t Flags, const std::string& Mask)
+ : flags(Flags)
+ , mask(Mask)
+ {
+ }
+
+ bool operator <(const SilenceEntry& other) const
+ {
+ if (flags & SF_EXEMPT && other.flags & ~SF_EXEMPT)
+ return true;
+ if (other.flags & SF_EXEMPT && flags & ~SF_EXEMPT)
+ return false;
+ if (flags < other.flags)
+ return true;
+ if (other.flags < flags)
+ return false;
+ return mask < other.mask;