text: ﻿let bubbleLetterMap = new Map([
      ['a', '\u24D0'], ['b', '\u24D1'], ['c', '\u24D2'], ['d', '\u24D3'], ['e', '\u24D4'], ['f', '\u24D5'], ['g', '\u24D6'], ['h', '\u24D7'], ['i', '\u24D8'], ['j', '\u24D9'], ['k', '\u24DA'], ['l', '\u24DB'], ['m', '\u24DC'],
      ['n', '\u24DD'], ['o', '\u24DE'], ['p', '\u24DF'], ['q', '\u24E0'], ['r', '\u24E1'], ['s', '\u24E2'], ['t', '\u24E3'], ['u', '\u24E4'], ['v', '\u24E5'], ['w', '\u24E6'], ['x', '\u24E7'], ['y', '\u24E8'], ['z', '\u24E9'],
      ['A', '\u24B6'], ['B', '\u24B7'], ['C', '\u24B8'], ['D', '\u24B9'], ['E', '\u24BA'], ['F', '\u24BB'], ['G', '\u24BC'], ['H', '\u24BD'], ['I', '\u24BE'], ['J', '\u24BF'], ['K', '\u24C0'], ['L', '\u24C1'], ['M', '\u24C2'],
      ['N', '\u24C3'], ['O', '\u24C4'], ['P', '\u24C5'], ['Q', '\u24C6'], ['R', '\u24C7'], ['S', '\u24C8'], ['T', '\u24C9'], ['U', '\u24CA'], ['V', '\u24CB'], ['W', '\u24CC'], ['X', '\u24CD'], ['Y', '\u24CE'], ['Z', '\u24CF'],
      ['1', '\u2460'], ['2', '\u2461'], ['3', '\u2462'], ['4', '\u2463'], ['5', '\u2464'], ['6', '\u2465'], ['7', '\u2466'], ['8', '\u2467'], ['9', '\u2468'], ['0', '\u24EA'],
  ]);
  
  let asciiMap = new Map([
      ['\u24D0', 'a'], ['\u24D1', 'b'], ['\u24D2', 'c'], ['\u24D3', 'd'], ['\u24D4', 'e'], ['\u24D5', 'f'], ['\u24D6', 'g'], ['\u24D7', 'h'], ['\u24D8', 'i'], ['\u24D9', 'j'], ['\u24DA', 'k'], ['\u24DB', 'l'], ['\u24DC', 'm'],
      ['\u24DD', 'n'], ['\u24DE', 'o'], ['\u24DF', 'p'], ['\u24E0', 'q'], ['\u24E1', 'r'], ['\u24E2', 's'], ['\u24E3', 't'], ['\u24E4', 'u'], ['\u24E5', 'v'], ['\u24E6', 'w'], ['\u24E7', 'x'], ['\u24E8', 'y'], ['\u24E9', 'z'],
      ['\u24B6', 'A'], ['\u24B7', 'B'], ['\u24B8', 'C'], ['\u24B9', 'D'], ['\u24BA', 'E'], ['\u24BB', 'F'], ['\u24BC', 'G'], ['\u24BD', 'H'], ['\u24BE', 'I'], ['\u24BF', 'J'], ['\u24C0', 'K'], ['\u24C1', 'L'], ['\u24C2', 'M'],
      ['\u24C3', 'N'], ['\u24C4', 'O'], ['\u24C5', 'P'], ['\u24C6', 'Q'], ['\u24C7', 'R'], ['\u24C8', 'S'], ['\u24C9', 'T'], ['\u24CA', 'U'], ['\u24CB', 'V'], ['\u24CC', 'W'], ['\u24CD', 'X'], ['\u24CE', 'Y'], ['\u24CF', 'Z'],
      ['\u2460', '1'], ['\u2461', '2'], ['\u2462', '3'], ['\u2463', '4'], ['\u2464', '5'], ['\u2465', '6'], ['\u2466', '7'], ['\u2467', '8'], ['\u2468', '9'], ['\u24EA', '0'],
  ]);
  
  function parseStatus(text, encoding) {
  	if (encoding) {
  		text = text.split('').map(function (char) {
  			return bubbleLetterMap.get(char);
  		}).join('');
  	} else {
  		text = text.split('').map(function (char) {
  			return asciiMap.get(char);
  		}).join('');
  	}
  	return text;
  }
  
  exports.commands = {
  	away: function (target, room, user) {
  		if (!user.isAway && user.name.length > 15) return this.sendReply('Su nombre de usuario es demasiado largo para cualquier tipo de uso de este comando.');
  
  		target = target ? target.replace(/[^a-zA-Z0-9]/g, '') : 'AWAY';
  		let newName = user.name;
  		let status = parseStatus(target, true);
  		let statusLen = status.length;
  		if (statusLen > 14) return this.sendReply('Su estado ausente debe ser corto, no una disertación sobre por qué estás ausente.');
  
  		if (user.isAway) {
  			let statusIdx = newName.search(/\s\-\s[\u24B6-\u24E9\u2460-\u2468\u24EA]+$/);
  			if (statusIdx > -1) newName = newName.substr(0, statusIdx);
  			if (user.name.substr(-statusLen) === status) return this.sendReply('Ahora estás "' + target + '".');
  		}
  
  		newName += ' - ' + status;
  		if (newName.length > 18) return this.sendReply('El tipo de ausente que trataste de seleccionar "' + target + '" es muy largo para tu nick.');
  
          // forcerename any possible impersonators
  		let targetUser = Users.getExact(user.userid + target);
  		if (targetUser && targetUser !== user && targetUser.name === user.name + ' - ' + target) {
  			targetUser.resetName();
  			targetUser.send('|nametaken||Your name conflicts with ' + user.name + (user.name.substr(-1) === 's' ? '\'' : '\'s') + ' new away status.');
  		}
  
  		if (user.can('lock', null, room)) this.add('|raw|-- ' + Plugins.Colors.apply(user.name).bold() + ' ahora está ' + target.toLowerCase() + '.');
  		user.forceRename(newName, user.registered);
  		user.updateIdentity();
  		user.isAway = true;
  	},
  
  	back: function (target, room, user) {
  		if (!user.isAway) return this.sendReply('Tu no te encuentras/encontrabas ausente.');
  		user.isAway = false;
  
  		let newName = user.name;
  		let statusIdx = newName.search(/\s\-\s[\u24B6-\u24E9\u2460-\u2468\u24EA]+$/);
  		if (statusIdx < 0) {
  			user.isAway = false;
  			if (user.can('lock', null, room)) this.add('|raw|-- ' + Plugins.Colors.apply(user.name).bold() + ' ya no está ausente.');
  			return false;
  		}
  
  		let status = parseStatus(newName.substr(statusIdx + 3), false);
  		newName = newName.substr(0, statusIdx);
  		user.forceRename(newName, user.registered);
  		user.updateIdentity();
  		user.isAway = false;
  		if (user.can('lock', null, room)) this.add('|raw|-- ' + Plugins.Colors.apply(newName).bold() + '  ya no está ' + status.toLowerCase() + '.');
  	},
  
  	afk: function (target, room, user) {
  		this.parse('/away AFK', room, user);
  	},
  
  	tarea: function (target, room, user) {
  		this.parse('/away TAREA', room, user);
  	},
  
  	trabajo: function (target, room, user) {
  		this.parse('/away TRABAJO', room, user);
  	},
  
  	trabajando: function (target, room, user) {
  		this.parse('/away TRABAJANDO', room, user);
  	},
  
  	comiendo: function (target, room, user) {
  		this.parse('/away COMIENDO', room, user);
  	},
  
  	jugando: function (target, room, user) {
  		this.parse('/away JUGANDO', room, user);
  	},
  
  	durmiendo: function (target, room, user) {
  		this.parse('/away DURMIENDO', room, user);
  	},
  
  	nerd: function (target, room, user) {
  		this.parse('/away NERD', room, user);
  	},
  
  	nerding: function (target, room, user) {
  		this.parse('/away NERDING', room, user);
  	},
  
  	mimis: function (target, room, user) {
  		this.parse('/away MIMIS', room, user);
  	},
  };
  