13

Here's the situation: I'm investigating a user's behaviour in a couple of chat rooms because I find the overall patterns concerning, and may need to direct some official attention their way discreetly. They haven't spoken there often, and I suspect a high % of their activity will be of interest.

Is there some way I can find the various instances of someone's activity in a room? Either their messages, or the days on which they have spoken, would be useful.

The best I can think of is to open up the Transcript and search it for very common words, but "the" turns up no results, and "you" isn't picking up much. I also tried Google ({username} site:chat.stackexchange.com/transcript/{roomnumber}), but that digs up a lot of false positives, and doesn't turn up incidents I know are there (I was there for them).

  • 1
    If only one could search for the wildcard q=* in http://chat.stackexchange.com/search?q=*&user=<usernum>&room=<roomnum>... – Werner Feb 4 '16 at 6:02
11

There is a way to see all messages in all rooms on the same chat server:

  1. Go to the user's chat profile, e.g. this one.
  2. Click the "recent" link:

    enter image description here

    You will see the last 50 messages by that user, in all rooms, with the room details to the left.

  3. Though there is no UI for paging, such paging exists, you'll just have to manually change the URL by appending &page=[page] to see the various pages. E.g. change http://chat.meta.stackexchange.com/users/152515/doppelgreener?tab=recent to http://chat.meta.stackexchange.com/users/152515/doppelgreener?tab=recent&page=2 to see the second page with the next 50 messages, etc.
8

If you're not afraid of running a userscript from your webbrowser console you can use the following script:

(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()),
        userid = 282866, // berserk
        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,
                event;
            for (i = 0; i < eve.events.length; i = i + 1) {
                event = eve.events[i];
                eventDate = new Date(event.time_stamp * MS);
                // time_stamp is now a real Date
                if (eventDate >= date) {
                    if (event.user_id === userid) {
                        // log all content!
                        console.log(event.content);
                    }
                } else {
                    // we reached our date...
                    // but keep processing....
                    next = false;
                }
            }
            if (next){
                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');
        }
    });
}());

You simply login on your favorite chat server, find the room number you're interested in (in the example it is room 721), set a start start date and the userid of the user you're investigating. Set the endDate in the enddate.setDate call and your all set to hit enter.

The console.log(event.content); will output all messages from that user in the browser console. You can change the boolean logic preceding that statement to only output lines you're interested in.

Beyond this your next option is writing a transcript scraper so you get all messages in your own database but that is a little bit more work and left for another answerer.

  • This doesn't seem to work anymore. I tried it and it gives me a 500 server error on /chats/[room ID]/events. – Sonic the Inclusive Hedgehog Mar 5 at 8:10
  • @SonictheWizardWerehog are you logged in and do you have a valid fkey on the chat page? – rene Mar 5 at 8:53

You must log in to answer this question.

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