Logging out and back in

From SmartBots Developers Docs
Bot PlaygroundExamples
Revision as of 19:26, 15 July 2016 by Gg (Talk | contribs) (Created page with "{{DISPLAYTITLE:{{SUBPAGENAME}}}} This example script logs bot out, waits for 30 seconds and then logs back in. To track the procedure, we set event handlers: before_logout, b...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


This example script logs bot out, waits for 30 seconds and then logs back in. To track the procedure, we set event handlers: before_logout, before_login and after_login.

P.S. Note that you can chain Bot.on() function calls as shown below.

Bot
	.on("before_logout", function(event) {
		console.log("Event: Bot is logging out");
	})
	.on("before_login", function(event) {
		console.log("Event: Bot is logging in");
	})
	.on("after_login", function(event) {
		console.log("Event: Bot has logged in");
	});

// Logout bot in few seconds (otherwise bot may not notice the events we just set)
setTimeout(function() {
	console.log("Logging out the bot...");
	Bot.logout();
}, 5 * 1000);


// Then wait 30 second and login back
setTimeout(function() {
	console.log("Starting log in sequence...");
	
	Bot.login();
}, 30 * 1000);