Is there some way to see all of a user's messages in a chat room?

by doppelgreener   Last Updated April 15, 2019 07:24 AM - source

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).



Answers 3


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.

rene
rene
February 04, 2016 14:49 PM

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.
Shadow Wizard
Shadow Wizard
February 04, 2016 15:49 PM

enter image description hereenter image description here

Rodney Lansing
Rodney Lansing
April 15, 2019 07:14 AM

Related Questions




Reply to a message from transcript

Updated February 24, 2016 01:10 AM

Obtaining full chat transcripts

Updated May 14, 2016 08:10 AM