added new multi log system
[NeonServV5.git] / src / modules / NeonServ.mod / cmd_neonserv_addtimeban.c
index 837812e8e856e6264316c95ddd928bc83d815395..2e096f9584dc86f56ba747ee44788e4103b9240e 100644 (file)
@@ -1,4 +1,4 @@
-/* cmd_neonserv_addtimeban.c - NeonServ v5.3
+/* cmd_neonserv_addtimeban.c - NeonServ v5.6
  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
  * 
  * This program is free software: you can redistribute it and/or modify
@@ -37,16 +37,16 @@ struct neonserv_cmd_addtimeban_cache {
 CMD_BIND(neonserv_cmd_addtimeban) {
     int duration = strToTime(user, argv[1]);
     if(duration < 5) {
-        reply(getTextBot(), user, "NS_TIMEBAN_DURATION_TOO_SHORT", 5);
+        reply(textclient, user, "NS_TIMEBAN_DURATION_TOO_SHORT", 5);
         return;
     }
     struct neonserv_cmd_addtimeban_cache *cache = malloc(sizeof(*cache));
     if (!cache) {
-        perror("malloc() failed");
+        printf_log("neonserv", LOG_ERROR, "%s:%d malloc() failed", __FILE__, __LINE__);
         return;
     }
     cache->client = client;
-    cache->textclient = getTextBot();
+    cache->textclient = textclient;
     cache->user = user;
     cache->event = event;
     cache->mask = strdup(argv[0]);
@@ -55,7 +55,7 @@ CMD_BIND(neonserv_cmd_addtimeban) {
         cache->reason = strdup(merge_argv(argv, 2, argc));
     } else
         cache->reason = NULL;
-    get_userlist(chan, neonserv_cmd_addtimeban_userlist_lookup, cache);
+    get_userlist(chan, module_id, neonserv_cmd_addtimeban_userlist_lookup, cache);
 }
 
 static USERLIST_CALLBACK(neonserv_cmd_addtimeban_userlist_lookup) {
@@ -129,10 +129,12 @@ static void neonserv_cmd_addtimeban_async1(struct ClientSocket *client, struct C
         }
     }
     char nameBuf[MAXLEN];
-    char banidBuf[20];
-    sprintf(nameBuf, "ban_%d", banid);
-    sprintf(banidBuf, "%d", banid);
-    timeq_add_name(nameBuf, duration, channel_ban_timeout, strdup(banidBuf));
+    if(duration < 86400*7) {
+        char banidBuf[20];
+        sprintf(nameBuf, "ban_%d", banid);
+        sprintf(banidBuf, "%d", banid);
+        timeq_add_name(nameBuf, duration, module_id, channel_ban_timeout, strdup(banidBuf));
+    }
     reply(textclient, user, "NS_TIMEBAN_DONE", mask, chan->name, timeToStr(user, duration, 2, nameBuf), match_count);
     logEvent(event);
 }