changed spamserv,chanserv and watchdog messages to privmsgs
authorNurPech <nurpech@nurpech.de>
Mon, 20 May 2013 17:28:47 +0000 (19:28 +0200)
committerNurPech <nurpech@nurpech.de>
Mon, 20 May 2013 17:56:23 +0000 (19:56 +0200)
src/chanserv.c
src/mod-watchdog.c
src/spamserv.c
srvx.conf.example

index 3ddfaf6874822d50451a596628451b53c73dcef1..44f6d9d5f1488f88c0b24d06260e0fce960e1eb9 100644 (file)
@@ -156,6 +156,7 @@ static const struct message_entry msgtab[] = {
     { "CSMSG_MUST_BE_OPPED", "You must be a channel operator in $b%s$b to register it." },
     { "CSMSG_PROXY_FORBIDDEN", "You may not register a channel for someone else." },
     { "CSMSG_OWN_TOO_MANY", "%s already owns enough channels (at least %d); use FORCE to override." },
+    { "CMSG_ALERT_REGISTERED" "%s registered to %s by %s." },
 
 /* Do-not-register channels */
     { "CSMSG_NOT_DNR", "$b%s$b is not a valid channel name or *account." },
@@ -178,6 +179,7 @@ static const struct message_entry msgtab[] = {
     { "CSMSG_UNREG_NODELETE", "$b%s$b is protected from unregistration." },
     { "CSMSG_CHAN_SUSPENDED", "$b$C$b access to $b%s$b has been temporarily suspended (%s)." },
     { "CSMSG_CONFIRM_UNREG", "To confirm this unregistration, you must use 'unregister %s'." },
+    { "CMSG_ALERT_UNREGISTERED" "%s %s" },
 
 /* Channel moving */
     { "CSMSG_MOVE_SUCCESS", "Channel registration has been moved to $b%s$b." },
@@ -548,6 +550,9 @@ static const struct message_entry msgtab[] = {
 DECLARE_LIST(dnrList, struct do_not_register *);
 DEFINE_LIST(dnrList, struct do_not_register *)
 
+#define chanserv_notice(target, format...) send_message(target , chanserv , ## format)
+#define chanserv_oper_message(format...) do { if(chanserv_conf.oper_channel) send_channel_message(chanserv_conf.oper_channel , chanserv , ## format); } while(0)
+
 static int eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, char *argv[], struct svccmd *cmd, int action);
 
 struct userNode *chanserv;
@@ -601,6 +606,8 @@ static struct
     const char          *new_channel_authed;
     const char          *new_channel_unauthed;
     const char          *new_channel_msg;
+
+    struct chanNode    *oper_channel;
 } chanserv_conf;
 
 struct listData
@@ -1517,10 +1524,9 @@ unregister_channel(struct chanData *channel, const char *reason)
     channel->channel->channel_info = NULL;
 
     dict_delete(channel->notes);
-    sprintf(msgbuf, "%s %s", channel->channel->name, reason);
     if(!IsSuspended(channel))
         DelChannelUser(chanserv, channel->channel, msgbuf, 0);
-    global_message(MESSAGE_RECIPIENT_OPERS | MESSAGE_RECIPIENT_HELPERS, msgbuf);
+    chanserv_oper_message(CSMSGL_CHANNEL_UNREGISTERED, channel->channel->name, reason);
     UnlockChannel(channel->channel);
     free(channel);
     registered_channels--;
@@ -2271,8 +2277,7 @@ static CHANSERV_FUNC(cmd_register)
     else
         reply("CSMSG_REG_SUCCESS", channel->name);
 
-    sprintf(reason, "%s registered to %s by %s.", channel->name, handle->handle, user->handle_info->handle);
-    global_message(MESSAGE_RECIPIENT_OPERS | MESSAGE_RECIPIENT_HELPERS, reason);
+    chanserv_oper_message(CSMSG_ALERT_REGISTERED, channel->name, handle->handle, user->handle_info->handle);
     return 1;
 }
 
@@ -7980,6 +7985,16 @@ chanserv_conf_read(void)
     chanserv_conf.old_ban_names = strlist;
     str = database_get_data(conf_node, "off_channel", RECDB_QSTRING);
     off_channel = str ? atoi(str) : 0;
