+/* Improved drop-in replacement for the /SILENCE command
+ * syntax: /SILENCE [+|-]<mask> <p|c|i|n|t|a|x> as in <privatemessage|channelmessage|invites|privatenotice|channelnotice|all|exclude>
+ *
+ * example that blocks all except private messages
+ * /SILENCE +*!*@* a
+ * /SILENCE +*!*@* px
+ *
+ * example that blocks all invites except from channel services
+ * /SILENCE +*!*@* i
+ * /SILENCE +chanserv!services@chatters.net ix
+ *
+ * example that blocks some bad dude from private, notice and inviting you
+ * /SILENCE +*!kiddie@lamerz.net pin
+ *
+ * TODO: possibly have add and remove check for existing host and only modify flags according to
+ * what's been changed instead of having to remove first, then add if you want to change
+ * an entry.
+ */
+
+// pair of hostmask and flags
+typedef std::pair<std::string, int> silenceset;
+
+// deque list of pairs
+typedef std::deque<silenceset> silencelist;
+
+// intmasks for flags
+static int SILENCE_PRIVATE = 0x0001; /* p private messages */
+static int SILENCE_CHANNEL = 0x0002; /* c channel messages */
+static int SILENCE_INVITE = 0x0004; /* i invites */
+static int SILENCE_NOTICE = 0x0008; /* n notices */
+static int SILENCE_CNOTICE = 0x0010; /* t channel notices */
+static int SILENCE_ALL = 0x0020; /* a all, (pcint) */
+static int SILENCE_EXCLUDE = 0x0040; /* x exclude this pattern */
+
+
+class CommandSVSSilence : public Command
+{
+ public:
+ CommandSVSSilence(Module* Creator) : Command(Creator,"SVSSILENCE", 2)
+ {
+ syntax = "<target> {[+|-]<mask> <p|c|i|n|t|a|x>}";
+ TRANSLATE4(TR_NICK, TR_TEXT, TR_TEXT, TR_END); /* we watch for a nick. not a UID. */
+ }
+
+ CmdResult Handle (const std::vector<std::string>& parameters, User *user)
+ {
+ /*
+ * XXX: thought occurs to me
+ * We may want to change the syntax of this command to
+ * SVSSILENCE <flagsora+> +<nick> -<nick> +<nick>
+ * style command so services can modify lots of entries at once.
+ * leaving it backwards compatible for now as it's late. -- w
+ */
+ if (!ServerInstance->ULine(user->server))
+ return CMD_FAILURE;
+
+ User *u = ServerInstance->FindNick(parameters[0]);
+ if (!u)
+ return CMD_FAILURE;
+
+ if (IS_LOCAL(u))
+ {
+ ServerInstance->Parser->CallHandler("SILENCE", std::vector<std::string>(++parameters.begin(), parameters.end()), u);
+ }
+
+ return CMD_SUCCESS;
+ }