Просмотр исходного кода

* Added channel flag +|-botbitch, when set only bots will be allowed to be opped, users be auto-deopped.
* chanset -bitch/-private/-botbitch/+botbitch/+closed/+private will now trigger bots to recheck channel (op/deop/kick people)


svn: 1912

Bryan Drewery 21 лет назад
Родитель
Сommit
f060e61929

+ 2 - 0
doc/UPDATES

@@ -41,6 +41,8 @@ Lines prefixxed with '-' were disabled before release and are not finishsed, or
 * Fixed binary exiting with ERR_NOBOTS under conditions that it shouldn't. (updating)
 * Fixed bots not rechecking channel for invalid users after a .-chrec
 * Users who are v|o in a +private chan are now voiced, as before |v was needed.
+* Added channel flag +|-botbitch, when set only bots will be allowed to be opped, users be auto-deopped.
+* chanset -bitch/-private/-botbitch/+botbitch/+closed/+private will now trigger bots to recheck channel (op/deop/kick people)
 
 1.2.2
 * Don't sanity check flags for users on DCC CHAT if they are on the bot via .botcmd.

+ 9 - 7
misc/help.txt

@@ -319,7 +319,7 @@ See also: botjoin, +chan, -chan, chanset, chaninfo
       Bots: cEvin, ruthie, Killa1
    There is no indication of which bots are directly connected to this current
    bot. %{+n}Use $b'%dwho'$b or $b'%dbottree'$b for that information.%{-}
-
+ 
    Specifying a nodename will display all bots up/down on that nodename.
    Bots with a * preceeding it's name is down.
  
@@ -431,6 +431,8 @@ See also: link
                        op access to the channel.
         $bbitch$b          Only let users with the +o flag have op on the
                        channel?
+        $bbotbitch$b       Only let $bbots$b with the +o flag have op on the
+                       channel?
         $bclosed$b         Kick all people who join channel unless they have
                        op access for the channel.
         $bcycle$b          Bot will attempt to cycle the channel when opless
@@ -902,7 +904,7 @@ See also: cycle
  
    Example:
       Down bots: cEvin, ruthie, Killa1
-
+ 
 See also: bots
 :leaf:dump
 ###  $bdump$b <text>
@@ -1054,11 +1056,6 @@ See also: +ignore, -ignore
    the bot with /MSG INVITE. Specify * for all channels.
  
 See also: console, iop
-:leaf:iop
-###  $biop$b <nickname> [channel|*]
-   same as normal invite, except auto-ops them when they join.
- 
-See also: console, invite
 ::invites
 ###  $binvites$b [[channel/all]/wildcard]
    Shows you a list of the global invites active on the current channel, and
@@ -1098,6 +1095,11 @@ See also: console, invite
    of your current console channel.
  
 See also: -invite, +invite, console%{+m|m}, chanset, chaninfo%{-}, stick, unstick
+:leaf:iop
+###  $biop$b <nickname> [channel|*]
+   same as normal invite, except auto-ops them when they join.
+ 
+See also: console, invite
 :leaf:jump
 ###  $bjump$b [server [port [pass]]]
    Makes the bot jump to another server. If you don't specify a

+ 3 - 1
src/chan.h

