Browse Source

* Add cmd_netrelease

Bryan Drewery 16 years ago
parent
commit
da499feb64
8 changed files with 43 additions and 12 deletions
  1. 1 1
      doc/UPDATES
  2. 8 2
      doc/help.txt
  3. 16 0
      src/cmds.c
  4. 2 0
      src/eggdrop.h
  5. 5 0
      src/mod/irc.mod/irc.c
  6. 1 1
      src/mod/server.mod/server.c
  7. 1 1
      src/mod/server.mod/server.h
  8. 9 7
      src/mod/server.mod/servmsg.c

+ 1 - 1
doc/UPDATES

@@ -1,4 +1,4 @@
-* Add cmd 'release' and msg-release for releasing a bot's jupenick on a 7 second timer.
+* Add cmd 'release', 'netrelease' and msg-release for releasing a bot's jupenick on a 7 second timer.
 
 1.3 - http://wraith.botpack.net/milestone/1.3
 * Binary / shell / startup changes

+ 8 - 2
doc/help.txt

@@ -1392,6 +1392,12 @@ See also: botnick, nick
    on 'ps'.
  
 See also: ps
+:hub:netrelease
+###  $netrelease$b <nick>
+   Tells all bots to unjupe the specified nickname. They will wait 7 seconds
+   before attempting to regain the nickname.
+ 
+See also: set, release
 :hub:netrontab:
 ###  $bnetcrontab$b <status|delete|show|new> [interval]
    Runs the specified crontab command on all linked bots.
@@ -1490,11 +1496,11 @@ See also: restart
  
 See also: bots%{+n}, newleaf%{-}%{+a}, -bot%{-}
 :leaf:release
-###  $bservers$b
+###  $brelease$b
    Releases the bot's nick if it is on the jupenick. It gives an estimated
    7 seconds before it attempts to regain its jupenick.
  
-See also: set
+See also: set, netrelease
 ::reload
 ###  $breload$b
    Reloads the bot's user file, discarding any changes made since the last

+ 16 - 0
src/cmds.c

@@ -3913,6 +3913,21 @@ static void cmd_netnick (int idx, char *par) {
   botnet_send_cmd_broad(-1, conf.bot->nick, dcc[idx].nick, idx, "curnick");
 }
 
+static void cmd_netrelease (int idx, char* par) {
+  putlog(LOG_CMDS, "*", "#%s# netrelease %s", dcc[idx].nick, par);
+  if (!par || !par[0]) {
+    dprintf(idx, "Usage: netrelease <nick>\n");
+    return;
+  }
+
+  // Don't bother checking what bot has the nick, multiple bots may be trying to jupe it
+  // so instead, tell all bots to release the specified nick.
+  // Any bots trying to get it will stop for 7 seconds, and any bot on it will release it.
+  bd::String str;
+  str.printf("rn %s", par);
+  putallbots(str.c_str());
+}
+
 static void cmd_botnick(int idx, char * par) {
   putlog(LOG_CMDS, "*", "#%s# botnick %s", dcc[idx].nick, par);
   if (!par || !par[0]) {
@@ -4629,6 +4644,7 @@ cmd_t C_dcc[] =
   {"botmsg",		"o",    (Function) cmd_botmsg,          NULL, HUB},
   {"botnick", 		"m", 	(Function) cmd_botnick, 	NULL, HUB},
   {"netnick", 		"m", 	(Function) cmd_netnick, 	NULL, HUB},
+  {"netrelease", 	"m", 	(Function) cmd_netrelease, 	NULL, HUB},
   {"netw", 		"n", 	(Function) cmd_netw, 		NULL, HUB},
   {"netps", 		"n", 	(Function) cmd_netps, 		NULL, HUB},
   {"netlast", 		"n", 	(Function) cmd_netlast, 	NULL, HUB},

+ 2 - 0
src/eggdrop.h

@@ -62,6 +62,8 @@
 #define RANDSPECIAL     "#*+,-./;<=>?[]^_{}|"
 #define RANDSPECIALLEN  19
 
+#define RELEASE_TIME	7
+
 #define ESCAPESHELL	"`\\|#*()[]& "
 
 #if (NICKMAX < 9) || (NICKMAX > 32)

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

@@ -1723,9 +1723,14 @@ do_nettype()
   }
 }
 
+static void bot_release_nick (char *botnick, char *code, char *par) {
+  release_nick(par);
+}
+
 static cmd_t irc_bot[] = {
   {"gi", "", (Function) getin_request, NULL, LEAF},
   {"mr", "", (Function) mass_request, NULL, LEAF},
+  {"rn", "", (Function) bot_release_nick, NULL, LEAF},
   {NULL, NULL, NULL, NULL, 0}
 };
 

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

@@ -1003,7 +1003,7 @@ static void server_secondly()
         ison_cnt = 0;
       } else
         ++ison_cnt;
-    } else if (!keepnick && ((now - release_time) >= 7)) {
+    } else if (!keepnick && ((now - release_time) >= RELEASE_TIME)) {
       release_time = 0;
       keepnick = 1;
       nick_available(1, 0);

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

@@ -60,7 +60,7 @@ extern rate_t		flood_msg, flood_ctcp, flood_callerid;
 
 int check_bind_ctcpr(char *, char *, struct userrec *, char *, char *, char *, bind_table_t *);
 void nicks_available(char* buf, char delim = 0, bool buf_contains_available = 1);
-void release_nick();
+void release_nick(const char* = NULL);
 
 #define check_bind_ctcp(a, b, c, d, e, f) check_bind_ctcpr(a, b, c, d, e, f, BT_ctcp)
 #define check_bind_ctcr(a, b, c, d, e, f) check_bind_ctcpr(a, b, c, d, e, f, BT_ctcr)

+ 9 - 7
src/mod/server.mod/servmsg.c

@@ -912,17 +912,19 @@ void nicks_available(char* buf, char delim, bool buf_contains_available) {
   nick_available(is_jupe, is_orig);
 }
 
-void release_nick() {
+void release_nick(const char* nick) {
   // Only do this if currently on a jupenick
-  if (jupenick[0] && match_my_nick(jupenick)) {
+  if (jupenick[0] && ((!nick && match_my_nick(jupenick)) || (nick && !rfc_casecmp(jupenick, nick)))) {
     keepnick = 0;
     release_time = now;
 
-    altnick_char = rolls = 0;
-    tried_nick = now;
-    dprintf(DP_MODE, "NICK %s\n", origbotname);
-    putlog(LOG_MISC, "*", "Releasing jupenick '%s' and switching back to nick '%s'", jupenick, origbotname);
-  } else
+    if (match_my_nick(jupenick)) {
+      altnick_char = rolls = 0;
+      tried_nick = now;
+      dprintf(DP_MODE, "NICK %s\n", origbotname);
+      putlog(LOG_MISC, "*", "Releasing jupenick '%s' and switching back to nick '%s'", jupenick, origbotname);
+    }
+  } else if (!nick)
     putlog(LOG_CMDS, "*", "Not releasing nickname. (Not currently on a jupenick)");
 }