浏览代码

* Added CFG_CHANSET
* Reorganized when chanprog() is called in main


svn: 867

Bryan Drewery 22 年之前
父节点
当前提交
8b70b7eb2d
共有 11 个文件被更改,包括 90 次插入29 次删除
  1. 2 0
      doc/UPDATES
  2. 53 7
      src/cfg.c
  3. 1 1
      src/cfg.h
  4. 0 5
      src/chanprog.c
  5. 7 8
      src/hooks.h
  6. 4 1
      src/main.c
  7. 9 1
      src/mod/channels.mod/channels.c
  8. 2 0
      src/mod/channels.mod/channels.h
  9. 2 0
      src/mod/channels.mod/tclchan.c
  10. 9 6
      src/mod/server.mod/server.c
  11. 1 0
      src/mod/server.mod/server.h

+ 2 - 0
doc/UPDATES

@@ -22,6 +22,8 @@ This is a summary of ChangeLog basically.
 19.Bots now respond to /ctcp CHAT quicker
 20.lock-threshold config option is now close-threshold.
 21.Fixed a bug with a full harddrive.
+22.Added config setting "chanset". Change to change what flags new channels will have. 
+   Original default list will apply for options you leave out.
 
 1.1.3
 1.Fixed a very fatal bug with channel ctcps.

+ 53 - 7
src/cfg.c

@@ -5,8 +5,8 @@
  */
 
 #include "common.h"
-#include "cmds.h"
 #include "cfg.h"
+#include "cmds.h"
 #include "userrec.h"
 #include "auth.h"
 #include "misc.h"
@@ -19,6 +19,7 @@
 #include <fcntl.h>
 #include "chan.h"
 #include "tandem.h"
+#include "src/mod/channels.mod/channels.h"
 #ifdef S_DCCPASS
 #include "botnet.h"
 #endif /* S_DCCPASS */
@@ -33,18 +34,35 @@ char 				cmdprefix[1] = "+";	/* This is the prefix for msg/channel cmds */
 struct cmd_pass 		*cmdpass = NULL;
 #endif /* S_DCCPASS */
 
