Explorar o código

* Remove %{hub/leaf} from misc.txt
* Added more parsing to showhelp()
* Increased the buffer in stringfix, I think it's a bit excessive though :\


svn: 446

Bryan Drewery %!s(int64=22) %!d(string=hai) anos
pai
achega
0609df0396
Modificáronse 3 ficheiros con 69 adicións e 26 borrados
  1. 12 12
      misc/help.txt
  2. 56 13
      src/misc.c
  3. 1 1
      src/stringfix.c

+ 12 - 12
misc/help.txt

@@ -59,7 +59,7 @@ See also: -noteign noteigns
    Creates a new user record for the handle given. The new user record will
    have no flags, an optional hostmask, and a random pass/secpass.
  
-See also: -user, +host, -host%(hub)%{+n}, newleaf
+See also: -user, +host, -host%{+ni}, newleaf
 ::-ban
 ###  %b-ban%b <banmask or number> [channel]
    Removes the specified ban from the list of bans stored on the bot. You may
@@ -129,7 +129,7 @@ See also: +noteign noteigns
 ###  %b-user%b <handle>
    Removes the specified handle's user record.
  
-See also: +user%(hub)%{+a}, -bot%{+n}, newleaf
+See also: +user%{+ai}, -bot%{+n}, newleaf
 ::about:
 ###  %babout%b
    If you feel you are missing from the list feel free to contact bryan.
@@ -653,7 +653,7 @@ See also: chhandle, chpass
    color codes in mIRC format using ^K^B, etc.. while ANSI will use escape
    chars to generate the color output.
  
-See also: echo, page
+See also: echo, page, strip
 ::comment
 ###  %bcomment%b <user> <comment>
    Creates or changes the comment field for a user. The comment field can only
@@ -842,7 +842,7 @@ See also: bots
    then when you say something on the party line, it will be displayed to you
    just like everyone else will see it. If it's off, then it won't happen.
  
-See also: color, page
+See also: color, page, strip
 ::exec:
 ###  %bexec%b <params>
    The bot will execute the specified program with each param specified,
@@ -918,7 +918,7 @@ See also: console, channels%{+m}, status
    bot will know you as from this point forward. It is used to log into the
    bot.
  
-See also: newpass%{+m}, %(hub)chhand, chpass%{+n}, chsecpass
+See also: newpass%{+m}, %{+i}chhand, chpass%{+n}, chsecpass
 ::help:
 ###  %bhelp%b [cmd]
    Alone, will show all cmds that match your flags. With a cmd it will show
@@ -1070,7 +1070,7 @@ See also: netlag
    Displays the 'last' output from the shell the bot is running on,
    for the user it is running as.
  
-%{hub}See also: netlast
+%{+i}See also: netlast
 :hub:link
 ###  %blink%b [via-bot] <bot-to-link>
    Attempts to link to another hub.  This command is deprecated and not 
@@ -1182,7 +1182,7 @@ See also: last
 ###  %bnetmsg%b <nickname|#chan> <text>
    All bots on the botnet will send a msg to the specified target.
  
-See also: botmsg%{leaf}, msg
+See also: botmsg, msg
 ::netnick:
 ###  %bnetnick%b 
    All bots on the botnet will display their nick over DCC.
@@ -1228,7 +1228,7 @@ See also: w
    newpassword is 'rand', a random password will be used.
  
  
-%(hub)%{+m}See also: chpass%{+n}, chsecpass
+%{+mi}See also: chpass%{+n}, chsecpass
 ::nick
 See: handle
 ::note
@@ -1280,7 +1280,7 @@ See also: echo, color
    Will run 'ps' on the bot's shell and display any results. If
    any params are specified, they will be used.
  
-%{hub}See also: netps
+%{+i}See also: netps
 ::quit
 ###  %bquit%b [comment]
    This disconnects you from the partyline. If you specify a comment, it will
@@ -1355,7 +1355,7 @@ See also: reload, backup
    Changes your secpass on the bot. This is used for Authing via /msg
    and for DCC. If the password is 'rand', a random password will be used.
  
-%(hub)%{+m}See also: chpass%{+n}, chsecpass
+%{+mi}See also: chpass%{+n}, chsecpass
 :leaf:servers
 ###  %bservers%b
    lists the servers that the bot has in its server list.  this is
@@ -1449,7 +1449,7 @@ See also: console
    The mode can also be a modifier like '+c' or '-bu' or '+ru-c'. If
    you omit modes, it will show your current setting.
  
-See also: fixcodes, color, echo
+See also: fixcodes, color, echo, page
 %{+m}
 ###  %bstrip%b <user> [modes]
    Set the strip level of another user. A master can't set their own strip
@@ -1536,7 +1536,7 @@ See also: devoice
    The output of 'w' will be displayed over DCC, bot the shell
    the bot is running on.
  
-%{hub}See also: netw
+%{+i}See also: netw
 ::who
 ###  %bwho%b [bot]
    Displays a list of users on the local bot.

+ 56 - 13
src/misc.c

@@ -43,7 +43,7 @@ extern tand_t 		*tandbot;
 
 extern char		 version[], origbotname[], botname[],
 			 admin[], network[], motdfile[], ver[], botnetnick[],
-			 bannerfile[], textdir[], userfile[],  
+			 bannerfile[], textdir[], userfile[], dcc_prefix[],
                          *binname, pid_file[], tempdir[];
 
 extern int		 backgrd, con_chan, term_z, use_stderr, dcc_total, timesync, sdebug, 
@@ -2059,21 +2059,29 @@ char *btoh(const unsigned char *md, int len)
   return ret;
 }
 
+#define HELP_BOLD  1
+#define HELP_REV   2
+#define HELP_UNDER 4
+#define HELP_FLASH 8
+#define HELP_IRC   16
+
 void showhelp (int idx, struct flag_record *flags, char *string)
 {
+  static int help_flags;
   struct flag_record tr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
   static char helpstr[8092] = "", tmp[2] = "", flagstr[10] = "";
   int ok = 1;
+  if (!help_flags) help_flags = (dcc[idx].status & STAT_TELNET) ? 0 : HELP_IRC;
 Context;
   helpstr[0] = 0;
-  while ( (string) && (string[0]) ) {
-    if ( (*string == '%') ) {
-      if ( !strncmp(string + 1, "{+", 2) ) {
-        while ( (*string) && (*string != '+') ) {
+  while ((string) && (string[0])) {
+    if ((*string == '%')) {
+      if (!strncmp(string + 1, "{+", 2)) {
+        while ((*string) && (*string != '+')) {
           string++;
         }
         flagstr[0] = 0;
-        while ( (*string) && (*string != '}') ) {
+        while ((*string) && (*string != '}')) {
           sprintf(tmp, "%c", *string);
           strcat(flagstr, tmp);
           string++;
@@ -2082,14 +2090,14 @@ Context;
         break_down_flags(flagstr, &tr, NULL);
         if (flagrec_ok(&tr, flags)) {
           ok = 1;
-          while ( (*string) && (*string != '%') ) {
+          while ((*string) && (*string != '%')) {
             sprintf(tmp, "%c", *string);
             strcat(helpstr, tmp);
             string++;
           }
-          if ( !strncmp(string + 1, "{-", 2) ) {
+          if (!strncmp(string + 1, "{-", 2)) {
             ok = 1;
-            while ( (*string) && (*string != '}') ) {
+            while ((*string) && (*string != '}')) {
               string++;
             }
           }
@@ -2097,16 +2105,51 @@ Context;
         } else {
           ok = 0;
         }
-      } else if ( !strncmp(string + 1, "{-", 2) ) {
+      } else if (!strncmp(string + 1, "{-", 2)) {
         ok = 1;
-        while ( (*string) && (*string != '}') ) {
+        while ((*string) && (*string != '}')) {
           string++;
         }
         string++;
-      } else if ( (*string == '{') ) {
-        while ( (*string) && (*string != '}') ) {
+      } else if (*string == '{') {
+        while ((*string) && (*string != '}')) {
           string++;
         }
+      } else if (*(string + 1) == 'b') {
+        string += 2;
+        if (help_flags & HELP_IRC) {
+          sprintf(tmp, "\002");
+        } else if (help_flags & HELP_BOLD) {
+          help_flags &= ~HELP_BOLD;
+         sprintf(tmp, "\033[0m");
+        } else {
+          help_flags |= HELP_BOLD;
+          sprintf(tmp, "\033[1m");
+        }
+        strcat(helpstr, tmp);
+      } else if (*(string + 1) == 'f') {
+        string += 2;
+        
+        if (help_flags & HELP_FLASH) {
+          if (help_flags & HELP_IRC)
+            sprintf(tmp, "\002\037");
+          else
+            sprintf(tmp, "\033[0m");
+          help_flags &= ~HELP_FLASH;
+        } else {
+          help_flags |= HELP_FLASH;
+          if (help_flags & HELP_IRC)
+            sprintf(tmp, "\002\037");
+          else
+            sprintf(tmp, "\033[5m");
+        }
+        strcat(helpstr, tmp);
+      } else if (*(string + 1) == 'd') {
+        string += 2;
+        strcat(helpstr, dcc_prefix);        
+      } else if (*(string + 1) == '%') {
+        string += 2;
+        strcat(helpstr, "%");        
       } else {
         if (ok) {
           sprintf(tmp, "%c", *string);

+ 1 - 1
src/stringfix.c

@@ -9,7 +9,7 @@
 #include <string.h>
 #include "conf.h"
 
-#define WTF 16384
+#define WTF 50720
 int help = 0;
 #ifdef S_GARBLESTRINGS
 void garble(char **inptr, char **outptr)