+
+    str = database_get_data(conf_node, "oper_chan", RECDB_QSTRING);
+       if(str)
+       {
+               chanserv_conf.oper_channel = AddChannel(str, now, "+tinms", NULL);
+       }
+       else
+       {
+               chanserv_conf.oper_channel = NULL;
+       }
 }
 
 static void
index 26bee0434ea06bcbeb4c491d8dbdca3e0e93e73e..0866b0076d37be6081c3bc0feafee95c78be78a0 100644 (file)
@@ -49,6 +49,7 @@
 
 static const struct message_entry msgtab[] = {
     { "WDMSG_REGISTER_SUCCESS", "$b%s$b is now registered with %s." },
+    { "WDMSG_UNREG_SUCCESS", "$b%s$b is now unregistered." },
     { "WDMSG_NOT_REGISTERED", "$b%s$b is not registered with %s." },
     { "WDMSG_ALREADY_ADDED", "$b%s$b is already added. (ID: %s)" },
     { "WDMSG_BADWORD_ADDED", "added '$b%s$b' to the badword list with ID %s." },
@@ -92,6 +93,7 @@ static struct {
     unsigned long ban_duration;
     unsigned long gline_duration;
     struct chanNode *alert_channel;
+    struct chanNode *oper_channel;
 } watchdog_conf;
 
 const char *watchdog_module_deps[] = { NULL };
@@ -107,6 +109,7 @@ static struct watchdog_channel *add_channel(const char *name);
 static struct badword *add_badword(const char *badword_mask, unsigned int triggered, unsigned int action, unsigned int alert, const char *id);
 #define watchdog_notice(target, format...) send_message(target , watchdog , ## format)
 #define watchdog_debug(format...) do { if(watchdog_conf.alert_channel) send_channel_message(watchdog_conf.alert_channel , watchdog , ## format); } while(0)
+#define watchdog_oper_message(format...) do { if(watchdog_conf.oper_channel) send_channel_message(watchdog_conf.oper_channel , watchdog , ## format); } while(0)
 
 static MODCMD_FUNC(cmd_addbad)
 {
@@ -353,6 +356,7 @@ static MODCMD_FUNC(cmd_register)
 
     add_channel(channel->name);
     reply("WDMSG_REGISTER_SUCCESS", channel->name, watchdog->nick);
+    watchdog_oper_message("WDMSG_REGISTER_SUCCESS", channel->name, watchdog->nick);
     return 1;
 }
 
@@ -374,6 +378,7 @@ static MODCMD_FUNC(cmd_unregister)
         DelChannelUser(watchdog, channel, reason, 0);
         dict_remove(chanlist, channel->name);
         reply("CSMSG_UNREG_SUCCESS", channel->name);
+        watchdog_oper_message("CSMSG_UNREG_SUCCESS", channel->name);
         return 1;
     } else {
         reply("WDMSG_NOT_REGISTERED", channel->name, watchdog->nick);
@@ -546,6 +551,15 @@ watchdog_conf_read(void)
                watchdog_conf.alert_channel = NULL;
        }
     
+       str = database_get_data(conf_node, "oper_chan", RECDB_QSTRING);
+       if(str)
+       {
+               watchdog_conf.oper_channel = AddChannel(str, now, "+tinms", NULL);
+       }
+       else
+       {
+               watchdog_conf.oper_channel = NULL;
+       }
 }
 
 static int
index aaf17b7178896829ee26038b11faab8f4d33edc8..f0ccca5d825f6f0226d072861493111f4fe71a60 100644 (file)
@@ -36,6 +36,7 @@
 #define KEY_EXPIRY                   "expiry"
 
 #define KEY_DEBUG_CHANNEL            "debug_channel"
+#define KEY_OPER_CHANNEL            "oper_channel"
 #define KEY_GLOBAL_EXCEPTIONS        "global_exceptions"
 #define KEY_NETWORK_RULES            "network_rules"
 #define KEY_TRIGGER                  "trigger"
@@ -70,6 +71,7 @@ dict_t killed_users_dict;
 
 #define spamserv_notice(target, format...) send_message(target , spamserv , ## format)
 #define spamserv_debug(format...) do { if(spamserv_conf.debug_channel) send_channel_message(spamserv_conf.debug_channel , spamserv , ## format); } while(0)
+#define spamserv_oper_message(format...) do { if(spamserv_conf.oper_channel) send_channel_message(spamserv_conf.oper_channel , spamserv , ## format); } while(0)
 #define ss_reply(format...)    send_message(user , spamserv , ## format)
 
 #define SET_SUBCMDS_SIZE 10