-struct cfg_entry CFG_MOTD = { 
-	"motd", CFGF_GLOBAL, NULL, NULL, 
-	NULL, NULL, NULL 
+
+void chanset_describe(struct cfg_entry * entry, int idx) {
+#ifdef HUB
+  dprintf(idx, STR("chanset is a list of default options for when a channel is added. Same format as .chanset.\n"));
+#endif /* HUB */
+}
+
+void chanset_changed(struct cfg_entry *entry, char *olddata, int *valid) {
+  if (entry->ldata) {
+    strncpyz(cfg_glob_chanset, (char *) entry->ldata, 512);
+  } else if (entry->gdata) {
+    strncpyz(cfg_glob_chanset, (char *) entry->gdata, 512);
+  }
+}
+
+struct cfg_entry CFG_CHANSET = {
+	"chanset", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL, 
+	chanset_changed, chanset_changed, chanset_describe
 };
 
 #if defined(S_AUTHHASH) || defined(S_DCCAUTH)
-void authkey_describe(struct cfg_entry * entry, int idx) {
+void authkey_describe(struct cfg_entry *entry, int idx) {
+#ifdef HUB
   dprintf(idx, 
   STR("authkey is used for authing, give to your users if they are to use DCC chat or IRC cmds. (can be bot specific)\n"));
+#endif /* HUB */
 }
 
-void authkey_changed(struct cfg_entry * entry, char * olddata, int * valid) {
+void authkey_changed(struct cfg_entry *entry, char *olddata, int *valid) {
   if (entry->ldata) {
     strncpyz(authkey, (char *) entry->ldata, sizeof authkey);
   } else if (entry->gdata) {
@@ -60,6 +78,7 @@ struct cfg_entry CFG_AUTHKEY = {
 
 #ifdef S_MSGCMDS
 void msgcmds_describe(struct cfg_entry *entry, int idx) {
+#ifdef HUB
   if (entry == &CFG_MSGOP)
     dprintf(idx, STR("msgop defines the cmd for opping via msging the bot (leave blank to disable)\n"));
   else if (entry == &CFG_MSGPASS)
@@ -68,6 +87,7 @@ void msgcmds_describe(struct cfg_entry *entry, int idx) {
     dprintf(idx, STR("msginvite defines the cmd for requesting invite via msging the bot (leave blank to disable)\n"));
   else if (entry == &CFG_MSGIDENT)
     dprintf(idx, STR("msgident defines the cmd for identing via msging the bot (leave blank to disable)\n"));
+#endif /* HUB */
 }
 
 struct cfg_entry CFG_MSGOP = {
@@ -92,7 +112,9 @@ struct cfg_entry CFG_MSGIDENT = {
 #endif /* S_MSGCMDS */
 
 void cmdprefix_describe(struct cfg_entry *entry, int idx) {
+#ifdef HUB
   dprintf(idx, STR("cmdprefix is the prefix used for msg cmds, ie: !op or .op\n"));
+#endif /* HUB */
 }
 
 void cmdprefix_changed(struct cfg_entry * entry, char * olddata, int * valid) {
@@ -114,6 +136,7 @@ struct cfg_entry CFG_CMDPREFIX = {
 
 void deflag_describe(struct cfg_entry *cfgent, int idx)
 {
+#ifdef HUB
   if (cfgent == &CFG_BADCOOKIE)
     dprintf(idx, STR("bad-cookie decides what happens to a bot if it does an illegal op (no/incorrect op cookie)\n"));
   else if (cfgent == &CFG_MANUALOP)
@@ -130,7 +153,9 @@ void deflag_describe(struct cfg_entry *cfgent, int idx)
     dprintf(idx, STR("mdop decides what happens to a user doing a mass deop\n"));
   else if (cfgent == &CFG_MOP)
     dprintf(idx, STR("mop decides what happens to a user doing a mass op\n"));
-  dprintf(idx, STR("Valid settings are: ignore (No flag changes), deop (set flags to +d), kick (set flags to +dk) or delete (remove from userlist)\n"));
+  dprintf(idx, 
+  STR("Valid settings are: ignore (No flag changes), deop (set flags to +d), kick (set flags to +dk) or delete (remove from userlist)\n"));
+#endif /* HUB */
 }
 
 void deflag_changed(struct cfg_entry *entry, char *oldval, int *valid) 
@@ -254,6 +279,7 @@ void deflag_user(struct userrec *u, int why, char *msg, struct chanset_t *chan)
 
 void misc_describe(struct cfg_entry *cfgent, int idx)
 {
+#ifdef HUB
   int i = 0;
 
   if (!strcmp(cfgent->name, STR("fork-interval"))) {
@@ -285,6 +311,7 @@ void misc_describe(struct cfg_entry *cfgent, int idx)
   }
   if (!i)
     dprintf(idx, STR("Valid settings are: ignore, warn, die, reject, suicide\n"));
+#endif /* HUB */
 }
 
 void fork_lchanged(struct cfg_entry * cfgent, char * oldval, int * valid) {
@@ -302,7 +329,9 @@ void fork_gchanged(struct cfg_entry * cfgent, char * oldval, int * valid) {
 }
 
 void fork_describe(struct cfg_entry * cfgent, int idx) {
+#ifdef HUB
   dprintf(idx, STR("fork-interval is number of seconds in between each fork() call made by the bot, to change process ID and reset cpu usage counters.\n"));
+#endif /* HUB */
 }
 
 struct cfg_entry CFG_FORKINTERVAL = {
@@ -368,21 +397,30 @@ struct cfg_entry CFG_PROCESSLIST = {
 
 /* this is cfg shit from servers/irc/ctcp because hub doesnt load
  * these mods */
+
 #ifdef HUB
 void servers_describe(struct cfg_entry * entry, int idx) {
+#ifdef HUB
   dprintf(idx, STR("servers is a comma-separated list of servers the bot will use\n"));
+#endif /* HUB */
 }
 
 void servers6_describe(struct cfg_entry * entry, int idx) {
+#ifdef HUB
   dprintf(idx, STR("servers6 is a comma-separated list of servers the bot will use (FOR IPv6)\n"));
+#endif /* HUB */
 }
 
 void nick_describe(struct cfg_entry * entry, int idx) {
+#ifdef HUB
   dprintf(idx, STR("nick is the bots preferred nick when connecting/using .resetnick\n"));
+#endif /* HUB */
 }
 
 void realname_describe(struct cfg_entry * entry, int idx) {
+#ifdef HUB
   dprintf(idx, STR("realname is the bots \"real name\" when connecting\n"));
+#endif /* HUB */
 }
 
 struct cfg_entry CFG_SERVERS = {
@@ -406,6 +444,7 @@ struct cfg_entry CFG_REALNAME = {
 
 void getin_describe(struct cfg_entry *cfgent, int idx)
 {
+#ifdef HUB
   if (!strcmp(cfgent->name, STR("op-bots")))
     dprintf(idx, STR("op-bots is number of bots to ask every time a oprequest is to be made\n"));
   else if (!strcmp(cfgent->name, STR("in-bots")))
@@ -426,6 +465,7 @@ void getin_describe(struct cfg_entry *cfgent, int idx)
     dprintf(idx, STR("No description for %s ???\n"), cfgent->name);
     putlog(LOG_ERRORS, "*", STR("getin_describe() called with unknown config entry %s"), cfgent->name);
   }
+#endif /* HUB */
 }
 
 void getin_changed(struct cfg_entry *cfgent, char *oldval, int *valid)
@@ -637,8 +677,14 @@ void set_cfg_str(char *target, char *entryname, char *data)
   }
 }
 
+struct cfg_entry CFG_MOTD = { 
+	"motd", CFGF_GLOBAL, NULL, NULL, 
+	NULL, NULL, NULL 
+};
+
 void init_config()
 {
+  add_cfg(&CFG_CHANSET);
 #if defined(S_AUTHHASH) || defined(S_DCCAUTH)
   add_cfg(&CFG_AUTHKEY);
 #endif /* S_AUTHHASH || S_DCCAUTH */

+ 1 - 1
src/cfg.h

@@ -18,7 +18,7 @@ typedef struct cfg_entry {
   void (*describe) (struct cfg_entry *, int idx);
 } cfg_entry_T;
 
-extern struct cfg_entry CFG_MOTD, CFG_CMDPREFIX, CFG_BADCOOKIE, CFG_MANUALOP, CFG_MDOP, CFG_MOP, CFG_FORKINTERVAL;
+extern struct cfg_entry CFG_MOTD, CFG_CMDPREFIX, CFG_BADCOOKIE, CFG_MANUALOP, CFG_MDOP, CFG_MOP, CFG_FORKINTERVAL, CFG_CHANSET;
 #if defined(S_AUTHHASH) || defined(S_DCCAUTH)
 extern struct cfg_entry CFG_AUTHKEY;
 #endif /* S_AUTHHASH || S_DCCAUTH */

+ 0 - 5
src/chanprog.c

@@ -526,11 +526,6 @@ void chanprog()
   sdprintf("ip6: %s", myipstr(6));
   conmask = 0;
 
- /* now this only checks server shit. (no channels) */
-  call_hook(HOOK_REHASH);
-
-  strcpy(botuser, origbotname);
-
   if (!conf.bot->nick)
     fatal("I don't have a nickname!!\n", 0);
 #ifdef HUB

+ 7 - 8
src/hooks.h

@@ -4,14 +4,13 @@
 #include "types.h"
 
 #define HOOK_READ_USERFILE        1
-#define HOOK_REHASH               2
-#define HOOK_USERFILE             3
-#define HOOK_PRE_REHASH           4
-#define HOOK_IDLE                 5
-#define HOOK_BACKUP               6
-#define HOOK_DIE                  7
-#define HOOK_DAILY                8
-#define REAL_HOOKS                9
+#define HOOK_USERFILE             2
+#define HOOK_PRE_REHASH           3
+#define HOOK_IDLE                 4
+#define HOOK_BACKUP               5
+#define HOOK_DIE                  6
+#define HOOK_DAILY                7
+#define REAL_HOOKS                8
 
 #define HOOK_RFC_CASECMP        111
 

+ 4 - 1
src/main.c

@@ -742,6 +742,7 @@ int main(int argc, char **argv)
     }
   }
 
+  chanprog();
   dns_init();
   channels_init();
 #ifdef LEAF
@@ -754,7 +755,9 @@ int main(int argc, char **argv)
   notes_init();
   console_init();
   ctcp_init();
-  chanprog();
+
+  strcpy(botuser, origbotname);
+  trigger_cfg_changed();
 
 #ifdef LEAF
   if (localhub) {

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

@@ -45,7 +45,7 @@ static int 			global_exempt_time;
 static int 			global_invite_time;
 
 /* Global channel settings (drummer/dw) */
-static char 			glob_chanset[512] = "";
+char 				glob_chanset[512] = "", cfg_glob_chanset[512] = "";
 
 /* Global flood settings */
 static int 			gfld_chan_thr;
@@ -943,6 +943,14 @@ void channels_init()
 	 "-voice "
          "-private "
 	 "-fastop ");
+#ifdef HUB
+  /* this should only happen while upgrading to 1.1.4 */
+  if (!CFG_CHANSET.gdata) {
+    cfg_noshare++;
+    set_cfg_str(NULL, "chanset", glob_chanset);
+    cfg_noshare--;
+  }
+#endif /* HUB */
 #ifdef LEAF
   timer_create_secs(60, "check_limitraise", (Function) check_limitraise);
 #endif /* LEAF */

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

@@ -92,6 +92,8 @@ int ismodeline(masklist *, char *);
 
 void channels_report(int, int);
 
+extern char		glob_chanset[], cfg_glob_chanset[];
+
 /* Macro's here because their functions were replaced by something more
  * generic. <cybah>
  */

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

@@ -750,6 +750,8 @@ int channel_add(char *result, char *newname, char *options)
   }
   simple_sprintf(buf, "chanmode { %s } ", glob_chanmode);
   strcat(buf, glob_chanset);
+  strcat(buf, cfg_glob_chanset);
+  strcat(buf, " ");
   strcat(buf, options);
   buf[strlen(buf)] = 0;
 

+ 9 - 6
src/mod/server.mod/server.c

@@ -1393,13 +1393,14 @@ static void server_prerehash()
   strcpy(oldnick, botname);
 }
 
-static void server_postrehash()
+void server_postrehash()
 {
   strncpyz(botname, origbotname, NICKLEN);
   if (oldnick[0] && !rfc_casecmp(oldnick, botname)) {
     /* Change botname back, don't be premature. */
     strcpy(botname, oldnick);
-    dprintf(DP_SERVER, "NICK %s\n", origbotname);
+    if (server_online)
+      dprintf(DP_SERVER, "NICK %s\n", origbotname);
   }
   /* Change botname back incase we were using altnick previous to rehash. */
   else if (oldnick[0])
@@ -1552,7 +1553,6 @@ void server_init()
   timer_create_secs(300, "server_5minutely", (Function) server_5minutely);
   timer_create_secs(60, "minutely_checks", (Function) minutely_checks);
   add_hook(HOOK_PRE_REHASH, (Function) server_prerehash);
-  add_hook(HOOK_REHASH, (Function) server_postrehash);
   add_hook(HOOK_DIE, (Function) server_die);
   mq.head = hq.head = modeq.head = NULL;
   mq.last = hq.last = modeq.last = NULL;
@@ -1568,8 +1568,11 @@ void server_init()
   add_cfg(&CFG_SERVERS);
   add_cfg(&CFG_SERVERS6);
   add_cfg(&CFG_REALNAME);
-  cfg_noshare = 1;
-  set_cfg_str(NULL, STR("realname"), "A deranged product of evil coders.");
-  cfg_noshare = 0;
+
+  if (!CFG_REALNAME.gdata) {
+    cfg_noshare = 1;
+    set_cfg_str(NULL, STR("realname"), "A deranged product of evil coders.");
+    cfg_noshare = 0;
+  }
 }
 #endif /* LEAF */

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

@@ -65,5 +65,6 @@ int detect_avalanche(char *);
 void server_report(int, int);
 void server_init();
 void queue_server(int, char *, int);
+void server_postrehash();
 
 #endif /*leaf*/