Sfoglia il codice sorgente

* Delay for auto-op/voice (+O, +v) and +voice can now be set with 'chanset auto-delay' (default 5 seconds)


svn: 3626
Bryan Drewery 18 anni fa
parent
commit
6bd993ce89

+ 1 - 0
doc/UPDATES

@@ -70,6 +70,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Add set 'irc-autoaway' to be able to disable autoaway feature. (addresses #380)
 * Add set 'irc-autoaway' to be able to disable autoaway feature. (addresses #380)
 * Fix an automatic hostmask bug (fixes #339)
 * Fix an automatic hostmask bug (fixes #339)
 * Bots no longer die when receiving a corrupt userfile under some conditions
 * Bots no longer die when receiving a corrupt userfile under some conditions
+* Delay for auto-op/voice (+O, +v) and +voice can now be set with 'chanset auto-delay' (default 5 seconds)
 
 
 1.2.13 - http://wraith.shatow.net/milestone/1.2.13
 1.2.13 - http://wraith.shatow.net/milestone/1.2.13
 * Fix cmd_chanset accepting invalid flags
 * Fix cmd_chanset accepting invalid flags

+ 3 - 0
misc/help.txt

@@ -354,6 +354,9 @@ See also: link
         $bchanmode$b   These modes are enforced on the channel. Both + and -
         $bchanmode$b   These modes are enforced on the channel. Both + and -
                    modes can be enforced.
                    modes can be enforced.
 %{+m|m}
 %{+m|m}
+        $bauto-delay$b        Amount of seconds to wait before auto opping,
+                              or auto voicing a client based on flags or
+                              +voice
         $blimit$b             If this is set, the +l bot will raise the limit 
         $blimit$b             If this is set, the +l bot will raise the limit 
                           to the users in the channel + this ammount. Set to 
                           to the users in the channel + this ammount. Set to 
                           0 to disable.
                           0 to disable.

+ 1 - 0
src/chan.h

@@ -175,6 +175,7 @@ struct chanset_t {
   int mdop;
   int mdop;
   int mop;
   int mop;
   int voice_non_ident;
   int voice_non_ident;
+  int auto_delay;
 /* Chanint template 
 /* Chanint template 
  *int temp;
  *int temp;
  */
  */

+ 1 - 0
src/mod/channels.mod/cmdschan.c

@@ -1221,6 +1221,7 @@ static void cmd_chaninfo(int idx, char *par)
  */
  */
     dprintf(idx, "Channel settings:\n");
     dprintf(idx, "Channel settings:\n");
     deflag = chan->bad_cookie;
     deflag = chan->bad_cookie;
+    SHOW_INT("Auto-delay: ", chan->auto_delay, NULL, "None");
     SHOW_INT("Bad-cookie:" , chan->bad_cookie, P_STR, "Ignore");
     SHOW_INT("Bad-cookie:" , chan->bad_cookie, P_STR, "Ignore");
     SHOW_INT("Ban-time: ", chan->ban_time, NULL, "Forever");
     SHOW_INT("Ban-time: ", chan->ban_time, NULL, "Forever");
     SHOW_INT("Closed-ban: ", chan->closed_ban, NULL, "Don't!");
     SHOW_INT("Closed-ban: ", chan->closed_ban, NULL, "Don't!");

+ 9 - 0
src/mod/channels.mod/tclchan.c

@@ -476,6 +476,14 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item,
         return ERROR;
         return ERROR;
       }
       }
       chan->flood_lock_time = atoi(item[i]);
       chan->flood_lock_time = atoi(item[i]);
+    } else if (!strcmp(item[i], "auto-delay")) {
+      i++;
+      if (i >= items) {
+        if (result)
+          simple_snprintf(result, RESULT_LEN, "channel auto-delay needs argument");
+        return ERROR;
+      }
+      chan->auto_delay = atoi(item[i]);
      
      
 
 
 /* Chanint template
 /* Chanint template
@@ -873,6 +881,7 @@ int channel_add(char *result, char *newname, char *options)
     chan->closed_private = 1;
     chan->closed_private = 1;
     chan->closed_invite = 1;
     chan->closed_invite = 1;
     chan->voice_non_ident = 1;
     chan->voice_non_ident = 1;
+    chan->auto_delay = 5;
 /* Chanint template
 /* Chanint template
  *  chan->temp = 0;
  *  chan->temp = 0;
  */
  */

+ 4 - 2
src/mod/channels.mod/userchan.c

@@ -731,7 +731,7 @@ bad-cookie %d manop %d mdop %d mop %d limit %d \
 flood-chan %d:%lu flood-ctcp %d:%lu flood-join %d:%lu \
 flood-chan %d:%lu flood-ctcp %d:%lu flood-join %d:%lu \
 flood-kick %d:%lu flood-deop %d:%lu flood-nick %d:%lu flood-mjoin %d:%lu \
 flood-kick %d:%lu flood-deop %d:%lu flood-nick %d:%lu flood-mjoin %d:%lu \
 closed-ban %d closed-invite %d closed-private %d ban-time %lu \
 closed-ban %d closed-invite %d closed-private %d ban-time %lu \
-exempt-time %lu invite-time %lu voice-non-ident %d \
+exempt-time %lu invite-time %lu voice-non-ident %d auto-delay %d \
 flood-exempt %d flood-lock-time %lu \
 flood-exempt %d flood-lock-time %lu \
 %cenforcebans %cdynamicbans %cuserbans %cbitch \
 %cenforcebans %cdynamicbans %cuserbans %cbitch \
 %cprivate %ccycle %cinactive %cdynamicexempts %cuserexempts \
 %cprivate %ccycle %cinactive %cdynamicexempts %cuserexempts \
@@ -768,6 +768,7 @@ flood-exempt %d flood-lock-time %lu \
         chan->exempt_time,
         chan->exempt_time,
         chan->invite_time,
         chan->invite_time,
         chan->voice_non_ident,
         chan->voice_non_ident,
+        chan->auto_delay,
         chan->flood_exempt_mode,
         chan->flood_exempt_mode,
         chan->flood_lock_time,
         chan->flood_lock_time,
  	PLSMNS(channel_enforcebans(chan)),
  	PLSMNS(channel_enforcebans(chan)),
@@ -832,7 +833,7 @@ bad-cookie %d manop %d mdop %d mop %d limit %d \
 flood-chan %d:%lu flood-ctcp %d:%lu flood-join %d:%lu \
 flood-chan %d:%lu flood-ctcp %d:%lu flood-join %d:%lu \
 flood-kick %d:%lu flood-deop %d:%lu flood-nick %d:%lu \
 flood-kick %d:%lu flood-deop %d:%lu flood-nick %d:%lu \
 closed-ban %d closed-invite %d closed-private %d ban-time %lu \
 closed-ban %d closed-invite %d closed-private %d ban-time %lu \
-exempt-time %lu invite-time %lu voice-non-ident %d \
+exempt-time %lu invite-time %lu voice-non-ident %d auto-delay %d \
 %cenforcebans %cdynamicbans %cuserbans %cbitch \
 %cenforcebans %cdynamicbans %cuserbans %cbitch \
 %cprivate %ccycle %cinactive %cdynamicexempts %cuserexempts \
 %cprivate %ccycle %cinactive %cdynamicexempts %cuserexempts \
 %cdynamicinvites %cuserinvites %cnodesynch %cclosed %cvoice \
 %cdynamicinvites %cuserinvites %cnodesynch %cclosed %cvoice \
@@ -867,6 +868,7 @@ exempt-time %lu invite-time %lu voice-non-ident %d \
         chan->exempt_time,
         chan->exempt_time,
         chan->invite_time,
         chan->invite_time,
         chan->voice_non_ident,
         chan->voice_non_ident,
+        chan->auto_delay,
  	PLSMNS(channel_enforcebans(chan)),
  	PLSMNS(channel_enforcebans(chan)),
 	PLSMNS(channel_dynamicbans(chan)),
 	PLSMNS(channel_dynamicbans(chan)),
 	PLSMNS(!channel_nouserbans(chan)),
 	PLSMNS(!channel_nouserbans(chan)),

+ 27 - 3
src/mod/irc.mod/chan.c

@@ -2516,9 +2516,33 @@ static int gotjoin(char *from, char *chname)
           }
           }
         }
         }
 #endif /* CACHE */
 #endif /* CACHE */
-        if (!splitjoin && !chan_hasop(m) && (op || (dovoice(chan) && 
-            !u_pass_match(m->user, "-") && chk_autoop(fr, chan)))) {
-          do_op(m->nick, chan, 1, 0);
+        if (!splitjoin) {
+          bool common_checks = dovoice(chan) && !glob_bot(fr);
+
+          /* Autoop */
+          if (!chan_hasop(m) && 
+               (op || 
+               (common_checks && !u_pass_match(m->user, "-") && chk_autoop(fr, chan)))) {
+            do_op(m->nick, chan, 1, 0);
+          }
+
+          /* +v or +voice */
+          if (!chan_hasvoice(m) && common_checks) {
+            if (m->user) {
+              if (!(m->flags & EVOICE) &&
+                  (
+                   (channel_voice(chan) && !chk_devoice(fr)) ||
+                   (!channel_voice(chan) && !privchan(fr, chan, PRIV_VOICE) && chk_voice(fr, chan))
+                  )
+                 ) {
+                m->delay = now + chan->auto_delay;
+                m->flags |= SENTVOICE;
+              }
+            } else if (!m->user && channel_voice(chan) && voice_ok(m, chan)) {
+              m->delay = now + chan->auto_delay;
+              m->flags |= SENTVOICE;
+            }
+          }
         }
         }
       }
       }
     }
     }

