Przeglądaj źródła

* Port [3671] to 1.2.15
* Added new chanset flag '+knock' which will make +y bots auto invite USERS. (No flag restrictions currently)



svn: 3672

Bryan Drewery 18 lat temu
rodzic
commit
97272ebfa0

+ 1 - 0
doc/UPDATES

@@ -7,6 +7,7 @@
 * Cleanup some ctcp responses
 * Add more ctcp version responses (mirc scripts), and some others, such as irssi/xchat/snak/cgi::irc
 * Add more 'responses' (ie, kicks reasons)
+* Added new chanset flag '+knock' which will make +y bots auto invite USERS. (No flag restrictions currently)
 
 1.2.14 - http://wraith.botpack.net/milestone/1.2.14
 * Fix another bug in shell functions. (fixes #321)

+ 2 - 1
src/chan.h

@@ -227,7 +227,7 @@ struct chanset_t {
 #define CHAN_CLOSED         BIT3	/* Only users +o can join */
 #define CHAN_BITCH          BIT4	/* be a tightwad with ops             */
 #define CHAN_TAKE 	    BIT5	/* When a bot gets opped, take the chan */
-//#define CHAN_UNUSED     BIT6	/* re-op any +o people who get deop'd */
+#define CHAN_KNOCK 	    BIT6	/* Auto invite qualifying people when they knock */
 #define CHAN_BOTBITCH       BIT7        /* only let bots be opped? */
 #define CHAN_BACKUP         BIT8	/* Join the BOT_BACKUP bots when set */
 #define CHAN_SECRET         BIT9	/* don't advertise channel on botnet  */
@@ -298,6 +298,7 @@ struct chanset_t *findchan_by_dname(const char *name);
 #define channel_privchan(chan) (chan->status & CHAN_PRIVATE)
 #define channel_autoop(chan) (chan->status & CHAN_AUTOOP)
 #define channel_nomassjoin(chan) (chan->status & CHAN_NOMASSJOIN)
+#define channel_knock(chan) (chan->status & CHAN_KNOCK)
 /* Chanflag template
  *#define channel_temp(chan) (chan->status & CHAN_PRIVATE)
  */

+ 2 - 0
src/mod/channels.mod/channels.c

@@ -860,6 +860,8 @@ void channels_report(int idx, int details)
           i += my_strcpy(s + i, "voice ");
         if (channel_autoop(chan))
           i += my_strcpy(s + i, "autoop ");
+        if (channel_knock(chan))
+          i += my_strcpy(s + i, "knock ");
 /* Chanflag template
  *	if (channel_temp(chan))
  *	  i += my_strcpy(s + i, "temp ");

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

@@ -1195,6 +1195,7 @@ static void cmd_chaninfo(int idx, char *par)
     SHOW_FLAG("nodesynch",	channel_nodesynch(chan));
     SHOW_FLAG("nomassjoin",	channel_nomassjoin(chan));
     SHOW_FLAG("private",	channel_privchan(chan));
+    SHOW_FLAG("knock",          channel_knock(chan));
 //    SHOW_FLAG("revenge",	channel_revenge(chan));
 //    SHOW_FLAG("revengebot",	channel_revengebot(chan));
     if (HAVE_TAKE)

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

@@ -581,6 +581,10 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item,
       chan->status |= CHAN_NOMASSJOIN;
     else if (!strcmp(item[i], "-nomassjoin"))
       chan->status &= ~CHAN_NOMASSJOIN;
+    else if (!strcmp(item[i], "+knock"))
+      chan->status |= CHAN_KNOCK;
+    else if (!strcmp(item[i], "-knock"))
+      chan->status &= ~CHAN_KNOCK;
 /* Chanflag template
  *  else if (!strcmp(item[i], "+temp"))
  *    chan->status |= CHAN_TEMP;

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

@@ -736,7 +736,7 @@ flood-exempt %d flood-lock-time %lu \
 %cenforcebans %cdynamicbans %cuserbans %cbitch \
 %cprivate %ccycle %cinactive %cdynamicexempts %cuserexempts \
 %cdynamicinvites %cuserinvites %cnodesynch %cclosed %cvoice \
-%cfastop %cautoop %cbotbitch %cbackup %cnomassjoin %c%s}\n",
+%cfastop %cautoop %cbotbitch %cbackup %cnomassjoin %cknock %c%s}\n",
 	chan->dname,
 	w,
         chan->added_by,
@@ -790,6 +790,7 @@ flood-exempt %d flood-lock-time %lu \
         PLSMNS(channel_botbitch(chan)),
         PLSMNS(channel_backup(chan)),
         PLSMNS(channel_nomassjoin(chan)),
+        PLSMNS(channel_knock(chan)),
 	HAVE_TAKE ? PLSMNS(channel_take(chan)) : 0,
         HAVE_TAKE ? "take " : " "
 /* Chanflag template
@@ -837,7 +838,7 @@ exempt-time %lu invite-time %lu voice-non-ident %d auto-delay %d \
 %cenforcebans %cdynamicbans %cuserbans %cbitch \
 %cprivate %ccycle %cinactive %cdynamicexempts %cuserexempts \
 %cdynamicinvites %cuserinvites %cnodesynch %cclosed %cvoice \
-%cfastop %cautoop %cbotbitch %cbackup %cnomassjoin %c%s}\n",
+%cfastop %cautoop %cbotbitch %cbackup %cnomassjoin %cknock %c%s}\n",
 	chan->dname,
 	w,
         chan->added_by,
@@ -888,6 +889,7 @@ exempt-time %lu invite-time %lu voice-non-ident %d auto-delay %d \
         PLSMNS(channel_botbitch(chan)),
         PLSMNS(channel_backup(chan)),
         PLSMNS(channel_nomassjoin(chan)),
+        PLSMNS(channel_knock(chan)),
 	HAVE_TAKE ? PLSMNS(channel_take(chan)) : 0,
         HAVE_TAKE ? "take " : " "
 /* Chanflag template

+ 41 - 0
src/mod/irc.mod/chan.c

@@ -1475,6 +1475,46 @@ static int got341(char *from, char *msg)
 }
 #endif /* CACHE */
 
+/* got 710: knock
+ * <server> 710 <to> <channel> <from> :<reason?>
+ * :irc.umich.edu 710 #wraith #wraith bryand!bryan@oper.blessed.net :has asked for an invite.
+ */
+static int got710(char *from, char *msg)
+{
+  char *chname = NULL;
+  struct chanset_t *chan = NULL;
+
+  chname = newsplit(&msg);
+  chan = findchan(chname);
+
+  if (!channel_knock(chan) || !dovoice(chan))
+    return 0;
+
+  char buf[UHOSTLEN] = "", *uhost = buf, *nick;
+
+  newsplit(&msg); //not used
+  uhost = newsplit(&msg);
+
+  struct userrec *u = get_user_by_host(uhost);
+
+  if (!u)
+    return 0;
+
+  nick = splitnick(&uhost);
+
+  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0 };
+
+  get_user_flagrec(u, &fr, chan->dname, chan);
+
+  if (chan_kick(fr) || glob_kick(fr))
+    return 0;
+
+//  dprintf(DP_HELP, "PRIVMSG %s :%s knocked, inviting.. (%s)\n", chname, nick, u ? u->handle : "");
+  cache_invite(chan, nick, uhost, u ? u->handle : NULL, 0, 0);
+
+  return 0;
+}
+
 /* got 324: mode status
  * <server> 324 <to> <channel> <mode>
  */
@@ -3177,5 +3217,6 @@ static cmd_t irc_raw[] =
   {"348",	"",	(Function) got348,	"irc:348", LEAF},
   {"349",	"",	(Function) got349,	"irc:349", LEAF},
   {"353",	"",	(Function) got353,	"irc:353", LEAF},
+  {"710",	"",	(Function) got710,	"irc:710", LEAF},
   {NULL,	NULL,	NULL,			NULL, 0}
 };