@@ -212,7 +212,7 @@ struct chanset_t {
 #define CHAN_BITCH          BIT4	/* be a tightwad with ops             */
 #define CHAN_TAKE 	    BIT5	/* When a bot gets opped, take the chan */
 #define CHAN_PROTECTOPS     BIT6	/* re-op any +o people who get deop'd */
-#undef  CHAN_7              /* BIT7         unused */
+#define CHAN_BOTBITCH       BIT7        /* only let bots be opped? */
 #define CHAN_REVENGE        BIT8	/* get revenge on bad people          */
 #define CHAN_SECRET         BIT9	/* don't advertise channel on botnet  */
 #undef  CHAN_10		    /* BIT10        not used */
@@ -251,6 +251,8 @@ struct chanset_t *findchan_by_dname(const char *name);
 #define channel_active(chan)  (chan->status & CHAN_ACTIVE)
 #define channel_pending(chan)  (chan->status & CHAN_PEND)
 #define channel_bitch(chan) (chan->status & CHAN_BITCH)
+#define chan_bitch(chan) (chan->status & (CHAN_BITCH|CHAN_BOTBITCH))
+#define channel_botbitch(chan) (chan->status & CHAN_BOTBITCH)
 #define channel_nodesynch(chan) (chan->status & CHAN_NODESYNCH)
 #define channel_enforcebans(chan) (chan->status & CHAN_ENFORCEBANS)
 #define channel_revenge(chan) (chan->status & CHAN_REVENGE)

+ 20 - 3
src/flags.c

@@ -419,7 +419,16 @@ privchan(struct flag_record fr, struct chanset_t *chan, int type)
 int
 chk_op(struct flag_record fr, struct chanset_t *chan)
 {
-  if (!chan || (!privchan(fr, chan, PRIV_OP) && !chk_deop(fr))) {
+  return real_chk_op(fr, chan, 1);
+}
+
+int
+real_chk_op(struct flag_record fr, struct chanset_t *chan, bool botbitch)
+{
+  if (!chan)
+    return 0;
+
+  if (!privchan(fr, chan, PRIV_OP) && !real_chk_deop(fr, chan, botbitch)) {
     if (chan_op(fr) || (glob_op(fr) && !chan_deop(fr)))
       return 1;
   }
@@ -431,16 +440,24 @@ chk_autoop(struct flag_record fr, struct chanset_t *chan)
 {
   if (glob_bot(fr))
     return 0;
-  if (!chan || (!channel_take(chan) && !privchan(fr, chan, PRIV_OP) && chk_op(fr, chan) && !chk_deop(fr))) {
+  if (!chan || (!channel_take(chan) && !privchan(fr, chan, PRIV_OP) && chk_op(fr, chan) && !chk_deop(fr, chan))) {
     if (channel_autoop(chan) || chan_autoop(fr) || glob_autoop(fr))
       return 1;
   }
   return 0;
 }
 
+int chk_deop(struct flag_record fr, struct chanset_t *chan)
+{
+  return real_chk_deop(fr, chan, 1);
+}
+
 int
-chk_deop(struct flag_record fr)
+real_chk_deop(struct flag_record fr, struct chanset_t *chan, bool botbitch)
 {
+  if (chan && botbitch && channel_botbitch(chan) && !glob_bot(fr))
+    return 1;
+
   if (chan_deop(fr) || (glob_deop(fr) && !chan_op(fr)))
     return 1;
   else

+ 3 - 1
src/flags.h

@@ -135,8 +135,10 @@ flag_t chan_sanity_check(flag_t);
 char geticon(int);
 int privchan(struct flag_record, struct chanset_t *, int);
 int chk_op(struct flag_record, struct chanset_t *);
+int real_chk_op(struct flag_record, struct chanset_t *, bool);
 int chk_autoop(struct flag_record, struct chanset_t *);
-int chk_deop(struct flag_record);
+int chk_deop(struct flag_record, struct chanset_t *);
+int real_chk_deop(struct flag_record, struct chanset_t *, bool);
 int chk_voice(struct flag_record, struct chanset_t *);
 int chk_devoice(struct flag_record);
 int chk_noflood(struct flag_record);

+ 4 - 3
src/misc.c

@@ -442,7 +442,7 @@ void show_channels(int idx, char *handle)
     if (l < strlen(chan->dname)) {
       l = strlen(chan->dname);
     }
-    if (chk_op(fr, chan))
+    if (real_chk_op(fr, chan, 0))
       total++;
   }
 
@@ -450,7 +450,7 @@ void show_channels(int idx, char *handle)
 
   for (chan = chanset;chan;chan = chan->next) {
     get_user_flagrec(u, &fr, chan->dname);
-    if (chk_op(fr, chan)) {
+    if (real_chk_op(fr, chan, 0)) {
         if (!first) { 
           dprintf(idx, "%s %s access to %d channel%s:\n", handle ? u->handle : "You", handle ? "has" : "have", total, (total > 1) ? "s" : "");
           
@@ -458,7 +458,8 @@ void show_channels(int idx, char *handle)
         }
         dprintf(idx, format, !conf.bot->hub && me_op(chan) ? '@' : ' ', chan->dname, !shouldjoin(chan) ? "(inactive) " : "", 
            channel_privchan(chan) ? "(private)  " : "", chan->manop ? "(no manop) " : "", 
-           channel_bitch(chan) ? "(bitch)    " : "", channel_closed(chan) ?  "(closed)" : "");
+           channel_bitch(chan) && !channel_botbitch(chan) ? "(bitch)    " : channel_botbitch(chan) ? "(botbitch) " : "",
+           channel_closed(chan) ?  "(closed)" : "");
     }
   }
   if (!first)

+ 3 - 1
src/mod/channels.mod/channels.c

@@ -752,7 +752,7 @@ void channels_report(int idx, int details)
 
       s[0] = 0;
 
-      if (channel_bitch(chan))
+      if (chan_bitch(chan))
 	strcat(s, "bitch, ");
       if (s[0])
 	s[strlen(s) - 2] = 0;
@@ -836,6 +836,8 @@ void channels_report(int idx, int details)
  *	if (channel_temp(chan))
  *	  i += my_strcpy(s + i, "temp ");
 */
+        if (channel_botbitch(chan))
+          i += my_strcpy(s + i, "botbitch ");
         if (channel_fastop(chan))
           i += my_strcpy(s + i, "fastop ");
         if (channel_privchan(chan))

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

@@ -1217,6 +1217,7 @@ static void cmd_chaninfo(int idx, char *par)
     work[0] = 0;
     SHOW_FLAG("autoop",		channel_autoop(chan));
     SHOW_FLAG("bitch",		channel_bitch(chan));
+    SHOW_FLAG("botbitch",       channel_botbitch(chan));
     SHOW_FLAG("closed",		channel_closed(chan));
     SHOW_FLAG("cycle",		channel_cycle(chan));
     SHOW_FLAG("enforcebans", 	channel_enforcebans(chan));

+ 7 - 2
src/mod/channels.mod/tclchan.c

@@ -537,6 +537,10 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       chan->status |= CHAN_AUTOOP;
     else if (!strcmp(item[i], "-autoop"))
       chan->status &= ~CHAN_AUTOOP;
+    else if (!strcmp(item[i], "+botbitch"))
+      chan->status |= CHAN_BOTBITCH;
+    else if (!strcmp(item[i], "-botbitch"))
+      chan->status &= ~CHAN_BOTBITCH;
 /* Chanflag template
  *  else if (!strcmp(item[i], "+temp"))
  *    chan->status |= CHAN_TEMP;
@@ -635,10 +639,11 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
   			   chan->channel.key[0] ?
     			   chan->channel.key : chan->key_prot);
     }
-    if ((old_status ^ chan->status) & (CHAN_ENFORCEBANS | CHAN_BITCH)) {
+    if ((old_status ^ chan->status) & (CHAN_ENFORCEBANS | CHAN_BITCH | CHAN_BOTBITCH | CHAN_CLOSED | CHAN_PRIVATE)) {
       recheck_channel(chan, 1);
     /* if we -take, recheck the chan for modes and shit */
-    } else if ((chan->status ^ old_status) & (CHAN_TAKE)) {
+    /* also -[bot]bitch/-private might allow for auto-opping users */
+    } else if ((chan->status ^ old_status) & (CHAN_TAKE | CHAN_BITCH | CHAN_BOTBITCH | CHAN_PRIVATE)) {
       recheck_channel(chan, 1);
     } else if (old_mode_pls_prot != chan->mode_pls_prot || old_mode_mns_prot != chan->mode_mns_prot) {
       recheck_channel_modes(chan);

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

@@ -1005,7 +1005,7 @@ exempt-time %lu invite-time %lu \
 %cenforcebans %cdynamicbans %cuserban %cbitch %cprotectops %crevenge \
 %crevengebot %cprivate %ccycle %cinactive %cdynamicexempts %cuserexempts \
 %cdynamicinvites %cuserinvites %cnodesynch %cclosed %ctake %cvoice \
-%cfastop %cautoop }\n",
+%cfastop %cautoop %cbotbitch }\n",
 	chan->dname,
 	w,
         chan->added_by,
@@ -1057,7 +1057,8 @@ exempt-time %lu invite-time %lu \
 	PLSMNS(channel_take(chan)),
 	PLSMNS(channel_voice(chan)),
 	PLSMNS(channel_fastop(chan)),
-        PLSMNS(channel_autoop(chan))
+        PLSMNS(channel_autoop(chan)),
+        PLSMNS(channel_botbitch(chan))
 /* Chanflag template
  * also include a %ctemp above.
  *      PLSMNS(channel_temp(chan)),

+ 5 - 5
src/mod/irc.mod/chan.c

@@ -921,8 +921,8 @@ static void check_this_member(struct chanset_t *chan, char *nick, struct flag_re
     /* +d or bitch and not an op
      * we dont check private because +private does not imply bitch. */
     if (chan_hasop(m) && 
-        (chk_deop(*fr) ||
-         (!loading && userlist && channel_bitch(chan) && !chk_op(*fr, chan)) ) ) {
+        (chk_deop(*fr, chan) ||
+         (!loading && userlist && chan_bitch(chan) && !chk_op(*fr, chan)) ) ) {
       /* if (target_priority(chan, m, 1)) */
         add_mode(chan, '-', 'o', m->nick);
     } else if (!chan_hasop(m) && dovoice(chan) && chk_autoop(*fr, chan)) {
@@ -1198,11 +1198,11 @@ void recheck_channel(struct chanset_t *chan, int dobans)
 
   /* don't do much if i'm lonely bot. Maybe they won't notice me? :P */
   if (botops == 1 && !botnonops) {
-    if (channel_bitch(chan) || channel_closed(chan))
+    if (chan_bitch(chan) || channel_closed(chan))
       putlog(LOG_MISC, "*", "Opped in %s, not checking +closed/+bitch until more bots arrive.", chan->dname);
   } else {
     /* if the chan is +closed, mass deop first, safer that way. */
-    if (channel_bitch(chan) || channel_closed(chan))
+    if (chan_bitch(chan) || channel_closed(chan))
       enforce_bitch(chan);
 
     if (channel_closed(chan))
@@ -1602,7 +1602,7 @@ static int got352or4(struct chanset_t *chan, char *user, char *host, char *nick,
   if (me_op(chan)) {
     /* are they a chanop, and me too */
         /* are they a channel or global de-op */
-    if (chan_hasop(m) && chk_deop(fr) && !match_my_nick(nick)) 
+    if (chan_hasop(m) && chk_deop(fr, chan) && !match_my_nick(nick)) 
         /* && target_priority(chan, m, 1) */
       add_mode(chan, '-', 'o', nick);
 

+ 3 - 3
src/mod/irc.mod/cmdsirc.c

@@ -37,7 +37,7 @@ static int has_op(int idx, struct chanset_t *chan)
     dprintf(idx, "No such channel.\n");
     return 0;
   }
-  if (chk_op(user, chan))
+  if (real_chk_op(user, chan, 0))
     return 1;
   dprintf(idx, "You are not a channel op on %s.\n", chan->dname);
   return 0;
@@ -503,12 +503,12 @@ static void cmd_op(int idx, char *par)
   egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
   u = get_user_by_host(s);
   get_user_flagrec(u, &victim, chan->dname);
-  if (chk_deop(victim)) {
+  if (chk_deop(victim, chan)) {
     dprintf(idx, "%s is currently being auto-deopped  on %s.\n", m->nick, chan->dname);
     if (all) goto next;
     return;
   }
-  if (channel_bitch(chan) && !chk_op(victim, chan)) {
+  if (chan_bitch(chan) && !chk_op(victim, chan)) {
     dprintf(idx, "%s is not a registered op on %s.\n", m->nick, chan->dname);
     if (all) goto next;
     return;

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

@@ -1242,7 +1242,7 @@ check_netfight(struct chanset_t *chan)
 
   if (limit) {
     if ((chan->channel.fighting) && (chan->channel.fighting > limit)) {
-      if (!channel_bitch(chan) || !channel_closed(chan)) {
+      if (!chan_bitch(chan) || !channel_closed(chan)) {
         putlog(LOG_WARN, "*", "Auto-closed %s - channel fight", chan->dname);
         do_chanset(NULL, chan, "+bitch +closed +backup", DO_LOCAL | DO_NET);
         enforce_closed(chan);

+ 6 - 6
src/mod/irc.mod/mode.c

@@ -544,7 +544,7 @@ got_op(struct chanset_t *chan, memberlist *m, memberlist *mv)
   /* I'm opped, and the opper isn't me, and it isn't a server op */
   if (m && me_op(chan) && !match_my_nick(mv->nick)) {
     /* deop if they are +d or it is +bitch */
-    if (reversing || chk_deop(victim) || (!loading && userlist && channel_bitch(chan) && !chk_op(victim, chan))) {     /* chk_op covers +private */
+    if (reversing || chk_deop(victim, chan) || (!loading && userlist && chan_bitch(chan) && !chk_op(victim, chan))) {     /* chk_op covers +private */
       int num = randint(10);
       char outbuf[101] = ""; 
 
@@ -571,7 +571,7 @@ got_op(struct chanset_t *chan, memberlist *m, memberlist *mv)
   if (!m && me_op(chan) && !match_my_nick(mv->nick)) {
     int snm = chan->stopnethack_mode;
 
-    if (chk_deop(victim)) {
+    if (chk_deop(victim, chan)) {
       mv->flags |= FAKEOP;
       add_mode(chan, '-', 'o', mv->nick);
     } else if (snm > 0 && snm < 7 && !((channel_autoop(chan) ||
@@ -580,9 +580,9 @@ got_op(struct chanset_t *chan, memberlist *m, memberlist *mv)
              !glob_exempt(victim) && !chan_exempt(victim)) {
 
       if (snm == 5)
-        snm = channel_bitch(chan) ? 1 : 3;
+        snm = chan_bitch(chan) ? 1 : 3;
       if (snm == 6)
-        snm = channel_bitch(chan) ? 4 : 2;
+        snm = chan_bitch(chan) ? 4 : 2;
       if (chan_wasoptest(victim) || glob_wasoptest(victim) || snm == 2) {
         if (!chan_wasop(mv)) {
           mv->flags |= FAKEOP;
@@ -648,7 +648,7 @@ got_deop(struct chanset_t *chan, memberlist *m, memberlist *mv, char *isserver)
         !match_my_nick(mv->nick) &&
         /* Is the deopper NOT a master or bot? */
         !glob_master(user) && !chan_master(user) && !glob_bot(user) &&
-        ((chan_op(victim) || (glob_op(victim) && !chan_deop(victim))) || !channel_bitch(chan)))
+        (chk_op(victim, chan) || !chan_bitch(chan)))
       /* Then we'll bless the victim */
       do_op(mv->nick, chan, 0, 0);
   }
@@ -661,7 +661,7 @@ got_deop(struct chanset_t *chan, memberlist *m, memberlist *mv, char *isserver)
   /* Having op hides your +v and +h  status -- so now that someone's lost ops,
    * check to see if they have +v or +h
    */
-  if (!channel_take(chan) && !channel_bitch(chan) && !(mv->flags & (CHANVOICE | STOPWHO))) {
+  if (!channel_take(chan) && !chan_bitch(chan) && !(mv->flags & (CHANVOICE | STOPWHO))) {
     dprintf(DP_HELP, "WHO %s\n", mv->nick);
     mv->flags |= STOPWHO;
   }