Random Group Tag Activator
From SmartBots Developers Docs
Revision as of 18:51, 13 July 2016 by Gg (Talk | contribs) (Created page with "{{DISPLAYTITLE:{{SUBPAGENAME}}}} The following code requests the groups list using listGroups(), selects the very first group and activa...")
The following code requests the groups list using listGroups(), selects the very first group and activates it using activateGroup():
Bot.listGroups()
.then(function(result) {
// We don't use Object.keys() below because it is was not
// supported in early versions of Bots Playground
var cnt = 0;
var uuid = "";
for(k in result.groups) {
cnt++;
// Activate the very first group in list
if(uuid == "") { uuid = k; }
}
console.log("Got groups. I'm a member of " + cnt + " group(s)" + "\n" +
"I will activate this group tag: " + result.groups[uuid]);
// We use Promise here. See Bot Playground docs
return Bot.activateGroup(uuid);
})
.then(function(result) {
console.log("group activated successfully: " + result.success);
exit();
});