+ 7 - 7
src/mod/irc.mod/irc.c

@@ -66,11 +66,6 @@ static bool prevent_mixing = 1;  /* To prevent mixing old/new modes */
 static bool include_lk = 1;      /* For correct calculation
 static bool include_lk = 1;      /* For correct calculation
                                  * in real_add_mode. */
                                  * in real_add_mode. */
 
 
-#include "chan.c"
-#include "mode.c"
-#include "cmdsirc.c"
-#include "msgcmds.c"
-
 static int
 static int
 voice_ok(memberlist *m, struct chanset_t *chan)
 voice_ok(memberlist *m, struct chanset_t *chan)
 {
 {
@@ -83,6 +78,11 @@ voice_ok(memberlist *m, struct chanset_t *chan)
   return 1;
   return 1;
 }
 }
 
 
+#include "chan.c"
+#include "mode.c"
+#include "cmdsirc.c"
+#include "msgcmds.c"
+
 static void
 static void
 detect_offense(memberlist* m, struct chanset_t *chan, char *msg)
 detect_offense(memberlist* m, struct chanset_t *chan, char *msg)
 {
 {
@@ -1456,7 +1456,7 @@ check_expired_chanstuff(struct chanset_t *chan)
             if (m->user) {
             if (m->user) {
               get_user_flagrec(m->user, &fr, chan->dname, chan);
               get_user_flagrec(m->user, &fr, chan->dname, chan);
               if (!glob_bot(fr)) {
               if (!glob_bot(fr)) {
-                if (!(m->flags & EVOICE) && 
+                if (!chan_sentvoice(m) && !(m->flags & EVOICE) && 
                     (
                     (
                      (channel_voice(chan) && !chk_devoice(fr)) ||
                      (channel_voice(chan) && !chk_devoice(fr)) ||
                      (!channel_voice(chan) && !privchan(fr, chan, PRIV_VOICE) && chk_voice(fr, chan))
                      (!channel_voice(chan) && !privchan(fr, chan, PRIV_VOICE) && chk_voice(fr, chan))
@@ -1467,7 +1467,7 @@ check_expired_chanstuff(struct chanset_t *chan)
                   add_mode(chan, '-', 'v', m->nick);
                   add_mode(chan, '-', 'v', m->nick);
                 }
                 }
               }
               }
-            } else if (!m->user && channel_voice(chan) && voice_ok(m, chan)) {
+            } else if (!chan_sentvoice(m) && !m->user && channel_voice(chan) && voice_ok(m, chan)) {
               add_mode(chan, '+', 'v', m->nick);
               add_mode(chan, '+', 'v', m->nick);
             }
             }
           }
           }

+ 2 - 30
src/mod/irc.mod/mode.c

@@ -70,21 +70,6 @@ static size_t egg_strcatn(char *dst, const char *src, size_t max)
   return tmpmax - max;
   return tmpmax - max;
 }
 }
 
 
-typedef struct autoop_b {
-  struct chanset_t *chan;
-  char *nick;
-} autoop_t;
-
-static void
-do_autoop(void *client_data)
-{
-  autoop_t *autoop = (autoop_t *) client_data;
-
-  do_op(autoop->nick, autoop->chan, 0, 1);
-  free(autoop->nick);
-  free(autoop);
-}
-
 static bool
 static bool
 do_op(char *nick, struct chanset_t *chan, time_t delay, bool force)
 do_op(char *nick, struct chanset_t *chan, time_t delay, bool force)
 {
 {
@@ -94,21 +79,8 @@ do_op(char *nick, struct chanset_t *chan, time_t delay, bool force)
     return 0;
     return 0;
 
 
   if (delay) {
   if (delay) {
-    egg_timeval_t howlong;
-    autoop_t *auto_op = (autoop_t *) my_calloc(1, sizeof(autoop_t));
-    char buf[51] = "";
-
-    howlong.sec = 6;
-    howlong.usec = 0;
-
-    auto_op->chan = chan;
-    auto_op->nick = strdup(nick);
-
-    simple_snprintf(buf, sizeof(buf), "AOp %s/%s", nick, chan->dname);
-
-    timer_create_complex(&howlong, buf, (Function) do_autoop, (void *) auto_op, 0);
-
-    return 1;
+    m->delay = now + chan->auto_delay;
+    m->flags |= SENTOP;
   }
   }
 
 
   if (channel_fastop(chan) || channel_take(chan)) {
   if (channel_fastop(chan) || channel_take(chan)) {