Browse Source

Merge branch 'chanset-default'

* chanset-default:
  * Also need UFF_CHDEFAULT check for streaming capable bots
  * Update default ban-type to 3
  * Update docs
  * Set the 'default' channel options when adding a channel
  * Fix UFF_CHANSET compatibility check being in wrong place
  * Add channel_to_string()
  * Remove set 'chanset'
  * Commit initial work for chanset 'default'
Bryan Drewery 16 năm trước cách đây
mục cha
commit
0bb441acc5

+ 3 - 0
doc/UPDATES

@@ -60,6 +60,9 @@
   * Fix cmd_slowjoin not working on backup bots correctly.
   * Fix cmd_slowjoin not working on backup bots correctly.
   * Fix a crash from long hubnicks.
   * Fix a crash from long hubnicks.
 * Misc changes
 * Misc changes
+  * Added pseudo-channel 'default' which can be modified with 'chanset' and 'chaninfo'.
+    This is used to modify what the default channel options will be for new channels.
+  * Removed 'set chanset' as it has been replaced by 'chanset default'
   * Add new channel setting 'ban-type' which support mIRC style ban types (adapted from recent eggdrop patch)
   * Add new channel setting 'ban-type' which support mIRC style ban types (adapted from recent eggdrop patch)
   * EFnet server list updates (To update yours: .set -YES servers - | .set -YES servers6 -)
   * EFnet server list updates (To update yours: .set -YES servers - | .set -YES servers6 -)
   * Give localhubs credit for adding their child bots in 'whois'.
   * Give localhubs credit for adding their child bots in 'whois'.

+ 2 - 1
doc/help.txt

@@ -589,12 +589,13 @@ See also: status, whois
             flags grant them access to.%{-}
             flags grant them access to.%{-}
 See also: whois%{+m}, chattr, chaninfo%{-}
 See also: whois%{+m}, chattr, chaninfo%{-}
 ::chanset
 ::chanset
-###  $bchanset$b <channel> <settings>
+###  $bchanset$b [#&!+channel|*|default] <settings>
    Allows you to change the channel settings (see $b'chaninfo'$b for the
    Allows you to change the channel settings (see $b'chaninfo'$b for the
    settings) for one specific channel or all channels. Use '*' to to apply the
    settings) for one specific channel or all channels. Use '*' to to apply the
    change to all channels.
    change to all channels.
    Changes are used until the next restart, and are saved
    Changes are used until the next restart, and are saved
    whenever the userfile is saved.
    whenever the userfile is saved.
+   Modifying 'default' will change what new channels get when they are created.
  
  
 See also: %{+n}+chan, -chan%{-}, chaninfo
 See also: %{+n}+chan, -chan%{-}, chaninfo
 ::chat
 ::chat

+ 20 - 6
src/chanprog.c

@@ -54,7 +54,9 @@
 #endif
 #endif
 #include <sys/utsname.h>
 #include <sys/utsname.h>
 
 
+char *def_chanset = "+enforcebans +dynamicbans +userbans -bitch +cycle -inactive +userexempts -dynamicexempts +userinvites -dynamicinvites -nodesynch -closed -take -voice -private -fastop +meankicks ban-type 3";
 struct chanset_t 	*chanset = NULL;	/* Channel list			*/
 struct chanset_t 	*chanset = NULL;	/* Channel list			*/
+struct chanset_t	*chanset_default = NULL;	/* Default channel list */
 char 			admin[121] = "";	/* Admin info			*/
 char 			admin[121] = "";	/* Admin info			*/
 char			origbotnick[NICKLEN + 1] = "";	/* from -B (placed into conf.bot->nick .. for backup when conf is cleared */
 char			origbotnick[NICKLEN + 1] = "";	/* from -B (placed into conf.bot->nick .. for backup when conf is cleared */
 char 			origbotname[NICKLEN + 1] = "";	/* Nick to regain */
 char 			origbotname[NICKLEN + 1] = "";	/* Nick to regain */
@@ -584,6 +586,15 @@ void chanprog()
 
 
 
 
   sdprintf("I am: %s", conf.bot->nick);
   sdprintf("I am: %s", conf.bot->nick);
