Browse Source

roles: Fix stale roles not being recalculated.

This was mostly a problem with gotop and gotdeop.
Bryan Drewery 2 năm trước cách đây
mục cha
commit
5e463847f8

+ 2 - 0
src/mod/channels.mod/chanmisc.cc

@@ -1043,7 +1043,9 @@ void clear_channel(struct chanset_t *chan, bool reset)
     chan->bot_roles = NULL;
     delete chan->role_bots;
     chan->role_bots = NULL;
+    chan->role = 0;
   }
+  chan->role_rebalance_cookie = 0;
 
   if (chan->channel.cached_members) {
     if (chan->channel.cached_members->size()) {

+ 3 - 8
src/mod/irc.mod/chan.cc

@@ -2970,8 +2970,7 @@ static int gotpart(char *from, char *msg)
       chan->ircnet_status &= ~(CHAN_PEND | CHAN_JOINING);
       reset_chan_info(chan);
     }
-    /* This bot fullfilled a role, need to rebalance. */
-    if (u && u->bot && (*chan->bot_roles)[u->handle] != 0) {
+    if (u && u->bot) {
       chan->role_rebalance_cookie = 0;
     }
     set_handle_laston(chan->dname, u, now);
@@ -3063,8 +3062,7 @@ static int gotkick(char *from, char *origmsg)
       }
 
       set_handle_laston(chan->dname, mv->user, now);
-      /* This bot fullfilled a role, need to rebalance. */
-      if (mv->user->bot && (*chan->bot_roles)[mv->user->handle] != 0) {
+      if (mv->user->bot) {
         chan->role_rebalance_cookie = 0;
       }
     }
@@ -3243,10 +3241,7 @@ static int gotquit(char *from, char *msg)
       if (u) {
         if (u->bot) {
           counter_clear(u->handle);
-          /* This bot fullfilled a role, need to rebalance. */
-          if ((*chan->bot_roles)[u->handle] != 0) {
-            chan->role_rebalance_cookie = 0;
-          }
+          chan->role_rebalance_cookie = 0;
         }
         set_handle_laston(chan->dname, u, now); /* If you remove this, the bot will crash when the user record in question
 						   is removed/modified during the tcl binds below, and the users was on more

+ 1 - 0
src/mod/irc.mod/cmdsirc.cc

@@ -1445,6 +1445,7 @@ static void cmd_roles(int idx, char *par)
   }
 
   dprintf(idx, "Roles for %s:\n", chan->dname);
+  dprintf(idx, "Cookie: %lu\n", chan->role_rebalance_cookie);
 
   /* Advertise roles */
   for (roleidx = 0; role_counts[roleidx].name; roleidx++) {

+ 7 - 0
src/mod/irc.mod/mode.cc

@@ -566,6 +566,9 @@ got_op(struct chanset_t *chan, memberlist *m, memberlist *mv)
   if (mv->user && mv->user->bot && !me_opped && !meop) {
     chan->channel.do_opreq = 1;
   }
+  if (mv->user && mv->user->bot) {
+    chan->role_rebalance_cookie = 0;
+  }
 
   /* Flags need to be set correctly right from the beginning now, so that
    * add_mode() doesn't get irritated.
@@ -669,6 +672,10 @@ got_deop(struct chanset_t *chan, memberlist *m, memberlist *mv, char *isserver)
   if (channel_pending(chan))
     return;
 
+  if (mv->user && mv->user->bot) {
+    chan->role_rebalance_cookie = 0;
+  }
+
   /* Deop'd someone on my oplist? */
   if (me_op(chan)) {
     /* do we want to reop victim? */