1
0
Эх сурвалжийг харах

* Cmd_conf now does the same as -C does: add/remove bots, add hosts (see UPDATES)

svn: 2098
Bryan Drewery 21 жил өмнө
parent
commit
87708e687b
3 өөрчлөгдсөн 22 нэмэгдсэн , 10 устгасан
  1. 7 7
      doc/UPDATES
  2. 14 2
      src/cmds.c
  3. 1 1
      src/conf.c

+ 7 - 7
doc/UPDATES

@@ -81,7 +81,13 @@ Lines prefixxed with '-' were disabled before release and are not finishsed, or
   -Running the bot with -C will automatically update uid/uname/homedir/username
   -Added cmd line param '-c' to avoid auto updating uid/uname/homedir/username
   -The binary is only rewritten now if CHANGES are made in the editor.
-  * Things done after the config is saved:
+* cmd_conf changes:
+  -Added 'enable' and 'disable' for bots
+  -'remove', 'rem', 'delete' are now also recognized for 'del'
+  -Fixed the binary not correctly being rewritten/saved
+  -Bots are now correctly killed/spawned 
+  -'del' now also removes the bot from the userlist
+* Things done after using cmd_conf / editing config with -C:
    -New bots are spawned and added (if linked)
    -Changed (NEW) ip/host for bots are added to the botnet (if linked)
    -Removed bots are killed and removed from the userlist (if linked)
@@ -105,12 +111,6 @@ Lines prefixxed with '-' were disabled before release and are not finishsed, or
 * Added log msg (+w) for when a msg is received when umode +g. (#44)
 * cmd_botcmd now works correctly when the target is the bot you're on. (#46)
 * cmd_pls_user wasn't correctly sharing multiple hosts to the botnet. (#48)
-* cmd_conf changes:
-  -Added 'enable' and 'disable' for bots
-  -'remove', 'rem', 'delete' are now also recognized for 'del'
-  -Fixed the binary not correctly being rewritten/saved
-  -Bots are now correctly killed/spawned 
-  -'del' now also removes the bot from the userlist
 * Only auto-op a user if they have a password set. (#52)
 * Made cmd_addlog o|o
 * Several cmds were not saving userfile: -/+chrec|ban|exempt|invite, [un]stick, chinfo (#68)

+ 14 - 2
src/cmds.c

@@ -1729,8 +1729,11 @@ static void cmd_conf(int idx, char *par)
       dprintf(idx, "Usage: conf <add|del|change|disable|enable|list|set> [options]\n");
     else
       dprintf(idx, "Usage: conf <set> [options]\n");
+
     return;
   }
+
+  conf_bot *oldlist = conf_bots_dup(conf.bots);
   
   putlog(LOG_CMDS, "*", "#%s# conf %s %s", dcc[idx].nick, cmd, par[0] ? par : "");
   if (!egg_strcasecmp(cmd, "add") || !egg_strcasecmp(cmd, "change")) {
@@ -1739,6 +1742,8 @@ static void cmd_conf(int idx, char *par)
     nick = newsplit(&par);
     if (!nick || (nick && !nick[0])) {
       dprintf(idx, "Usage: conf %s <bot> [<ip|.> <[+]host|.> [ipv6-ip]]\n", cmd);
+
+      free_conf_bots(oldlist);
       return;
     }
 
@@ -1759,6 +1764,8 @@ static void cmd_conf(int idx, char *par)
   } else if (!egg_strncasecmp(cmd, "del", 3) || !egg_strncasecmp(cmd, "rem", 3)) {
     if (!par[0]) {
       dprintf(idx, "Usage: conf del <bot>\n");
+
+      free_conf_bots(oldlist);
       return;
     }
 
@@ -1874,10 +1881,15 @@ static void cmd_conf(int idx, char *par)
     free(listbot);
 
   if (save) {
+    /* rewrite our binary */
     conf_to_bin(&conf, 0, -1);
-    if (!conf.bot->hub)
-      spawnbots();			/* parse conf struct and spawn/kill as needed */
+
+    kill_removed_bots(oldlist, conf.bots);
+    conf_add_userlist_bots();
+    spawnbots();
   }
+
+  free_conf_bots(oldlist);
 }
 
 static void cmd_encrypt(int idx, char *par)

+ 1 - 1
src/conf.c

@@ -1019,8 +1019,8 @@ void conf_add_userlist_bots()
     if (!bot->hub) {
       u = get_user_by_handle(userlist, bot->nick);
       if (!u) {
+        putlog(LOG_MISC, "*", "Adding bot '%s' as it has been added to the binary config.", bot->nick);
         userlist = adduser(userlist, bot->nick, "none", "-", USER_OP, 1);
-        putlog(LOG_MISC, "*", "Adding '%s' as it has been added to the binary config.", bot->nick);
         u = get_user_by_handle(userlist, bot->nick);
 
         egg_snprintf(tmp, sizeof(tmp), "%li [internal]", now);