]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/mod-snoop.c
Couple of srvx updates.
[irc/evilnet/x3.git] / src / mod-snoop.c
index f5748612c61a809d0e2d7e4f3394294c68196442..15b57201071e188205cef274750cefe81f508346 100644 (file)
@@ -3,9 +3,9 @@
  *
  * This file is part of x3.
  *
- * srvx is free software; you can redistribute it and/or modify
+ * x3 is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -55,18 +55,22 @@ const char *snoop_module_deps[] = { NULL };
 static int finalized;
 int snoop_finalize(void);
 
-#define SNOOP(FORMAT, ARGS...) send_channel_message(snoop_cfg.channel, snoop_cfg.bot, "%s "FORMAT, timestamp , ## ARGS)
+#if defined(GCC_VARMACROS)
+# define SNOOP(FORMAT, ARGS...) send_channel_message(snoop_cfg.channel, snoop_cfg.bot, "%s "FORMAT, timestamp, ARGS)
+#elif defined(C99_VARMACROS)
+# define SNOOP(FORMAT, ...) send_channel_message(snoop_cfg.channel, snoop_cfg.bot, "%s "FORMAT, timestamp, __VA_ARGS__)
+#endif
 #define UPDATE_TIMESTAMP() strftime(timestamp, sizeof(timestamp), "[%H:%M:%S]", localtime(&now))
 
 static void
