added cmd_info peek time info
authorpk910 <philipp@zoelle1.de>
Thu, 7 Jul 2011 18:42:12 +0000 (20:42 +0200)
committerpk910 <philipp@zoelle1.de>
Thu, 7 Jul 2011 18:42:12 +0000 (20:42 +0200)
src/chanserv.c
src/chanserv.h

index 0a8faccdb31985fcc9dd72642960db8e8aac9254..130e8298d0dea5dc6d447b0454589828587e8ef3 100644 (file)
 #define KEY_USERS           "users"
 #define KEY_BANS            "bans"
 #define KEY_MAX             "max"
+#define KEY_MAX_TIME        "max_time"
 #define KEY_NOTES           "notes"
 #define KEY_TOPIC_MASK      "topic_mask"
 #define KEY_OWNER_TRANSFER  "owner_transfer"
@@ -386,6 +387,7 @@ static const struct message_entry msgtab[] = {
     { "CSMSG_CHANNEL_MODES", "$bMode Lock:           $b%s" },
     { "CSMSG_CHANNEL_NOTE", "$b%s:%*s$b%s" },
     { "CSMSG_CHANNEL_MAX", "$bRecord Visitors:     $b%i" },
+    { "CSMSG_CHANNEL_MAX_TIME", "$bRecord Visitors:     $b%i (%s ago.)" },
     { "CSMSG_CHANNEL_OWNER", "$bOwner:               $b%s" },
     { "CSMSG_CHANNEL_BANS", "$bBan Count:           $b%i" },
     { "CSMSG_CHANNEL_USERS", "$bTotal User Count:    $b%i" },
@@ -2110,6 +2112,7 @@ static CHANSERV_FUNC(cmd_register)
 
     /* Initialize the channel's max user record. */
     cData->max = channel->members.used;
+    cData->max_time = 0;
 
     if(handle != user->handle_info)
         reply("CSMSG_PROXY_SUCCESS", handle->handle, channel->name);
@@ -2501,8 +2504,10 @@ merge_data(struct chanData *source, struct chanData *target)
         target->ownerTransfer = source->ownerTransfer;
     if(source->may_opchan)
         target->may_opchan = 1;
-    if(source->max > target->max)
+    if(source->max > target->max) {
         target->max = source->max;
+        target->max_time = source->max_time;
+    }
 }
 
 static void
@@ -4473,7 +4478,11 @@ static CHANSERV_FUNC(cmd_info)
         reply("CSMSG_CHANNEL_NOTE", iter_key(it), padding > 0 ? padding : 1, "", note->note);
     }
 
-    reply("CSMSG_CHANNEL_MAX", cData->max);
+    if(cData->max_time) {
+        reply("CSMSG_CHANNEL_MAX_TIME", cData->max, intervalString(buffer, now - cData->max_time, user->handle_info));
+    } else {
+        reply("CSMSG_CHANNEL_MAX", cData->max);
+    }
     for(owner = cData->users; owner; owner = owner->next)
         if(owner->access == UL_OWNER)
             reply("CSMSG_CHANNEL_OWNER", owner->handle->handle);
@@ -6530,8 +6539,10 @@ handle_join(struct modeNode *mNode)
         return 0;
 
     cData = channel->channel_info;
-    if(channel->members.used > cData->max)
+    if(channel->members.used > cData->max) {
         cData->max = channel->members.used;
+        cData->max_time = now;
+    }
 
     for(i = 0; i < channel->invited.used; i++)
     {
@@ -7493,6 +7504,8 @@ chanserv_channel_read(const char *key, struct record_data *hir)
     cData->ownerTransfer = str ? strtoul(str, NULL, 0) : 0;
     str = database_get_data(channel, KEY_MAX, RECDB_QSTRING);
     cData->max = str ? atoi(str) : 0;
+    str = database_get_data(channel, KEY_MAX_TIME, RECDB_QSTRING);
+    cData->max_time = str ? atoi(str) : 0;
     str = database_get_data(channel, KEY_GREETING, RECDB_QSTRING);
     cData->greeting = str ? strdup(str) : NULL;
     str = database_get_data(channel, KEY_USER_GREETING, RECDB_QSTRING);
@@ -7688,6 +7701,7 @@ chanserv_write_channel(struct saxdb_context *ctx, struct chanData *channel)
 
     saxdb_write_int(ctx, KEY_REGISTERED, channel->registered);
     saxdb_write_int(ctx, KEY_MAX, channel->max);
+    saxdb_write_int(ctx, KEY_MAX_TIME, channel->max_time);
     if(channel->topic)
         saxdb_write_string(ctx, KEY_TOPIC, channel->topic);
     if(channel->registrar)
index 8b7edf382118267f5c03e680a2cf14a8ceb76cad..9a7b08e140f3b16a78c7520542fb8a785015dcab 100644 (file)
@@ -93,6 +93,7 @@ struct chanData
     unsigned int        flags : 30;
     unsigned int        may_opchan : 1;
     unsigned int        max;
+    unsigned int        max_time;
     unsigned int        last_refresh;
     unsigned short      banCount;
     unsigned short      userCount;