Skip to content

Instantly share code, notes, and snippets.

@lcharette
Last active December 14, 2015 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lcharette/5095452 to your computer and use it in GitHub Desktop.
Save lcharette/5095452 to your computer and use it in GitHub Desktop.
Ape.registerCmd("channelsUserNb", false, function(params, infos) {
//Object to be returned
var reponse = new Object;
//List of channel, as an Array
var channelList = params.channelList;
//We loop for every channel in the Array
for (x in channelList)
{
//Setup the counter to start at zero (O rly?)
var i = 0;
//Get the channel obj
var chan = Ape.getChannelByName(channelList[x]);
//If the channel doesn't exist, we skip
if ($defined(chan)) {
//We calculate how many user on the channel (Lenght could be used maybe?)
chan.userslist.each(function(user) {
i++;
});
}
//Add to the return and
reponse[listeChannels[x]] = i;
}
//Return to InlinePush
return {"name":"pushed","data":{"value":"ok", "reponse":reponse}};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment