[eggheads-patches] PATCH:mode_while_pending.patch

Axel Franke eule at berlin.snafu.de
Sun Oct 8 21:47:09 CST 2000


Hi,

This patch fixed the mode-recognize while channel-status:pending.
Old-status was for example if read the ban-list done and somebody 
sent a ban before the bot get a 315-end of who list, the bot ignored 
such bans (for other modes the same problem). This patch fixed this. 
And a other effect: bind-mode while pending should now work. But 
please expect not to much, in this case is the memberlist incomplete.

Greeting Eule

-------------- next part --------------
diff -ur eggdrop1.5/src/mod/irc.mod/mode.c eggneu/src/mod/irc.mod/mode.c
--- eggdrop1.5/src/mod/irc.mod/mode.c	Mon Oct  9 04:20:40 2000
+++ eggneu/src/mod/irc.mod/mode.c	Mon Oct  9 04:23:56 2000
@@ -350,7 +350,6 @@
 {
   if ((!nick[0]) && (bounce_modes))
     reversing = 1;
-  set_key(chan, key);
   if (((reversing) && !(chan->key_prot[0])) ||
       ((chan->mode_mns_prot & CHANKEY) &&
        !(glob_master(user) || glob_bot(user) || chan_master(user)))) {
@@ -373,6 +372,8 @@
 
   m = ismember(chan, who);
   if (!m) {
+    if (channel_pending(chan))
+      return;
     putlog(LOG_MISC, chan->dname, CHAN_BADCHANMODE, chan->dname, who);
     dprintf(DP_MODE, "WHO %s\n", who);
     return;
@@ -402,6 +403,9 @@
    */
   m->flags &= ~SENTOP;
 
+  if (channel_pending(chan))
+    return;
+
   /* I'm opped, and the opper isn't me */
   if (me_op(chan) && !match_my_nick(who) &&
     /* and it isn't a server op */
@@ -464,6 +468,8 @@
 
   m = ismember(chan, who);
   if (!m) {
+    if (channel_pending(chan))
+      return;
     putlog(LOG_MISC, chan->dname, CHAN_BADCHANMODE, chan->dname, who);
     dprintf(DP_MODE, "WHO %s\n", who);
     return;
@@ -483,6 +489,9 @@
   /* Check comments in got_op()  (drummer) */
   m->flags &= ~WASOP;
 
+  if (channel_pending(chan))
+    return;
+
   /* Deop'd someone on my oplist? */
   if (me_op(chan)) {
     int ok = 1;
@@ -564,6 +573,10 @@
   simple_sprintf(me, "%s!%s", botname, botuserhost);
   simple_sprintf(s, "%s!%s", nick, from);
   newban(chan, who, s);
+
+  if (channel_pending(chan))
+    return;
+
   if (wild_match(who, me) && me_op(chan)) {
     /* First of all let's check whether some luser banned us ++rtc */
     if (match_my_nick(nick))
@@ -661,6 +674,10 @@
     nfree(b->who);
     nfree(b);
   }
+
+  if (channel_pending(chan))
+    return;
+
   if (u_sticky_mask(chan->bans, who) || u_sticky_mask(global_bans, who)) {
     /* That's a sticky ban! No point in being
      * sticky unless we enforce it!!
@@ -684,6 +701,10 @@
   Context;
   simple_sprintf(s, "%s!%s", nick, from);
   newexempt(chan, who, s);
+
+  if (channel_pending(chan))
+    return;
+
   if (!match_my_nick(nick)) {	/* It's not my exemption */
     if (channel_nouserexempts(chan) && nick[0] && !glob_bot(user) &&
 	!glob_master(user) && !chan_master(user)) {
@@ -723,6 +744,10 @@
     nfree(e->who);
     nfree(e);
   }
+
+  if (channel_pending(chan))
+    return;
+
   if (u_sticky_mask(chan->exempts, who) || u_sticky_mask(global_exempts, who)) {
     /* That's a sticky exempt! No point in being sticky unless we enforce it!!
      */
@@ -757,6 +782,10 @@
 
   simple_sprintf(s, "%s!%s", nick, from);
   newinvite(chan, who, s);
+
+  if (channel_pending(chan))
+    return;
+
   if (!match_my_nick(nick)) {	/* It's not my invitation */
     if (channel_nouserinvites(chan) && nick[0] && !glob_bot(user) &&
 	!glob_master(user) && !chan_master(user)) {
@@ -793,6 +822,10 @@
     nfree(inv->who);
     nfree(inv);
   }
+
+  if (channel_pending(chan))
+    return;
+
   if (u_sticky_mask(chan->invites, who) || u_sticky_mask(global_invites, who)) {
     /* That's a sticky invite! No point in being sticky unless we enforce it!!
      */
@@ -834,7 +867,7 @@
     if (!chan) {
       putlog(LOG_MISC, "*", CHAN_FORCEJOIN, ch);
       dprintf(DP_SERVER, "PART %s\n", ch);
-    } else if (!channel_pending(chan)) {
+    } else if (channel_active(chan) || channel_pending(chan)) {
       z = strlen(msg);
       if (msg[--z] == ' ')	/* I hate cosmetic bugs :P -poptix */
 	msg[z] = 0;
@@ -846,23 +879,22 @@
       m = ismember(chan, nick);
       if (m)
 	m->last = now;
-      if (!(glob_friend(user) || chan_friend(user) ||
+      if (channel_active(chan) && m && me_op(chan)  &&
+	  !(glob_friend(user) || chan_friend(user) ||
 	    (channel_dontkickops(chan) &&
 	     (chan_op(user) || (glob_op(user) && !chan_deop(user)))))) {
-	if (m && me_op(chan)) {
-	  if (chan_fakeop(m)) {
-	    putlog(LOG_MODES, ch, CHAN_FAKEMODE, ch);
-	    dprintf(DP_MODE, "KICK %s %s :%s\n", ch, nick,
-		    CHAN_FAKEMODE_KICK);
-	    m->flags |= SENTKICK;
-	    reversing = 1;
-	  } else if (!chan_hasop(m) && !channel_nodesynch(chan)) {
-	    putlog(LOG_MODES, ch, CHAN_DESYNCMODE, ch);
-	    dprintf(DP_MODE, "KICK %s %s :%s\n", ch, nick,
-		    CHAN_DESYNCMODE_KICK);
-	    m->flags |= SENTKICK;
-	    reversing = 1;
-	  }
+	if (chan_fakeop(m)) {
+	  putlog(LOG_MODES, ch, CHAN_FAKEMODE, ch);
+	  dprintf(DP_MODE, "KICK %s %s :%s\n", ch, nick,
+		  CHAN_FAKEMODE_KICK);
+	  m->flags |= SENTKICK;
+	  reversing = 1;
+	} else if (!chan_hasop(m) && !channel_nodesynch(chan)) {
+	  putlog(LOG_MODES, ch, CHAN_DESYNCMODE, ch);
+	  dprintf(DP_MODE, "KICK %s %s :%s\n", ch, nick,
+		  CHAN_DESYNCMODE_KICK);
+	  m->flags |= SENTKICK;
+	  reversing = 1;
 	}
       }
       ms2[0] = '+';
@@ -932,13 +964,15 @@
 	    reversing = 1;
 	  if (ms2[0] == '-') {
 	    check_tcl_mode(nick, from, u, chan->dname, ms2, "");
-	    if ((reversing) && (chan->channel.maxmembers != (-1))) {
-	      simple_sprintf(s, "%d", chan->channel.maxmembers);
-	      add_mode(chan, '+', 'l', s);
-	    } else if ((chan->limit_prot != (-1)) && !glob_master(user) &&
-		       !chan_master(user)) {
-	      simple_sprintf(s, "%d", chan->limit_prot);
-	      add_mode(chan, '+', 'l', s);
+	    if (channel_active(chan)) {
+	      if ((reversing) && (chan->channel.maxmembers != (-1))) {
+		simple_sprintf(s, "%d", chan->channel.maxmembers);
+		add_mode(chan, '+', 'l', s);
+	      } else if ((chan->limit_prot != (-1)) && !glob_master(user) &&
+			 !chan_master(user)) {
+		simple_sprintf(s, "%d", chan->limit_prot);
+		add_mode(chan, '+', 'l', s);
+	      }
 	    }
 	    chan->channel.maxmembers = (-1);
 	  } else {
@@ -950,6 +984,8 @@
 	    chan->channel.maxmembers = atoi(op);
 	    check_tcl_mode(nick, from, u, chan->dname, ms2,
 			   int_to_base10(chan->channel.maxmembers));
+	    if (channel_pending(chan))
+	      break;
 	    if (((reversing) &&
 		 !(chan->mode_pls_prot & CHANLIMIT)) ||
 		((chan->mode_mns_prot & CHANLIMIT) &&
@@ -978,14 +1014,18 @@
 	    break;
 	  }
 	  check_tcl_mode(nick, from, u, chan->dname, ms2, op);
-	  if (ms2[0] == '+')
-	    got_key(chan, nick, from, op);
-	  else {
-	    if ((reversing) && (chan->channel.key[0]))
-	      add_mode(chan, '+', 'k', chan->channel.key);
-	    else if ((chan->key_prot[0]) && !glob_master(user)
-		     && !chan_master(user))
-	      add_mode(chan, '+', 'k', chan->key_prot);
+	  if (ms2[0] == '+') {
+	    set_key(chan, op);
+	    if (channel_active(chan))
+	      got_key(chan, nick, from, op);
+	  } else {
+	    if (channel_active(chan)) {
+	      if ((reversing) && (chan->channel.key[0]))
+		add_mode(chan, '+', 'k', chan->channel.key);
+	      else if ((chan->key_prot[0]) && !glob_master(user)
+		       && !chan_master(user))
+		add_mode(chan, '+', 'k', chan->key_prot);
+	    }
 	    set_key(chan, NULL);
 	  }
 	  break;
@@ -1002,16 +1042,21 @@
 	  fixcolon(op);
 	  m = ismember(chan, op);
 	  if (!m) {
+	    if (channel_pending(chan))
+	      break;
 	    putlog(LOG_MISC, chan->dname,
 		   CHAN_BADCHANMODE, chan->dname, op);
 	    dprintf(DP_MODE, "WHO %s\n", op);
 	  } else {
-	    get_user_flagrec(m->user, &victim, chan->dname);
+	    simple_sprintf(s, "%s!%s", m->nick, m->userhost);
+	    get_user_flagrec(m->user ? m->user : get_user_by_host(s),
+			     &victim, chan->dname);
 	    if (ms2[0] == '+') {
 	      m->flags &= ~SENTVOICE;
 	      m->flags |= CHANVOICE;
 	      check_tcl_mode(nick, from, u, chan->dname, ms2, op);
-	      if (!glob_master(user) && !chan_master(user)) {
+	      if (channel_active(chan) &&
+		  !glob_master(user) && !chan_master(user)) {
 		if (channel_autovoice(chan) &&
 		    (chan_quiet(victim) ||
 		     (glob_quiet(victim) && !chan_voice(victim)))) {
@@ -1023,7 +1068,8 @@
 	      m->flags &= ~SENTDEVOICE;
 	      m->flags &= ~CHANVOICE;
 	      check_tcl_mode(nick, from, u, chan->dname, ms2, op);
-	      if (!glob_master(user) && !chan_master(user)) {
+	      if (channel_active(chan) &&
+		  !glob_master(user) && !chan_master(user)) {
 		if ((channel_autovoice(chan) && !chan_quiet(victim) &&
 		    (chan_voice(victim) || glob_voice(victim))) ||
 		    (!chan_quiet(victim) && 
@@ -1069,14 +1115,16 @@
 	    chan->channel.mode |= todo;
 	  else
 	    chan->channel.mode &= ~todo;
-	  if ((((ms2[0] == '+') && (chan->mode_mns_prot & todo)) ||
-	       ((ms2[0] == '-') && (chan->mode_pls_prot & todo))) &&
-	      !glob_master(user) && !chan_master(user))
-	    add_mode(chan, ms2[0] == '+' ? '-' : '+', *chg, "");
-	  else if (reversing &&
-		   ((ms2[0] == '+') || (chan->mode_pls_prot & todo)) &&
-		   ((ms2[0] == '-') || (chan->mode_mns_prot & todo)))
-	    add_mode(chan, ms2[0] == '+' ? '-' : '+', *chg, "");
+	  if (channel_active(chan)) {
+	    if ((((ms2[0] == '+') && (chan->mode_mns_prot & todo)) ||
+		 ((ms2[0] == '-') && (chan->mode_pls_prot & todo))) &&
+		!glob_master(user) && !chan_master(user))
+	      add_mode(chan, ms2[0] == '+' ? '-' : '+', *chg, "");
+	    else if (reversing &&
+		     ((ms2[0] == '+') || (chan->mode_pls_prot & todo)) &&
+		     ((ms2[0] == '-') || (chan->mode_mns_prot & todo)))
+	      add_mode(chan, ms2[0] == '+' ? '-' : '+', *chg, "");
+	  }
 	}
 	chg++;
       }


More information about the Patches mailing list