Example #1
0
function applyProgress(progress, room) {
	allData[room].stored = progress.storedData
	commandList = Object.keys(progress.commands)
	if (commandList.indexOf('sendMessage') !== -1) {
		for (var i = 0; i < progress.commands.sendMessage.length; i++) {
			if (progress.commands.sendMessage[i][0] === 'room') { //why cant it know its room?
				bot.sendMessage(room, progress.commands.sendMessage[i][1])
			}
			else {
				bot.sendMessage(progress.commands.sendMessage[i][0], progress.commands.sendMessage[i][1])
			}
		}
	}
	if (commandList.indexOf('lockChat') !== -1) {
		if (lockChat === true) {
			bot.lockChat(room)
		}
	}
	if (commandList.indexOf('unlockChat') !== -1) {
		if (unlockChat === true) {
			bot.unlockChat(room)
		}
	}
	if (commandList.indexOf('setModerated') !== -1) {
		if (setModerated === true) {
			bot.setModerated(room)
		}
	}
	if (commandList.indexOf('setUnmoderated') !== -1) {
		if (setUnmoderated === true) {
			bot.setUnmoderated(room)
		}
	}
	if (commandList.indexOf('kick') !== -1) {
		for (var i = 0; i < progress.commands.kick.length; i++) {
			bot.kick(room, progress.commands.kick[i])
		}
	}
	if (commandList.indexOf('ban') !== -1) {
		for (var i = 0; i < progress.commands.ban.length; i++) {
			bot.ban(room, progress.commands.ban[i])
		}
	}
	if (commandList.indexOf('unban') !== -1) {
		for (var i = 0; i < progress.commands.unban.length; i++) {
			bot.unban(room, progress.commands.unban[i])
		}
	}
}