3

I'm wondering if there is a number displayed somewhere where I can see the exact amount of messages for a given day for a given chatroom?

3

There isn't any such number displayed.

You can use the following script (drop it in the dev console of your favorite browser (tested on Chrome)) when you are logged in any of the chat servers of Stack Exchange to fetch the events for a specific chatroom and count the number of days.

(function () {
    "use strict";

    var room = 721, // http://chat.meta.stackexchange.com/rooms/721/shadows-den
        // Yes, month is zero based... day isn't :(
        date = new Date(2015, 9, 1), // 0 = Jan, 1 = Feb ... 11 = Dec
        enddate = new Date(date.valueOf()),
        url = ['/chats', room, 'events'].join('/'),
        totalCount = 0,
        MS = 1000, // miliseconds
        baseYear = 1900,
        msgCountMax = 500;

    enddate.setDate(enddate.getDate() + 1);

    function loadEvents(before) {
        // data to post
        var data = {
            mode: 'Messages',
            before: before, // before this message id
            msgCount: msgCountMax, // we never get more ...
            fkey: fkey().fkey
        };
        $.post(url, data).success(function (eve) {
            var i,
                eventDate,
                next = true;
            for (i = 0; i < eve.events.length; i = i + 1) {
                eventDate = new Date(eve.events[i].time_stamp * MS);
                // time_stamp is now a real Date
                console.log(eventDate);
                if (eventDate >= date) {
                    // count if between low and upper mark date
                    if (eventDate >= date && eventDate < enddate) {
                        totalCount = totalCount + 1;
                    }
                } else {
                    // we reached our date...
                    // but keep processing....
                    next = false;
                }
            }
            if (!next) {
                console.log('total messages:' + totalCount);
            } else {
                loadEvents(eve.events[0].message_id);
            }
        }).fail(function () {
            console.log('fail!');
        });
    }

    // get the enddate full chat transscript
    $.get([
        '/transcript',
        room,
        baseYear + enddate.getYear(),
        enddate.getMonth() + 1, /* hate JavaScript*/
        enddate.getDate()].join('/'), function (html) {
        var $messages = $(html).find('.message[id^="message-"]');
        // if those have messages ...
        if ($messages.length > 0) {
            // get the first message id to start loading events before that id
            loadEvents(parseInt($messages[0].id.replace('message-', ''), 10 /* base 10 */));
        } else {
            // 0 messages 
            console.log('total messages: 0');
        }
    });
}());

If this exact script is run the output in the console will be:

Wed Sep 30 2015 14:37:29 GMT+0200 (W. Europe Daylight Time)
Wed Sep 30 2015 14:37:38 GMT+0200 (W. Europe Daylight Time) 
.... many more datetimes ...
Thu Oct 01 2015 21:48:44 GMT+0200 (W. Europe Daylight Time)
Thu Oct 01 2015 22:03:21 GMT+0200 (W. Europe Daylight Time)
total messages:325

Which would mean that there were 325 messages posted in chatroom 721 on Oct, 1st, 2015.

  • I see you extend your powers from SEDE to the API, nice! – Shadow Wizard is Ear For You Oct 3 '15 at 15:51
  • Not really the API @ShadowWizard, just a nasty reverse engineering hack...but thanks for providing a chatroom with enough datapoints to test ;) – rene Oct 3 '15 at 16:27
  • My pleasure! ;) – Shadow Wizard is Ear For You Oct 3 '15 at 16:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .