changed Makefile; build all commands as an own file
[NeonServV5.git] / cmd_neonserv_events.c
index 30cc68ef46beaf7249c27820fc039f912b077c50..23ecf3cf90103f4bf533503e1030c6e52a0be3a0 100644 (file)
@@ -1,16 +1,19 @@
 
+#include "cmd_neonserv.h"
+
 /*
 * argv[0]     time
 * argv[1-*]   match
 */
 
-static CMD_BIND(neonserv_cmd_events) {
+CMD_BIND(neonserv_cmd_events) {
     char *str_match;
-    int duration = (argc ? strToTime(user, argv[0]) : (60*60*24));
-    if(argc)
+    int duration = (argc ? strToTime(user, argv[0]) : 0);
+    if(argc > (duration ? 1 : 0))
         str_match = merge_argv(argv, (duration ? 1 : 0), argc);
     else
-        str_match = "*";
+        str_match = "";
+    if(!duration) duration = (60*60*24);
     MYSQL_RES *res;
     MYSQL_ROW row;
     printf_mysql_query("SELECT `time`, `auth`, `nick`, `command` FROM `events` WHERE `cid` = '%d' AND `time` > '%lu' ORDER BY `time` ASC", chan->channel_id, ((unsigned long) time(0) - duration));
@@ -27,7 +30,7 @@ static CMD_BIND(neonserv_cmd_events) {
             skip--;
             continue;
         }
-        if(match(str_match, row[3])) continue;
+        if(*str_match && match(str_match, row[3])) continue;
         count++;
         event_time = (time_t) atol(row[0]);
         timeinfo = localtime(&event_time);