[eggheads-patches] More halfop stuff

Sven Trenkel Sven.Trenkel at tu-clausthal.de
Sun Mar 2 09:31:04 CST 2003


There are more problems with halfops and my privious patch didn't even
fix the washalfop issue, sorry about that.

1. The gotjoin function in the irc module only sets the WASOP flag, but
not the WASHALFOP flag.

2. The bot won't do any mode changes if it's a halfop, because the
add_mode function just returns if the bot isn't chanop.

3. Every IRCd handles halfops slightly differently. On some halfops can
halfop other people, on some they can't and on some they can except the
channel is +p (but not +s). My workaround is to try it once. Thanks to
the SENTHALFOP flag the bot won't try it again if it didn't work. If the
bot gets full chanop privileges later on the SENTHALFOP und SENTKICK
flags are cleared so the modes can be sent again.

CU
   Sven
-- 
Today's experiment ..... failed!
-------------- next part --------------
diff -bur eggdrop1.6.original/src/mod/irc.mod/chan.c eggdrop1.6.modified/src/mod/irc.mod/chan.c
--- eggdrop1.6.original/src/mod/irc.mod/chan.c        Thu Feb 27 06:00:05 2003
+++ eggdrop1.6.modified/src/mod/irc.mod/chan.c        Sun Mar  2 04:29:11 2003
@@ -711,10 +711,6 @@
           !(glob_op(*fr) && !chan_deop(*fr)))))) {
         add_mode(chan, '-', 'o', m->nick);
       }
-      if (chan_hashalfop(m) && ((chan_dehalfop(*fr) || (glob_dehalfop(*fr) &&
-          !chan_halfop(*fr)) || (channel_bitch(chan) && (!chan_halfop(*fr) &&
-          !(glob_halfop(*fr) && !chan_dehalfop(*fr)))))))
-        add_mode(chan, '-', 'h', m->nick);
       if (!chan_hasop(m) && (chan_op(*fr) || (glob_op(*fr) &&
           !chan_deop(*fr))) && (channel_autoop(chan) || glob_autoop(*fr) ||
           chan_autoop(*fr))) {
@@ -724,7 +720,13 @@
           set_delay(chan, m->nick);
           m->flags |= SENTOP;
         }
-      } else if (!chan_hasop(m) && !chan_hashalfop(m) && (chan_halfop(*fr) ||
+      }
+    }
+    if (chan_hashalfop(m) && ((chan_dehalfop(*fr) || (glob_dehalfop(*fr) &&
+        !chan_halfop(*fr)) || (channel_bitch(chan) && (!chan_halfop(*fr) &&
+        !(glob_halfop(*fr) && !chan_dehalfop(*fr)))))))
+      add_mode(chan, '-', 'h', m->nick);
+    if (!chan_sentop(m) && !chan_hasop(m) && !chan_hashalfop(m) && (chan_halfop(*fr) ||
                (glob_halfop(*fr) && !chan_dehalfop(*fr))) &&
                (channel_autohalfop(chan) || glob_autohalfop(*fr) ||
                chan_autohalfop(*fr))) {
@@ -735,7 +737,6 @@
           m->flags |= SENTHALFOP;
         }
       }
-    }
     if (chan_hasvoice(m) && (chan_quiet(*fr) || (glob_quiet(*fr) &&
         !chan_voice(*fr))))
       add_mode(chan, '-', 'v', m->nick);
@@ -817,6 +818,9 @@
     get_user_flagrec(m->user, &fr, chan->dname);
     if (glob_bot(fr) && chan_hasop(m) && !match_my_nick(m->nick))
       stop_reset = 1;
+    /* Perhaps we were halfop and tried to halfop/kick the user
+       earlier but the server rejected the request, so let's try again. */
+    m->flags &= ~(SENTHALFOP | SENTKICK);
     check_this_member(chan, m->nick, &fr);
   }
   if (dobans) {
@@ -1646,7 +1650,7 @@
         m->split = 0;
         m->last = now;
         m->delay = 0L;
-        m->flags = (chan_hasop(m) ? WASOP : 0);
+        m->flags = (chan_hasop(m) ? WASOP : 0) | (chan_hashalfop(m) ? WASHALFOP : 0);
         m->user = u;
         set_handle_laston(chan->dname, u, now);
         m->flags |= STOPWHO;
diff -bur eggdrop1.6.original/src/mod/irc.mod/mode.c eggdrop1.6.modified/src/mod/irc.mod/mode.c
--- eggdrop1.6.original/src/mod/irc.mod/mode.c        Wed Feb  5 06:00:09 2003
+++ eggdrop1.6.modified/src/mod/irc.mod/mode.c        Sun Mar  2 15:27:04 2003
@@ -182,8 +182,16 @@
   memberlist *mx;
   char s[21];
 
-  if (!me_op(chan))
+  if (!me_op(chan) && !me_halfop(chan))
     return;                     /* No point in queueing the mode */
+
+  /* Now this is ugly! On some IRCds halfops can halfop other users.
+     On some they can't. And on some they can if the channel isn't +p
+     And everyone has a different way of telling us it didn't work.
+     So let's not assume what should work and what shouldn't */
+
+  if (!me_op(chan) && ((mode == 'o') || (mode == 'p')))
+    return;
 
   if (mode == 'o' || mode == 'h' || mode == 'v') {
     mx = ismember(chan, op);


More information about the Patches mailing list