Created
December 18, 2015 05:44
-
-
Save Tiny-Giant/db5476b7ff159d01ade7 to your computer and use it in GitHub Desktop.
Retrieves a variable number of events from the chat transcript.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*************************************************** | |
* GetChatEvents * | |
* You can only retrieve a maximum of 500 messages * | |
* from the transcript at one time, so you have to * | |
* search recursively. * | |
***************************************************/ | |
var events = []; | |
function GetChatEvents(count, callback, before) { | |
if (count <= 0) return callback(events), false; | |
var data = { | |
fkey: fkey, | |
msgCount: count > 500 ? 500 : count, | |
mode: 'Messages', | |
}; | |
if (before) data.before = before; | |
$.ajax({ | |
type: 'POST', | |
url: '/chats/' + room + '/events', | |
data: data, | |
success: function(response) { | |
events.push(response.events); | |
GetChatEvents(count - 500, callback, response.events[0].message_id); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment