src/parse.c
changeset 40 5b7e8dba46a0
parent 39 0ae006af497e
child 45 535478a0f482
equal deleted inserted replaced
39:0ae006af497e 40:5b7e8dba46a0
    24 #define SOURCE_URL "http://largo.homelinux.org/cgi-bin/gitweb.cgi?p=net/mcbot.git"
    24 #define SOURCE_URL "http://largo.homelinux.org/cgi-bin/gitweb.cgi?p=net/mcbot.git"
    25 #endif
    25 #endif
    26 
    26 
    27 enum command_map {
    27 enum command_map {
    28     HELP, JOIN, LEAVE, ADD, REPLACE, DELETE, LIST, SEARCH, INFO, PING, ON, OFF, DEBUG,
    28     HELP, JOIN, LEAVE, ADD, REPLACE, DELETE, LIST, SEARCH, INFO, PING, ON, OFF, DEBUG,
    29     VACCUUM, LOGOUT, WHO, WHOIS, TIME, TELL, OP, DEOP, KICK, BAN, UNBAN, KICKBAN, HELLO
    29     VACCUUM, LOGOUT, WHO, WHOIS, TIME, TELL, OP, DEOP, KICK, BAN, UNBAN, KICKBAN, HELLO,
       
    30     TOPIC,
    30 };
    31 };
    31 
    32 
    32 const
    33 const
    33 char *COMMAND_LIST[] = {
    34 char *COMMAND_LIST[] = {
    34     "help      Known Commands: join(1), leave(2), add(3), replace(4), delete(5), list(6), search(7), info(8)\r\n",
    35     "help      Known Commands: join(1), leave(2), add(3), replace(4), delete(5), list(6), search(7), info(8)\r\n",
    44     "on        enables autolearning mode\r\n",
    45     "on        enables autolearning mode\r\n",
    45     "off       disables autolearning\r\n",
    46     "off       disables autolearning\r\n",
    46     "debug     prints some debug infos\r\n",
    47     "debug     prints some debug infos\r\n",
    47     "vaccuum   reorganizes the database\r\n",
    48     "vaccuum   reorganizes the database\r\n",
    48     "logout    Protected logout function\r\n",
    49     "logout    Protected logout function\r\n",
       
    50     "topic     Sets a new topic\r\n",
    49     NULL,
    51     NULL,
    50 };
    52 };
    51 
    53 
    52 const
    54 const
    53 char VISIBLE_ITEMS = 14;
    55 char VISIBLE_ITEMS = 14;
    60     "!ping", "!on", "!off",
    62     "!ping", "!on", "!off",
    61     "!debug", "!vaccuum", "!logout",
    63     "!debug", "!vaccuum", "!logout",
    62     "!who", "!whois", "!time",
    64     "!who", "!whois", "!time",
    63     "!tell", "!op", "!deop",
    65     "!tell", "!op", "!deop",
    64     "!kick", "!ban", "!unban",
    66     "!kick", "!ban", "!unban",
    65     "!kickban", "!hello",
    67     "!kickban", "!hello", "!topic",
    66     NULL
    68     NULL
    67 };
    69 };
    68 
    70 
    69 char *parse (MSG * message)
    71 char *parse (MSG * message)
    70 {
    72 {
   309 
   311 
   310             case HELLO:
   312             case HELLO:
   311                 snprintf (msg, sizeof (msg), "PRIVMSG %s :%s, %s?\r\n", message->channel, gettext ("What's up"),
   313                 snprintf (msg, sizeof (msg), "PRIVMSG %s :%s, %s?\r\n", message->channel, gettext ("What's up"),
   312                           message->user);
   314                           message->user);
   313                 return msg;
   315                 return msg;
       
   316 
       
   317             case TOPIC:
       
   318                 if ((token = strtok (NULL, "\r\n")) == NULL)
       
   319                     return NULL;
       
   320 
       
   321                 snprintf (msg, sizeof (msg), "TOPIC %s :%s\r\n", message->channel, token);
       
   322                 return msg;
   314             }
   323             }
   315         }
   324         }
   316         map++;
   325         map++;
   317     }
   326     }
   318 
   327