Просмотр исходного кода

* Fixed cmd relaying
* Made cmd_bc as alias for cmd_botcmd


svn: 148

Bryan Drewery 23 лет назад
Родитель
Сommit
82d461c845
5 измененных файлов с 49 добавлено и 31 удалено
  1. 9 9
      src/botcmd.c
  2. 23 14
      src/cmds.c
  3. 1 4
      src/dccutil.c
  4. 1 1
      src/misc.c
  5. 15 3
      src/tclhash.c

+ 9 - 9
src/botcmd.c

@@ -1462,8 +1462,10 @@ void bounce_simul(int idx, char *buf)
 {
 {
   char rmsg[SGRAB-110];
   char rmsg[SGRAB-110];
 
 
-  if (!buf || !buf[0] || !dcc[idx].simulbot || !dcc[idx].simulbot[0] || idx < 0)
+  if (!buf || !buf[0] || !dcc[idx].simulbot || !dcc[idx].simulbot[0] || idx < 0) {
+    debug0("returning from bounce_simul");
     return;
     return;
+  }
 
 
   snprintf(rmsg, sizeof rmsg, "r-sr %d %s", idx, buf);          /* remote-simul[r]eturn idx buf */
   snprintf(rmsg, sizeof rmsg, "r-sr %d %s", idx, buf);          /* remote-simul[r]eturn idx buf */
 
 
@@ -1473,23 +1475,21 @@ void bounce_simul(int idx, char *buf)
 void send_remote_simul(int idx, char *bot, char *cmd, char *par)
 void send_remote_simul(int idx, char *bot, char *cmd, char *par)
 {
 {
   char msg[SGRAB-110];
   char msg[SGRAB-110];
-Context;
-  snprintf(msg, sizeof msg, "r-s %d %s %d %s %s", idx, dcc[idx].nick, dcc[idx].u.chat->con_flags, cmd, par);
+  snprintf(msg, sizeof msg, "r-s %d %s %d %s %s %s", idx, dcc[idx].nick, dcc[idx].u.chat->con_flags, dcc[idx].u.chat->con_chan, cmd, par);
 
 
-Context;
   putbot(bot, msg);
   putbot(bot, msg);
-Context;
 }
 }
 
 
 /* idx nick conmask cmd par */
 /* idx nick conmask cmd par */
 static void bot_rsim(char *botnick, char *code, char *par)
 static void bot_rsim(char *botnick, char *code, char *par)
 {
 {
   int ridx = -1, idx = -1, i = 0, rconmask;
   int ridx = -1, idx = -1, i = 0, rconmask;
-  char *nick = NULL, *cmd = NULL, buf[UHOSTMAX];
+  char *nick = NULL, *cmd = NULL, *rconchan = NULL, buf[UHOSTMAX];
 
 
   ridx = atoi(newsplit(&par));
   ridx = atoi(newsplit(&par));
   nick = newsplit(&par);
   nick = newsplit(&par);
   rconmask = atoi(newsplit(&par));
   rconmask = atoi(newsplit(&par));
+  rconchan = newsplit(&par);
   cmd = newsplit(&par);
   cmd = newsplit(&par);
   if (ridx < 0 || !nick || !cmd)
   if (ridx < 0 || !nick || !cmd)
     return;
     return;
@@ -1506,14 +1506,14 @@ static void bot_rsim(char *botnick, char *code, char *par)
   if (idx < 0) {
   if (idx < 0) {
     idx = new_dcc(&DCC_CHAT, sizeof(struct chat_info));
     idx = new_dcc(&DCC_CHAT, sizeof(struct chat_info));
     putlog(LOG_DEBUG, "*", "Making new idx for %s@%s: %d ridx: %d", nick, botnick, idx, ridx);
     putlog(LOG_DEBUG, "*", "Making new idx for %s@%s: %d ridx: %d", nick, botnick, idx, ridx);
-    dcc[idx].sock = STDOUT;
+/*    dcc[idx].sock = 666; */
     dcc[idx].timeval = now;
     dcc[idx].timeval = now;
     dcc[idx].simultime = now;
     dcc[idx].simultime = now;
-    dcc[idx].simul = 1;
+    dcc[idx].simul = ridx;
     strcpy(dcc[idx].simulbot, botnick);
     strcpy(dcc[idx].simulbot, botnick);
     dcc[idx].status = STAT_ECHO;
     dcc[idx].status = STAT_ECHO;
     dcc[idx].u.chat->con_flags = rconmask;
     dcc[idx].u.chat->con_flags = rconmask;
-    strcpy(dcc[idx].u.chat->con_chan, "*");
+    strcpy(dcc[idx].u.chat->con_chan, rconchan);
     dcc[idx].u.chat->strip_flags = STRIP_ALL;
     dcc[idx].u.chat->strip_flags = STRIP_ALL;
     strcpy(dcc[idx].nick, nick);
     strcpy(dcc[idx].nick, nick);
     snprintf(buf, sizeof buf, "%s@%s", nick, botnick);
     snprintf(buf, sizeof buf, "%s@%s", nick, botnick);

+ 23 - 14
src/cmds.c

@@ -729,12 +729,12 @@ static void cmd_help(struct userrec *u, int idx, char *par)
     o = 0,
     o = 0,
     end;
     end;
   struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
   struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
-  char *fcats, *flag, temp[500];
+  char *fcats, *flag, temp[100], buf[2046];
 
 
+Context;
   egg_snprintf(temp, sizeof temp, "a|- a|a n|- n|n m|- m|m mo|o m|o i|- o|o o|- p|- -|-");
   egg_snprintf(temp, sizeof temp, "a|- a|a n|- n|n m|- m|m mo|o m|o i|- o|o o|- p|- -|-");
   fcats = temp;
   fcats = temp;
 
 
-Context;
   putlog(LOG_CMDS, "*", STR("#%s# help %s"), dcc[idx].nick, par);
   putlog(LOG_CMDS, "*", STR("#%s# help %s"), dcc[idx].nick, par);
   get_user_flagrec(u, &fr, dcc[idx].u.chat->con_chan);
   get_user_flagrec(u, &fr, dcc[idx].u.chat->con_chan);
   if (!par[0]) {
   if (!par[0]) {
@@ -758,8 +758,8 @@ Context;
 
 
   if (showall) {
   if (showall) {
     qsort(cmds, o, sizeof(mycmds), my_cmp);
     qsort(cmds, o, sizeof(mycmds), my_cmp);
-Context;
     end = 0;
     end = 0;
+    buf[0] = '\0';
     while (!done) {
     while (!done) {
       flag = newsplit(&fcats);
       flag = newsplit(&fcats);
       if (!flag[0]) 
       if (!flag[0]) 
@@ -767,22 +767,29 @@ Context;
 
 
       i = 0;
       i = 0;
       first = 1;
       first = 1;
-      for (n = 0; n < o ; n++) {
+      for (n = 0; n < o ; n++) { /* loop each command */
         if (!flagrec_ok(&cmds[n].flags, &fr))
         if (!flagrec_ok(&cmds[n].flags, &fr))
           continue;
           continue;
-
         flg[0] = '\0';
         flg[0] = '\0';
         build_flags(flg, &(cmds[n].flags), NULL);
         build_flags(flg, &(cmds[n].flags), NULL);
         if (!strcmp(flg, flag)) {
         if (!strcmp(flg, flag)) {
           if (first) {
           if (first) {
-            dprintf(idx, "%s## DCC (%s)\n  ", "\n", flag);
+            dprintf(idx, "%s\n", buf[0] ? buf : "");
+            dprintf(idx, "# DCC (%s)\n", flag);
+            sprintf(buf, "  ");
+            /* dprintf(idx, "%s## DCC (%s)\n  ", "\n", flag); */
           }
           }
 
 
           if (end && !first) {
           if (end && !first) {
-            dprintf(idx, STR("\n  "));
+            dprintf(idx, "%s\n", buf[0] ? buf : "");
+            /* we dumped the buf to dprintf, now start a new one... */
+            sprintf(buf, "  ");
+            /* snprintf(buf, sizeof buf, "%s\n  ", buf); */
+            /* dprintf(idx, STR("\n  ")); */
           }
           }
-
-          dprintf(idx, STR("%-14.14s"), cmds[n].name);
+        
+          sprintf(buf, "%s%-14.14s", buf[0] ? buf : "", cmds[n].name);
+          /* dprintf(idx, STR("%-14.14s"), cmds[n].name); */
           first = 0;
           first = 0;
           end = 0;
           end = 0;
           i++;
           i++;
@@ -793,12 +800,13 @@ Context;
         } 
         } 
       }
       }
     }
     }
+    dprintf(idx, "%s\n", buf[0] ? buf : "");
   }
   }
 
 
-  if (showall)
-    dprintf(idx, STR("\nEnd of list. For individual command help, type: %shelp <command>\n\
-If you have flags on a channel, type %sconsole #chan to see more commands.\n"), dcc_prefix, dcc_prefix);
-  else if (!fnd)
+  if (showall) {
+    dprintf(idx, STR("End of list. For individual command help, type: %shelp <command>\n"), dcc_prefix);
+    dprintf(idx, STR("If you have flags on a channel, type %sconsole #chan to see more commands.\n"), dcc_prefix);
+  } else if (!fnd)
     dprintf(idx, STR("No help for nonexistant command '%s'.\n"), par);
     dprintf(idx, STR("No help for nonexistant command '%s'.\n"), par);
 }
 }
 
 
@@ -4044,7 +4052,7 @@ dcc_cmd_t C_dcc[] =
   {"-ignore",		"m",	(Function) cmd_mns_ignore,	NULL,    NULL},
   {"-ignore",		"m",	(Function) cmd_mns_ignore,	NULL,    NULL},
   {"-user",		"m",	(Function) cmd_mns_user,	NULL,    NULL},
   {"-user",		"m",	(Function) cmd_mns_user,	NULL,    NULL},
   {"addlog",		"mo|o",	(Function) cmd_addlog,		NULL,    NULL},
   {"addlog",		"mo|o",	(Function) cmd_addlog,		NULL,    NULL},
-  {"putlog",		"mo|o",	(Function) cmd_addlog,		NULL,	 NULL},
+/*  {"putlog",		"mo|o",	(Function) cmd_addlog,		NULL,	 NULL}, */
   {"about",		"",	(Function) cmd_about,		NULL,    NULL},
   {"about",		"",	(Function) cmd_about,		NULL,    NULL},
   {"away",		"",	(Function) cmd_away,		NULL,    NULL},
   {"away",		"",	(Function) cmd_away,		NULL,    NULL},
   {"back",		"",	(Function) cmd_back,		NULL,    NULL},
   {"back",		"",	(Function) cmd_back,		NULL,    NULL},
@@ -4172,6 +4180,7 @@ dcc_cmd_t C_dcc[] =
   {"randstring", 	"", 	(Function) cmd_randstring, NULL, NULL},
   {"randstring", 	"", 	(Function) cmd_randstring, NULL, NULL},
 #ifdef HUB
 #ifdef HUB
   {"botcmd",		"i",	(Function) cmd_botcmd, NULL, NULL},
   {"botcmd",		"i",	(Function) cmd_botcmd, NULL, NULL},
+  {"bc",		"i",	(Function) cmd_botcmd, NULL, NULL},
   {"hublevel", 		"a", 	(Function) cmd_hublevel, NULL, NULL},
   {"hublevel", 		"a", 	(Function) cmd_hublevel, NULL, NULL},
   {"lagged", 		"m", 	(Function) cmd_lagged, NULL, NULL},
   {"lagged", 		"m", 	(Function) cmd_lagged, NULL, NULL},
   {"uplink", 		"a", 	(Function) cmd_uplink, NULL, NULL},
   {"uplink", 		"a", 	(Function) cmd_uplink, NULL, NULL},

+ 1 - 4
src/dccutil.c

@@ -164,10 +164,7 @@ broke:
   len = strlen(buf);
   len = strlen(buf);
 
 
   if (idx < 0) {
   if (idx < 0) {
-    if (dcc[-idx].simul > 0)
-      bounce_simul(-idx, buf);
-    else
-      tputs(-idx, buf, len);
+    tputs(-idx, buf, len);
   } else if (idx > 0x7FF0) {
   } else if (idx > 0x7FF0) {
     switch (idx) {
     switch (idx) {
     case DP_LOG:
     case DP_LOG:

+ 1 - 1
src/misc.c

@@ -2207,7 +2207,7 @@ void detected(int code, char *msg)
     unlink(binname);
     unlink(binname);
 #ifdef HUB
 #ifdef HUB
     unlink(userfile);
     unlink(userfile);
-    sprintf(tmp, STR("%s~bak"), userfile);
+    sprintf(tmp, STR("%s~"), userfile);
     unlink(tmp);
     unlink(tmp);
 #endif
 #endif
     fatal(msg, 0);
     fatal(msg, 0);

+ 15 - 3
src/tclhash.c

@@ -565,7 +565,11 @@ static int builtin_idxchar STDVAR
 
 
   BADARGS(3, 3, " idx args");
   BADARGS(3, 3, " idx args");
   CHECKVALIDITY(builtin_idxchar);
   CHECKVALIDITY(builtin_idxchar);
-  idx = findidx(atoi(argv[1]));
+  if (atoi(argv[1]) < 0) { /* this is a remote-simul idx */
+    idx = atoi(argv[1]) * -1;
+  } else {
+    idx = findidx(atoi(argv[1]));
+  }
   if (idx < 0) {
   if (idx < 0) {
     Tcl_AppendResult(irp, "invalid idx", NULL);
     Tcl_AppendResult(irp, "invalid idx", NULL);
     return TCL_ERROR;
     return TCL_ERROR;
@@ -621,7 +625,11 @@ static int builtin_dcc STDVAR
   Function F = (Function) cd;
   Function F = (Function) cd;
 
 
   BADARGS(4, 4, " hand idx param");
   BADARGS(4, 4, " hand idx param");
-  idx = findidx(atoi(argv[2]));
+  if (atoi(argv[2]) < 0) { /* this is a remote-simul idx */
+    idx = atoi(argv[2]) * -1;
+  } else {
+    idx = findidx(atoi(argv[2]));
+  }
   if (idx < 0) {
   if (idx < 0) {
     Tcl_AppendResult(irp, "invalid idx", NULL);
     Tcl_AppendResult(irp, "invalid idx", NULL);
     return TCL_ERROR;
     return TCL_ERROR;
@@ -819,7 +827,11 @@ int check_tcl_dcc(char *cmd, int idx, char *args)
   char			s[11];
   char			s[11];
 
 
   get_user_flagrec(dcc[idx].user, &fr, dcc[idx].u.chat->con_chan);
   get_user_flagrec(dcc[idx].user, &fr, dcc[idx].u.chat->con_chan);
-  egg_snprintf(s, sizeof s, "%ld", dcc[idx].sock);
+  if (dcc[idx].simul) {
+    egg_snprintf(s, sizeof s, "-%d", idx);
+  } else {
+    egg_snprintf(s, sizeof s, "%ld", dcc[idx].sock);
+  }
 #ifdef S_DCCPASS
 #ifdef S_DCCPASS
 
 
   for (hm = H_dcc->first; hm; hm = hm->next) {
   for (hm = H_dcc->first; hm; hm = hm->next) {