+
+  /* Add the 'default' virtual channel.
+     The flags will be overwritten when the userfile is loaded,
+     but if there is no userfile yet, or no 'default' channel,
+     then it will take on the properties of 'def_chanset',
+     and then later save this to the userfile.
+   */
+  channel_add(NULL, "default", def_chanset, 1);
+
   if (conf.bot->hub) {
   if (conf.bot->hub) {
     simple_snprintf(userfile, 121, "%s/.u", dirname(binname));
     simple_snprintf(userfile, 121, "%s/.u", dirname(binname));
     loading = 1;
     loading = 1;
@@ -803,11 +814,11 @@ bool shouldjoin(struct chanset_t *chan)
 /* do_chanset() set (options) on (chan)
 /* do_chanset() set (options) on (chan)
  * USES DO_LOCAL|DO_NET bits.
  * USES DO_LOCAL|DO_NET bits.
  */
  */
-int do_chanset(char *result, struct chanset_t *chan, const char *options, int local)
+int do_chanset(char *result, struct chanset_t *chan, const char *options, int flags)
 {
 {
   int ret = OK;
   int ret = OK;
 
 
-  if (local & DO_NET) {
+  if (flags & DO_NET) {
     size_t bufsiz = 0;
     size_t bufsiz = 0;
          /* malloc(options,chan,'cset ',' ',+ 1) */
          /* malloc(options,chan,'cset ',' ',+ 1) */
     if (chan)
     if (chan)
@@ -829,15 +840,15 @@ int do_chanset(char *result, struct chanset_t *chan, const char *options, int lo
     free(buf);
     free(buf);
   }
   }
 
 
-  if (local & DO_LOCAL) {
-    bool cmd = (local & CMD);
+  if (flags & DO_LOCAL) {
+    bool cmd = (flags & CMD);
     struct chanset_t *ch = NULL;
     struct chanset_t *ch = NULL;
     int all = chan ? 0 : 1;
     int all = chan ? 0 : 1;
 
 
     if (chan)
     if (chan)
       ch = chan;
       ch = chan;
     else
     else
-      ch = chanset;
+      ch = chanset_default; //First iteration changes default, then move on to all chans
 
 
     while (ch) {
     while (ch) {
       const char **item = NULL;
       const char **item = NULL;
@@ -855,7 +866,10 @@ int do_chanset(char *result, struct chanset_t *chan, const char *options, int lo
         if (ret == ERROR) /* just bail if there was an error, no sense in trying more */
         if (ret == ERROR) /* just bail if there was an error, no sense in trying more */
           return ret;
           return ret;
 
 
-        ch = ch->next;
+        if (ch == chanset_default)
+          ch = chanset;
+        else
+          ch = ch->next;
       } else {
       } else {
         ch = NULL;
         ch = NULL;
       }
       }

+ 2 - 2
src/chanprog.h

@@ -32,8 +32,8 @@ bool is_hub(const char*);
 void load_internal_users();
 void load_internal_users();
 void setup_HQ(int);
 void setup_HQ(int);
 
 
-extern struct chanset_t		*chanset;
-extern char			admin[], origbotnick[NICKLEN + 1], origbotname[NICKLEN + 1], jupenick[NICKLEN], botname[NICKLEN + 1];
+extern struct chanset_t		*chanset, *chanset_default;
+extern char			admin[], origbotnick[NICKLEN + 1], origbotname[NICKLEN + 1], jupenick[NICKLEN], botname[NICKLEN + 1], *def_chanset;
 extern port_t			my_port;
 extern port_t			my_port;
 extern bool			reset_chans, cookies_disabled;
 extern bool			reset_chans, cookies_disabled;
 
 

+ 15 - 20
src/mod/channels.mod/channels.c

@@ -47,6 +47,7 @@
 #include "src/net.h"
 #include "src/net.h"
 #include "src/binds.h"
 #include "src/binds.h"
 #include "src/cmds.h"
 #include "src/cmds.h"
+#include <bdlib/src/String.h>
 
 
 
 
 #include <sys/stat.h>
 #include <sys/stat.h>
@@ -59,8 +60,6 @@ static interval_t			global_exempt_time;
 static interval_t 			global_invite_time;
 static interval_t 			global_invite_time;
 
 
 
 
-/* Global channel settings (drummer/dw) */
-char glob_chanset[512];
 static char *lastdeletedmask = NULL;
 static char *lastdeletedmask = NULL;
 
 
 /* Global flood settings */
 /* Global flood settings */
@@ -121,7 +120,7 @@ static void got_cset(char *botnick, char *code, char *par)
   if (!par || !par[0])
   if (!par || !par[0])
    return;
    return;
 
 
-  bool all = 0;
+  bool all = 0, isdefault = 0;
   char *chname = NULL;
   char *chname = NULL;
   struct chanset_t *chan = NULL;
   struct chanset_t *chan = NULL;
 
 
@@ -129,26 +128,22 @@ static void got_cset(char *botnick, char *code, char *par)
     all = 1;
     all = 1;
     newsplit(&par);
     newsplit(&par);
    } else {
    } else {
-    if (!strchr(CHANMETA, par[0])) {
-      putlog(LOG_ERROR, "*", "Got bad cset: bot: %s code: %s par: %s", botnick, code, par);
-      return;
-    }
-    chname = newsplit(&par);
-    if (!(chan = findchan_by_dname(chname)))
-      return;
+     chname = newsplit(&par);
+     if (!strcasecmp(chname, "default"))
+       isdefault = 1;
+     else if (!strchr(CHANMETA, chname[0])) {
+       putlog(LOG_ERROR, "*", "Got bad cset: bot: %s code: %s par: %s %s", botnick, code, chname, par);
+       return;
+     }
+     if (isdefault)
+       chan = chanset_default;
+     else if (!(chan = findchan_by_dname(chname)))
+       return;
    }
    }
 
 
   if (all)
   if (all)
-   chan = chanset;
-
-  while (chan) {
-    chname = chan->dname;
-    do_chanset(NULL, chan, par, DO_LOCAL);
-    if (!all)
-      chan = NULL;
-    else
-      chan = chan->next;
-  }
+   chan = NULL;
+  do_chanset(NULL, chan, par, DO_LOCAL);
 }
 }
 
 
 /* returns 1 if botn is in bots */
 /* returns 1 if botn is in bots */

+ 5 - 4
src/mod/channels.mod/channels.h

@@ -26,6 +26,7 @@ static int count_mask(maskrec *);
 
 
 namespace bd {
 namespace bd {
   class Stream;
   class Stream;
+  class String;
 }
 }
 
 
 void remove_channel(struct chanset_t *);
 void remove_channel(struct chanset_t *);
@@ -37,8 +38,9 @@ struct chanuserrec *add_chanrec(struct userrec *u, char *);
 void del_chanrec(struct userrec *, char *);
 void del_chanrec(struct userrec *, char *);
 void write_bans(bd::Stream&, int);
 void write_bans(bd::Stream&, int);
 void write_exempts(bd::Stream&, int);
 void write_exempts(bd::Stream&, int);
-void write_chans(bd::Stream&, int);
+void write_chans(bd::Stream&, int, bool = 0);
 void write_chans_compat(bd::Stream&, int);
 void write_chans_compat(bd::Stream&, int);
+bd::String channel_to_string(struct chanset_t* chan, bool force_inactive = 0);
 void write_invites(bd::Stream&, int);
 void write_invites(bd::Stream&, int);
 bool expired_mask(struct chanset_t *, char *);
 bool expired_mask(struct chanset_t *, char *);
 void set_handle_laston(char *, struct userrec *, time_t);
 void set_handle_laston(char *, struct userrec *, time_t);
@@ -48,17 +50,16 @@ int u_sticky_mask(maskrec *, char *);
 int u_setsticky_mask(struct chanset_t *, maskrec *, char *, int, const char);
 int u_setsticky_mask(struct chanset_t *, maskrec *, char *, int, const char);
 int SplitList(char *, const char *, int *, const char ***);
 int SplitList(char *, const char *, int *, const char ***);
 int channel_modify(char *, struct chanset_t *, int, char **, bool);
 int channel_modify(char *, struct chanset_t *, int, char **, bool);
-int channel_add(char *, char *, char *);
+int channel_add(char *, char *, char *, bool = 0);
 void clear_channel(struct chanset_t *, bool);
 void clear_channel(struct chanset_t *, bool);
 int u_equals_mask(maskrec *, char *);
 int u_equals_mask(maskrec *, char *);
 bool u_match_mask(struct maskrec *, char *);
 bool u_match_mask(struct maskrec *, char *);
 bool ismasked(masklist *, const char *);
 bool ismasked(masklist *, const char *);
 bool ismodeline(masklist *, const char *);
 bool ismodeline(masklist *, const char *);
 void channels_report(int, int);
 void channels_report(int, int);
-void channels_writeuserfile(bd::Stream&, bool = 0);
+void channels_writeuserfile(bd::Stream&, int = 0);
 void rcmd_chans(char *, char *, char *);
 void rcmd_chans(char *, char *, char *);
 
 
-extern char		glob_chanset[512];
 
 
 /* Macro's here because their functions were replaced by something more
 /* Macro's here because their functions were replaced by something more
  * generic. <cybah>
  * generic. <cybah>

+ 19 - 7
src/mod/channels.mod/cmdschan.c

@@ -1203,7 +1203,10 @@ static void cmd_chaninfo(int idx, char *par)
       return;
       return;
     }
     }
   }
   }
-  chan = findchan_by_dname(chname);
+  if (!strcasecmp(chname, "default"))
+    chan = chanset_default;
+  else
+    chan = findchan_by_dname(chname);
   if (!chan || (chan && privchan(user, chan, PRIV_OP))) {
   if (!chan || (chan && privchan(user, chan, PRIV_OP))) {
     dprintf(idx, "No such channel.\n");
     dprintf(idx, "No such channel.\n");
     return;
     return;
@@ -1314,10 +1317,11 @@ static void cmd_chanset(int idx, char *par)
   char *chname = NULL, result[RESULT_LEN] = "";
   char *chname = NULL, result[RESULT_LEN] = "";
   struct chanset_t *chan = NULL;
   struct chanset_t *chan = NULL;
   int all = 0;
   int all = 0;
+  bool isdefault = 0;
 
 
   if (!par[0]) {
   if (!par[0]) {
     putlog(LOG_CMDS, "*", "#%s# chanset %s", dcc[idx].nick, par);
     putlog(LOG_CMDS, "*", "#%s# chanset %s", dcc[idx].nick, par);
-    dprintf(idx, "Usage: chanset [%schannel|*] <settings>\n", CHANMETA);
+    dprintf(idx, "Usage: chanset [%schannel|*|default] <settings>\n", CHANMETA);
     return;
     return;
   }
   }
 
 
@@ -1330,10 +1334,17 @@ static void cmd_chanset(int idx, char *par)
     }
     }
     newsplit(&par);
     newsplit(&par);
   } else {
   } else {
-    if (strchr(CHANMETA, par[0])) {
+    if (par && par[0]) {
       chname = newsplit(&par);
       chname = newsplit(&par);
+      if (!strcasecmp(chname, "default"))
+        isdefault = 1;
+    }
+    if ((chname[0] && strchr(CHANMETA, chname[0])) || isdefault) {
       get_user_flagrec(dcc[idx].user, &user, chname);
       get_user_flagrec(dcc[idx].user, &user, chname);
-      chan = findchan_by_dname(chname);
+      if (isdefault)
+        chan = chanset_default;
+      else
+        chan = findchan_by_dname(chname);
 
 
       if (!glob_master(user) && !chan_master(user)) {
       if (!glob_master(user) && !chan_master(user)) {
         dprintf(idx, "You don't have access to %s. \n", chname);
         dprintf(idx, "You don't have access to %s. \n", chname);
@@ -1357,8 +1368,8 @@ static void cmd_chanset(int idx, char *par)
 	par = chname;
 	par = chname;
       }
       }
     }
     }
-    if (!par[0] || par[0] == '*') {
-      dprintf(idx, "Usage: chanset [%schannel] <settings>\n", CHANMETA);
+    if (!chname[0] || chname[0] == '*') {
+      dprintf(idx, "Usage: chanset [%schannel|*|default] <settings>\n", CHANMETA);
       return;
       return;
     }
     }
     if (!chan && !(chan = findchan_by_dname(chname = dcc[idx].u.chat->con_chan))) {
     if (!chan && !(chan = findchan_by_dname(chname = dcc[idx].u.chat->con_chan))) {
@@ -1373,8 +1384,9 @@ static void cmd_chanset(int idx, char *par)
     dprintf(idx, "Error trying to set { %s } on %s: %s\n", par, all ? "all channels" : chan->dname, result);
     dprintf(idx, "Error trying to set { %s } on %s: %s\n", par, all ? "all channels" : chan->dname, result);
     return;
     return;
   }
   }
+
   if (all)
   if (all)
-    dprintf(idx, "Successfully set modes { %s } on all channels.\n", par);
+    dprintf(idx, "Successfully set modes { %s } on all channels (Including the default).\n", par);
   else
   else
     dprintf(idx, "Successfully set modes { %s } on %s\n", par, chan->dname);
     dprintf(idx, "Successfully set modes { %s } on %s\n", par, chan->dname);
 
 

+ 25 - 12
src/mod/channels.mod/tclchan.c

@@ -798,7 +798,7 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item,
   if ((chan->status ^ old_status) & CHAN_TAKE)
   if ((chan->status ^ old_status) & CHAN_TAKE)
     chan->status |= (CHAN_FASTOP|CHAN_BITCH);		// to avoid bots still mass opping from +take from not using cookies
     chan->status |= (CHAN_FASTOP|CHAN_BITCH);		// to avoid bots still mass opping from +take from not using cookies
 
 
-  if (!conf.bot->hub) {
+  if (!conf.bot->hub && (chan != chanset_default)) {
     if ((old_status ^ chan->status) & (CHAN_INACTIVE | CHAN_BACKUP)) {
     if ((old_status ^ chan->status) & (CHAN_INACTIVE | CHAN_BACKUP)) {
       if (!shouldjoin(chan) && (chan->status & (CHAN_ACTIVE | CHAN_PEND)))
       if (!shouldjoin(chan) && (chan->status & (CHAN_ACTIVE | CHAN_PEND)))
         dprintf(DP_SERVER, "PART %s\n", chan->name);
         dprintf(DP_SERVER, "PART %s\n", chan->name);
@@ -908,9 +908,13 @@ void clear_channel(struct chanset_t *chan, bool reset)
 
 
 /* Create new channel and parse commands.
 /* Create new channel and parse commands.
  */
  */
-int channel_add(char *result, char *newname, char *options)
+int channel_add(char *result, char *newname, char *options, bool isdefault)
 {
 {
-  if (!newname || !newname[0] || !strchr(CHANMETA, newname[0])) {
+  /* When loading userfile */
+  if (newname && newname[0] && loading && !strcmp(newname, "default"))
+    isdefault = 1;
+
+  if (!newname || !newname[0] || (!isdefault && !strchr(CHANMETA, newname[0]))) {
     if (result)
     if (result)
       strlcpy(result, "invalid channel prefix", RESULT_LEN);
       strlcpy(result, "invalid channel prefix", RESULT_LEN);
     return ERROR;
     return ERROR;
@@ -928,10 +932,16 @@ int channel_add(char *result, char *newname, char *options)
 
 
   simple_snprintf(buf, sizeof(buf), "chanmode { %s } ", glob_chanmode);
   simple_snprintf(buf, sizeof(buf), "chanmode { %s } ", glob_chanmode);
   strlcat(buf, def_chanset, sizeof(buf));
   strlcat(buf, def_chanset, sizeof(buf));
-  strlcat(buf, " ", sizeof(buf));
-  strlcat(buf, glob_chanset, sizeof(buf));
-  strlcat(buf, " ", sizeof(buf));
-  strlcat(buf, options, sizeof(buf));
+  // Add in 'default' channel options
+  if (!isdefault && chanset_default) {
+    bd::String default_chan_options = channel_to_string(chanset_default);
+    strlcat(buf, " ", sizeof(buf));
+    strlcat(buf, default_chan_options.c_str(), sizeof(buf));
+  }
+  if (options && options[0]) {
+    strlcat(buf, " ", sizeof(buf));
+    strlcat(buf, options, sizeof(buf));
+  }
 
 
   if (SplitList(result, buf, &items, &item) != OK)
   if (SplitList(result, buf, &items, &item) != OK)
     return ERROR;
     return ERROR;
@@ -980,7 +990,6 @@ int channel_add(char *result, char *newname, char *options)
     chan->ban_time = global_ban_time;
     chan->ban_time = global_ban_time;
     chan->exempt_time = global_exempt_time;
     chan->exempt_time = global_exempt_time;
     chan->invite_time = global_invite_time;
     chan->invite_time = global_invite_time;
-    /* let's initialize this stuff for shits & giggles */
     chan->channel.jointime = 0;
     chan->channel.jointime = 0;
     chan->channel.parttime = 0;
     chan->channel.parttime = 0;
     chan->channel.fighting = 0;
     chan->channel.fighting = 0;
@@ -997,10 +1006,14 @@ int channel_add(char *result, char *newname, char *options)
 
 
     /* Initialize chan->channel info */
     /* Initialize chan->channel info */
     init_channel(chan, 0);
     init_channel(chan, 0);
-    list_append((struct list_type **) &chanset, (struct list_type *) chan);
-    /* Channel name is stored in xtra field for sharebot stuff */
-    if (!conf.bot->hub)
-      join = 1;
+    if (isdefault)
+      chanset_default = chan;
+    else {
+      list_append((struct list_type **) &chanset, (struct list_type *) chan);
+      /* Channel name is stored in xtra field for sharebot stuff */
+      if (!conf.bot->hub && !isdefault)
+        join = 1;
+    }
   }
   }
   /* If loading is set, we're loading the userfile. Ignore errors while
   /* If loading is set, we're loading the userfile. Ignore errors while
    * reading userfile and just return OK. This is for compatability
    * reading userfile and just return OK. This is for compatability

+ 43 - 30
src/mod/channels.mod/userchan.c

@@ -701,32 +701,31 @@ void write_invites(bd::Stream& stream, int idx)
 
 
 /* Write the channels to the userfile
 /* Write the channels to the userfile
  */
  */
-void write_chans(bd::Stream& stream, int idx)
+static void write_chan(bd::Stream& stream, int idx, struct chanset_t* chan)
 {
 {
   bd::String buf;
   bd::String buf;
 
 
-  putlog(LOG_DEBUG, "*", "Writing channels..");
-
-  stream << buf.printf(CHANS_NAME " - -\n");
-
-  char w[1024] = "";
+  putlog(LOG_DEBUG, "*", "writing channel %s to userfile..", chan->dname);
 
 
-  for (struct chanset_t *chan = chanset; chan; chan = chan->next) {
-    char inactive = 0;
+  bool force_inactive = 0;
+  /* if a bot should explicitly NOT join, just set it +inactive ... */
+  if (idx >= 0 && !botshouldjoin(dcc[idx].user, chan))
+    force_inactive = 1;
 
 
-    putlog(LOG_DEBUG, "*", "writing channel %s to userfile..", chan->dname);
-    get_mode_protect(chan, w, sizeof(w));
+  stream << buf.printf("+ channel add %s { ", chan->dname);
+  if (chan != chanset_default)
+    stream << buf.printf("addedby %s addedts %li ", chan->added_by, (long)chan->added_ts);
+  stream << channel_to_string(chan, force_inactive);
+  stream << buf.printf("}\n");
+}
 
 
-    /* if a bot should explicitly NOT join, just set it +inactive ... */
-    if (idx >= 0 && !botshouldjoin(dcc[idx].user, chan))
-      inactive = '+';
-    /* ... otherwise give the bot the *actual* setting */
-    else
-      inactive = PLSMNS(channel_inactive(chan));
+bd::String channel_to_string(struct chanset_t* chan, bool force_inactive) {
+  bd::String buf;
+  char w[1024] = "";
 
 
-    stream << buf.printf("\
-+ channel add %s { chanmode { %s } addedby %s addedts %li \
-bad-cookie %d manop %d mdop %d mop %d limit %d ban-type %d \
+  get_mode_protect(chan, w, sizeof(w));
+  buf.printf("\
+chanmode { %s } bad-cookie %d manop %d mdop %d mop %d limit %d  ban-type %d \
 flood-chan %d:%d flood-ctcp %d:%d flood-join %d:%d \
 flood-chan %d:%d flood-ctcp %d:%d flood-join %d:%d \
 flood-kick %d:%d flood-deop %d:%d flood-nick %d:%d flood-mjoin %d:%d \
 flood-kick %d:%d flood-deop %d:%d flood-nick %d:%d flood-mjoin %d:%d \
 closed-ban %d closed-invite %d closed-private %d ban-time %d \
 closed-ban %d closed-invite %d closed-private %d ban-time %d \
@@ -735,11 +734,8 @@ flood-exempt %d flood-lock-time %d knock %d \
 %cmeankicks %cenforcebans %cdynamicbans %cuserbans %cbitch \
 %cmeankicks %cenforcebans %cdynamicbans %cuserbans %cbitch \
 %cprivate %ccycle %cinactive %cdynamicexempts %cuserexempts \
 %cprivate %ccycle %cinactive %cdynamicexempts %cuserexempts \
 %cdynamicinvites %cuserinvites %cnodesynch %cclosed %cvoice \
 %cdynamicinvites %cuserinvites %cnodesynch %cclosed %cvoice \
-%cfastop %cautoop %cbotbitch %cbackup %cnomassjoin %crbl %c%s}\n",
-	chan->dname,
+%cfastop %cautoop %cbotbitch %cbackup %cnomassjoin %crbl %c%s",
 	w,
 	w,
-        chan->added_by,
-        (long)chan->added_ts,
 /* Chanchar template
 /* Chanchar template
  *      temp,
  *      temp,
  * also include temp %s in dprintf.
  * also include temp %s in dprintf.
@@ -779,7 +775,7 @@ flood-exempt %d flood-lock-time %d knock %d \
 	PLSMNS(channel_bitch(chan)),
 	PLSMNS(channel_bitch(chan)),
 	PLSMNS(channel_privchan(chan)),
 	PLSMNS(channel_privchan(chan)),
 	PLSMNS(channel_cycle(chan)),
 	PLSMNS(channel_cycle(chan)),
-        inactive,
+        force_inactive ? '+' : PLSMNS(channel_inactive(chan)),
 	PLSMNS(channel_dynamicexempts(chan)),
 	PLSMNS(channel_dynamicexempts(chan)),
 	PLSMNS(!channel_nouserexempts(chan)),
 	PLSMNS(!channel_nouserexempts(chan)),
  	PLSMNS(channel_dynamicinvites(chan)),
  	PLSMNS(channel_dynamicinvites(chan)),
@@ -799,8 +795,25 @@ flood-exempt %d flood-lock-time %d knock %d \
  * also include a %ctemp above.
  * also include a %ctemp above.
  *      PLSMNS(channel_temp(chan)),
  *      PLSMNS(channel_temp(chan)),
  */
  */
-    );
-  }
+  );
+  return buf;
+}
+
+/* Write the channels to the userfile
+ */
+void write_chans(bd::Stream& stream, int idx, bool old)
+{
+  bd::String buf;
+
+  putlog(LOG_DEBUG, "*", "Writing channels..");
+
+  stream << buf.printf(CHANS_NAME " - -\n");
+
+  /* FIXME: Remove after 1.2.15 */
+  if (!old)
+    write_chan(stream, idx, chanset_default);
+  for (struct chanset_t *chan = chanset; chan; chan = chan->next)
+    write_chan(stream, idx, chan);
 }
 }
 
 
 /* FIXME: remove after 1.2.14 */
 /* FIXME: remove after 1.2.14 */
@@ -888,12 +901,12 @@ exempt-time %d invite-time %d voice-non-ident %d auto-delay %d \
   }
   }
 }
 }
 
 
-void channels_writeuserfile(bd::Stream& stream, bool old)
+void channels_writeuserfile(bd::Stream& stream, int old)
 {
 {
   putlog(LOG_DEBUG, "@", "Writing channel/ban/exempt/invite entries.");
   putlog(LOG_DEBUG, "@", "Writing channel/ban/exempt/invite entries.");
-  if (!old)
-    write_chans(stream, -1);
-  else
+  if (old != 1)
+    write_chans(stream, -1, old == 0 ? 0 : 1);
+  else /* flood-* hacks */
     write_chans_compat(stream, -1);
     write_chans_compat(stream, -1);
   write_vars_and_cmdpass(stream, -1);
   write_vars_and_cmdpass(stream, -1);
   write_bans(stream, -1);
   write_bans(stream, -1);

+ 13 - 2
src/mod/share.mod/share.c

@@ -909,6 +909,9 @@ share_ufyes(int idx, char *par)
 
 
     lower_bot_linked(idx);
     lower_bot_linked(idx);
 
 
+    if (strstr(par, "chdefault"))
+        dcc[idx].u.bot->uff_flags |= UFF_CHDEFAULT;
+
     if (strstr(par, "stream")) {
     if (strstr(par, "stream")) {
       updatebot(-1, dcc[idx].nick, '+', 0, 0, 0, NULL);
       updatebot(-1, dcc[idx].nick, '+', 0, 0, 0, NULL);
       /* Start up a tbuf to queue outgoing changes for this bot until the
       /* Start up a tbuf to queue outgoing changes for this bot until the
@@ -950,7 +953,7 @@ share_userfileq(int idx, char *par)
       dprintf(idx, "s un Already sharing.\n");
       dprintf(idx, "s un Already sharing.\n");
     else {
     else {
       dcc[idx].u.bot->uff_flags |= (UFF_OVERRIDE | UFF_INVITE | UFF_EXEMPT);
       dcc[idx].u.bot->uff_flags |= (UFF_OVERRIDE | UFF_INVITE | UFF_EXEMPT);
-      dprintf(idx, "s uy overbots invites exempts stream\n");
+      dprintf(idx, "s uy overbots invites exempts stream chdefault\n");
       /* Set stat-getting to astatic void race condition (robey 23jun1996) */
       /* Set stat-getting to astatic void race condition (robey 23jun1996) */
       dcc[idx].status |= STAT_SHARE | STAT_GETTING | STAT_AGGRESSIVE;
       dcc[idx].status |= STAT_SHARE | STAT_GETTING | STAT_AGGRESSIVE;
       if (conf.bot->hub)
       if (conf.bot->hub)
@@ -1454,7 +1457,11 @@ static void
 stream_send_users(int idx)
 stream_send_users(int idx)
 {
 {
   bd::Stream stream;
   bd::Stream stream;
-  stream_writeuserfile(stream, userlist);
+  bool old = 0;
+  /* FIXME: Remove after 1.2.15 */
+  if (idx != -1 && !(dcc[idx].u.bot->uff_flags & UFF_CHDEFAULT)) /* channel 'default' */
+    old = 2;
+  stream_writeuserfile(stream, userlist, old);
   stream.seek(0, SEEK_SET);
   stream.seek(0, SEEK_SET);
   dprintf(idx, "s ls\n");
   dprintf(idx, "s ls\n");
   bd::String buf;
   bd::String buf;
@@ -1484,6 +1491,10 @@ start_sending_users(int idx)
   if (bot && bot->buildts < 1175102242) /* flood-* hacks */
   if (bot && bot->buildts < 1175102242) /* flood-* hacks */
     old = 1;
     old = 1;
 
 
+  /* FIXME: Remove after 1.2.15 */
+  if (idx != -1 && !(dcc[idx].u.bot->uff_flags & UFF_CHDEFAULT)) /* channel 'default' */
+    old = 2;
+
   const char salt1[] = SALT1;
   const char salt1[] = SALT1;
   EncryptedStream stream(salt1);
   EncryptedStream stream(salt1);
   stream_writeuserfile(stream, userlist, old);
   stream_writeuserfile(stream, userlist, old);

+ 1 - 0
src/mod/share.mod/share.h

@@ -9,6 +9,7 @@
 #define	UFF_OVERRIDE	BIT0	/* Override existing bot entries    */
 #define	UFF_OVERRIDE	BIT0	/* Override existing bot entries    */
 #define UFF_INVITE	BIT1	/* Send invites in user file	    */
 #define UFF_INVITE	BIT1	/* Send invites in user file	    */
 #define UFF_EXEMPT	BIT2	/* Send exempts in user file	    */
 #define UFF_EXEMPT	BIT2	/* Send exempts in user file	    */
+#define UFF_CHDEFAULT	BIT3
 
 
 #include "src/users.h"
 #include "src/users.h"
 
 

+ 2 - 9
src/set.c

@@ -40,7 +40,6 @@ int dcc_autoaway;
 bool irc_autoaway;
 bool irc_autoaway;
 bool link_cleartext;
 bool link_cleartext;
 bool dccauth = 0;
 bool dccauth = 0;
-char *def_chanset = "+enforcebans +dynamicbans +userbans -bitch +cycle -inactive +userexempts -dynamicexempts +userinvites -dynamicinvites -nodesynch -closed -take -voice -private -fastop +meankicks ban-type 3";
 int cloak_script = 0;
 int cloak_script = 0;
 rate_t close_threshold;
 rate_t close_threshold;
 int fight_threshold;
 int fight_threshold;
@@ -75,7 +74,6 @@ static variable_t vars[] = {
  VAR("auth-key",	auth_key,		VAR_STRING|VAR_PERM,				0, 0, NULL),
  VAR("auth-key",	auth_key,		VAR_STRING|VAR_PERM,				0, 0, NULL),
  VAR("auth-obscure",	&auth_obscure,		VAR_INT|VAR_BOOL,				0, 1, "0"),
  VAR("auth-obscure",	&auth_obscure,		VAR_INT|VAR_BOOL,				0, 1, "0"),
  VAR("auth-prefix",	auth_prefix,		VAR_WORD|VAR_NOLHUB|VAR_PERM,			0, 0, "+"),
  VAR("auth-prefix",	auth_prefix,		VAR_WORD|VAR_NOLHUB|VAR_PERM,			0, 0, "+"),
- VAR("chanset",		glob_chanset,		VAR_STRING|VAR_CHANSET|VAR_NOLHUB,		0, 0, NULL),
  VAR("cloak-script",	&cloak_script,		VAR_INT|VAR_CLOAK|VAR_NOLHUB,			0, 10, "0"),
  VAR("cloak-script",	&cloak_script,		VAR_INT|VAR_CLOAK|VAR_NOLHUB,			0, 10, "0"),
  VAR("close-threshold",	&close_threshold,	VAR_RATE|VAR_NOLOC,				0, 0, "0:0"),
  VAR("close-threshold",	&close_threshold,	VAR_RATE|VAR_NOLOC,				0, 0, "0:0"),
  VAR("dcc-autoaway",	&dcc_autoaway,		VAR_INT|VAR_NOLOC,				0, (5*60*60), "1800"),
  VAR("dcc-autoaway",	&dcc_autoaway,		VAR_INT|VAR_NOLOC,				0, (5*60*60), "1800"),
@@ -532,12 +530,8 @@ sdprintf("var: %s (local): %s", var->name, data ? data : "(NULL)");
 sdprintf("var: %s (global): %s", var->name, data ? data : "(NULL)");
 sdprintf("var: %s (global): %s", var->name, data ? data : "(NULL)");
     if (data && !clear)
     if (data && !clear)
       var->gdata = strdup(data);
       var->gdata = strdup(data);
-    else {
-      if (var->flags & VAR_CHANSET)
-        var->gdata = strdup(def_chanset);
-      else 
-        var->gdata = var->def ? strdup(var->def) : NULL;
-    }
+    else
+      var->gdata = var->def ? strdup(var->def) : NULL;
 
 
     if (domem && var->mem)
     if (domem && var->mem)
       var_set_mem(var, var->gdata);
       var_set_mem(var, var->gdata);
@@ -611,7 +605,6 @@ void init_vars()
     if (!vars[i].gdata && !vars[i].ldata && !(!conf.bot->hub && (vars[i].flags & VAR_NOLDEF)))
     if (!vars[i].gdata && !vars[i].ldata && !(!conf.bot->hub && (vars[i].flags & VAR_NOLDEF)))
       var_set(&vars[i], NULL, NULL);		//empty out and set to defaults
       var_set(&vars[i], NULL, NULL);		//empty out and set to defaults
   }
   }
-  var_set_by_name(NULL, "chanset", def_chanset);
 #ifdef DEBUG
 #ifdef DEBUG
   if (!strncmp(conf.bot->nick, "wtest", 5))
   if (!strncmp(conf.bot->nick, "wtest", 5))
     var_set_by_name(NULL, "homechan", "#bryan");
     var_set_by_name(NULL, "homechan", "#bryan");

+ 2 - 2
src/set.h

@@ -28,7 +28,7 @@
 #define VAR_PERM	BIT13
 #define VAR_PERM	BIT13
 /* Don't set the var data from the mem as default (NICK) */
 /* Don't set the var data from the mem as default (NICK) */
 #define VAR_NODEF	BIT14
 #define VAR_NODEF	BIT14
-#define VAR_CHANSET	BIT15
+//#define VAR_UNUSED	BIT15
 /* Don't set the default on startup of a leaf (servers) */
 /* Don't set the default on startup of a leaf (servers) */
 #define VAR_NOLDEF	BIT16
 #define VAR_NOLDEF	BIT16
 /* Don't set global on hub */
 /* Don't set global on hub */
@@ -67,7 +67,7 @@ typedef struct rate_b {
  interval_t time;
  interval_t time;
 } rate_t;
 } rate_t;
 
 
-extern char		auth_key[], auth_prefix[2], motd[], *def_chanset, alias[], rbl_servers[1024],
+extern char		auth_key[], auth_prefix[2], motd[], alias[], rbl_servers[1024],
 			msgident[], msginvite[], msgop[], msgpass[],
 			msgident[], msginvite[], msgop[], msgpass[],
                         homechan[], altchars[];
                         homechan[], altchars[];
 extern bool		dccauth, auth_obscure, manop_warn, auth_chan, oidentd, ident_botnick, irc_autoaway, link_cleartext;
 extern bool		dccauth, auth_obscure, manop_warn, auth_chan, oidentd, ident_botnick, irc_autoaway, link_cleartext;