-snoop_nick_change(struct userNode *user, const char *old_nick) {
+snoop_nick_change(struct userNode *user, const char *old_nick, UNUSED_ARG(void *extra)) {
     if (!snoop_cfg.enabled) return;
     UPDATE_TIMESTAMP();
     SNOOP("$bNICK$b change %s -> %s", old_nick, user->nick);
 }
 
 static int
-snoop_join(struct modeNode *mNode) {
+snoop_join(struct modeNode *mNode, UNUSED_ARG(void *extra)) {
     struct userNode *user = mNode->user;
     struct chanNode *chan = mNode->channel;
     if (!snoop_cfg.enabled) return 0;
@@ -81,7 +85,7 @@ snoop_join(struct modeNode *mNode) {
 }
 
 static void
-snoop_part(struct modeNode *mn, const char *reason) {
+snoop_part(struct modeNode *mn, const char *reason, UNUSED_ARG(void *extra)) {
     if (!snoop_cfg.enabled) return;
     if (mn->user->dead) return;
     UPDATE_TIMESTAMP();
@@ -89,14 +93,14 @@ snoop_part(struct modeNode *mn, const char *reason) {
 }
 
 static void
-snoop_kick(struct userNode *kicker, struct userNode *victim, struct chanNode *chan) {
+snoop_kick(struct userNode *kicker, struct userNode *victim, struct chanNode *chan, UNUSED_ARG(void *extra)) {
     if (!snoop_cfg.enabled) return;
     UPDATE_TIMESTAMP();
     SNOOP("$bKICK$b %s from %s by %s", victim->nick, chan->name, (kicker ? kicker->nick : "some server"));
 }
 
 static int
-snoop_new_user(struct userNode *user) {
+snoop_new_user(struct userNode *user, UNUSED_ARG(void *extra)) {
     if (!snoop_cfg.enabled) return 0;
     if (user->uplink->burst && !snoop_cfg.show_bursts) return 0;
     UPDATE_TIMESTAMP();
@@ -105,7 +109,7 @@ snoop_new_user(struct userNode *user) {
 }
 
 static void
-snoop_del_user(struct userNode *user, struct userNode *killer, const char *why) {
+snoop_del_user(struct userNode *user, struct userNode *killer, const char *why, UNUSED_ARG(void *extra)) {
     if (!snoop_cfg.enabled) return;
     UPDATE_TIMESTAMP();
     if (killer) {
@@ -116,17 +120,20 @@ snoop_del_user(struct userNode *user, struct userNode *killer, const char *why)
 }
 
 static void
-snoop_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle)) {
+snoop_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle), UNUSED_ARG(void *extra)) {
     if (!snoop_cfg.enabled) return;
     if (user->uplink->burst && !snoop_cfg.show_bursts) return;
     if (user->handle_info) {
         UPDATE_TIMESTAMP();
+        /* TODO: show old_handle info -> new handle info if they
+         * re-authed or something.
+         */
         SNOOP("$bAUTH$b %s as %s", user->nick, user->handle_info->handle);
     }
 }
 
 static void
-snoop_user_mode(struct userNode *user, const char *mode_change) {
+snoop_user_mode(struct userNode *user, const char *mode_change, UNUSED_ARG(void *extra)) {
     if (!snoop_cfg.enabled) return;
     if (user->uplink->burst && !snoop_cfg.show_bursts) return;
     if (!mode_change[1]) return; /* warning there has to be atleast one char in the buffer */
@@ -135,7 +142,7 @@ snoop_user_mode(struct userNode *user, const char *mode_change) {
 }
 
 static void
-snoop_oper(struct userNode *user) {
+snoop_oper(struct userNode *user, UNUSED_ARG(void *extra)) {
     if (!snoop_cfg.enabled) return;
     if (user->uplink->burst && !snoop_cfg.show_bursts) return;
     UPDATE_TIMESTAMP();
@@ -143,7 +150,7 @@ snoop_oper(struct userNode *user) {
 }
 
 static void
-snoop_channel_mode(struct userNode *who, struct chanNode *channel, char **modes, unsigned int argc)
+snoop_channel_mode(struct userNode *who, struct chanNode *channel, char **modes, unsigned int argc, UNUSED_ARG(void *extra))
 {
        if (!snoop_cfg.enabled) return;
        if(who) {
@@ -240,6 +247,19 @@ snoop_channel_mode(struct userNode *who, struct chanNode *channel, char **modes,
                                                        tg = tmp;
                                                break;
                                        }
+                               case 'h':
+                                       {
+                                               strcat(targets, " ");
+                                               if ((tmp = strchr(tg, ' ')))
+                                                       *tmp++ = 0;
+                                               if((un = GetUserN(tg)))
+                                                       strcat(targets, un->nick);
+                                               else
+                                                       strcat(targets, tg);
+                                               if(tmp)
+                                                       tg = tmp;
+                                               break;
+                                       }
                                case 'v':
                                        {
                                                strcat(targets, " ");
@@ -285,25 +305,25 @@ snoop_conf_read(void) {
 }
 
 void
-snoop_cleanup(void) {
+snoop_cleanup(UNUSED_ARG(void *extra)) {
     snoop_cfg.enabled = 0;
-    unreg_del_user_func(snoop_del_user);
+    unreg_del_user_func(snoop_del_user, NULL);
 }
 
 int
 snoop_init(void) {
-    reg_exit_func(snoop_cleanup);
+    reg_exit_func(snoop_cleanup, NULL);
     conf_register_reload(snoop_conf_read);
-    reg_nick_change_func(snoop_nick_change);
-    reg_join_func(snoop_join);
-    reg_part_func(snoop_part);
-    reg_kick_func(snoop_kick);
-    reg_new_user_func(snoop_new_user);
-    reg_del_user_func(snoop_del_user);
-    reg_auth_func(snoop_auth);
-    reg_channel_mode_func(snoop_channel_mode);
-    reg_user_mode_func(snoop_user_mode);
-    reg_oper_func(snoop_oper);
+    reg_nick_change_func(snoop_nick_change, NULL);
+    reg_join_func(snoop_join, NULL);
+    reg_part_func(snoop_part, NULL);
+    reg_kick_func(snoop_kick, NULL);
+    reg_new_user_func(snoop_new_user, NULL);
+    reg_del_user_func(snoop_del_user, NULL);
+    reg_auth_func(snoop_auth, NULL);
+    reg_channel_mode_func(snoop_channel_mode, NULL);
+    reg_user_mode_func(snoop_user_mode, NULL);
+    reg_oper_func(snoop_oper, NULL);
 
     return 1;
 }