@@ -121,6 +123,8 @@ static const struct message_entry msgtab[] = {
     { "SSMSG_STATUS_MEMORY",           "$bMemory Information:$b" },
     { "SSMSG_STATUS_CHANNEL_LIST",     "$bRegistered Channels:$b" },
     { "SSMSG_STATUS_NO_CHANNEL",       "No channels registered." },
+    { "SSMSG_CHANNEL_REGISTERED",         "%s (channel %s) registered by %s." },
+    { "SSMSG_CHANNEL_UNREGISTERED",       "%s (channel %s) unregistered by %s." },
        { NULL, NULL }
 };
 
@@ -141,6 +145,7 @@ static const struct message_entry msgtab[] = {
 static struct
 {
        struct chanNode *debug_channel;
+       struct chanNode *oper_channel;
        struct string_list *global_exceptions;
        const char *network_rules;
        unsigned char trigger;
@@ -1088,8 +1093,7 @@ SPAMSERV_FUNC(cmd_register)
 
        spamserv_join_channel(cInfo->channel);
        
-       snprintf(reason, sizeof(reason), "%s (channel %s) registered by %s.", spamserv->nick, channel->name, user->handle_info->handle);
-       global_message(MESSAGE_RECIPIENT_OPERS | MESSAGE_RECIPIENT_HELPERS, reason);
+       spamserv_oper_message("SSMSG_CHANNEL_REGISTERED", spamserv->nick, channel->name, user->handle_info->handle);
        ss_reply("SSMSG_REG_SUCCESS", channel->name);
 
        return 1;
@@ -1138,8 +1142,7 @@ SPAMSERV_FUNC(cmd_unregister)
        
        spamserv_unregister_channel(cInfo);     
 
-       snprintf(reason, sizeof(reason), "%s (channel %s) unregistered by %s.", spamserv->nick, channel->name, user->handle_info->handle);
-       global_message(MESSAGE_RECIPIENT_OPERS | MESSAGE_RECIPIENT_HELPERS, reason);
+       spamserv_oper_message("SSMSG_CHANNEL_UNREGISTERED", spamserv->nick, channel->name, user->handle_info->handle);
        ss_reply("SSMSG_UNREG_SUCCESS", channel->name);
 
        return 1;
@@ -1930,7 +1933,6 @@ spamserv_conf_read(void)
        }
 
        str = database_get_data(conf_node, KEY_DEBUG_CHANNEL, RECDB_QSTRING);
-
        if(str)
        {
                spamserv_conf.debug_channel = AddChannel(str, now, "+tinms", NULL);
@@ -1943,6 +1945,16 @@ spamserv_conf_read(void)
                spamserv_conf.debug_channel = NULL;
        }
 
+       str = database_get_data(conf_node, KEY_OPER_CHANNEL, RECDB_QSTRING);
+       if(str)
+       {
+               spamserv_conf.oper_channel = AddChannel(str, now, "+tinms", NULL);
+       }
+       else
+       {
+               spamserv_conf.oper_channel = NULL;
+       }
+
        spamserv_conf.global_exceptions = database_get_data(conf_node, KEY_GLOBAL_EXCEPTIONS, RECDB_STRING_LIST);
 
        str = database_get_data(conf_node, KEY_NETWORK_RULES, RECDB_QSTRING);
index b3901c88736c238fdf77bd96d26b27c5c5302180..855e80acd787298f3a67d361900d9dc71e6a9bd2 100644 (file)
         "new_channel_unauthed_join" ""; //only sent if the user is unauthed
         "new_channel_authed_join" ""; //only sent if the user is authed
         "new_channel_message" ""; //always after the message above
+        "oper_channel" "#opers";
         
     };
 
         // unless you specified ".disabled".)
         "nick" "SpamServ";
         "debug_channel" "#spamserv";
+        "oper_channel" "#opers";
         // url of the network rules. if you don't have network rules, remove this key.
         "network_rules" "http://www.gamesurge.net/aup";
         // trigger for spamserv; remove this key to disable the trigger
         "gline_duration" "1h";
         "punishment_reason" "Your message contained a forbidden word.";
         "alert_chan" "#opers";
+        "oper_channel" "#opers";
     };
        
        "hostserv" {