src/parse.c
changeset 19 66114d944208
parent 18 4435146391ae
child 21 138537d81dd1
equal deleted inserted replaced
18:4435146391ae 19:66114d944208
    41 #define     WHO 15
    41 #define     WHO 15
    42 #define   WHOIS 16
    42 #define   WHOIS 16
    43 #define    TIME 17
    43 #define    TIME 17
    44 #define    TELL 18
    44 #define    TELL 18
    45 #define      OP 19
    45 #define      OP 19
       
    46 #define    DEOP 20
       
    47 #define    KICK 21
       
    48 #define     BAN 22
       
    49 #define   UNBAN 23
       
    50 #define KICKBAN 24
    46 
    51 
    47 const
    52 const
    48 char *COMMAND_LIST[] = {
    53 char *COMMAND_LIST[] = {
    49     "help      Known Commands: join(1), leave(2), add(3), replace(4), delete(5), list(6), search(7), info(8)\r\n",
    54     "help      Known Commands: join(1), leave(2), add(3), replace(4), delete(5), list(6), search(7), info(8)\r\n",
    50     "join:     Joins a new channel\r\n",
    55     "join:     Joins a new channel\r\n",
    72     "!help", "!join", "!leave",
    77     "!help", "!join", "!leave",
    73     "!add", "!replace", "!delete",
    78     "!add", "!replace", "!delete",
    74     "!list", "!search", "!info",
    79     "!list", "!search", "!info",
    75     "!ping", "!on", "!off",
    80     "!ping", "!on", "!off",
    76     "!debug", "!vaccuum", "!logout",
    81     "!debug", "!vaccuum", "!logout",
    77     "!who", "!whois", "!time", "!tell",
    82     "!who", "!whois", "!time",
    78     "!op", NULL
    83     "!tell", "!op", "!deop",
       
    84     "!kick", "!ban", "!unban",
       
    85     "!kickban",
       
    86     NULL
    79 };
    87 };
    80 
    88 
    81 char *parse (MSG * message)
    89 char *parse (MSG * message)
    82 {
    90 {
    83     static char msg[513];
    91     static char msg[513];
   282                 if ((token = strtok (NULL, "\r\n")) != NULL) {
   290                 if ((token = strtok (NULL, "\r\n")) != NULL) {
   283                     if (strstr (message->email, db_lookup (DATABASE_FILE, "mcbot.email")))
   291                     if (strstr (message->email, db_lookup (DATABASE_FILE, "mcbot.email")))
   284                         snprintf (msg, 512, "MODE %s +o %s\r\n", message->channel, token);
   292                         snprintf (msg, 512, "MODE %s +o %s\r\n", message->channel, token);
   285                 }
   293                 }
   286                 return msg;
   294                 return msg;
       
   295 
       
   296             case DEOP:
       
   297                 if ((token = strtok (NULL, "\r\n")) != NULL) {
       
   298                     if (strstr (message->email, db_lookup (DATABASE_FILE, "mcbot.email")))
       
   299                         snprintf (msg, 512, "MODE %s -o %s\r\n", message->channel, token);
       
   300                 }
       
   301                 return msg;
       
   302 
       
   303             case KICK:
       
   304                 if ((token = strtok (NULL, "\r\n")) != NULL) {
       
   305                     if (strstr (message->email, db_lookup (DATABASE_FILE, "mcbot.email")))
       
   306                         snprintf (msg, 512, "KICK %s %s\r\n", message->channel, token);
       
   307                 }
       
   308                 return msg;
       
   309 
       
   310             case BAN:
       
   311                 if ((token = strtok (NULL, "\r\n")) != NULL) {
       
   312                     if (strstr (message->email, db_lookup (DATABASE_FILE, "mcbot.email")))
       
   313                         snprintf (msg, 512, "MODE %s +b %s\r\n", message->channel, token);
       
   314                 }
       
   315                 return msg;
       
   316 
       
   317             case UNBAN:
       
   318                 if ((token = strtok (NULL, "\r\n")) != NULL) {
       
   319                     if (strstr (message->email, db_lookup (DATABASE_FILE, "mcbot.email")))
       
   320                         snprintf (msg, 512, "MODE %s -b %s\r\n", message->channel, token);
       
   321                 }
       
   322                 return msg;
       
   323 
       
   324             case KICKBAN:
       
   325                 if ((token = strtok (NULL, "\r\n")) != NULL) {
       
   326                     if (strstr (message->email, db_lookup (DATABASE_FILE, "mcbot.email")))
       
   327                         snprintf (msg, 512, "MODE %s +b %s\r\nKICK %s %s\r\n", message->channel, token,
       
   328                                   message->channel, token);
       
   329                 }
       
   330                 return msg;
   287             }
   331             }
   288         }
   332         }
   289         i++;
   333         i++;
   290     }
   334     }
   291 
   335