User:Annawantimes/ChatHacks.js

window.commands = { 'away': 'afk', 'afk': function(com, text) { if($('#ChatHeader .User').hasClass('away') == false) {toggleAway;} //if you're away, hitting enter has already sent you back },		'clear': function(com, text) { //Clear the active chat window this.clearWindow; },		'me': function(com, text) { //Emote if(com) {$('#Write [name="message"]').val('* ' + wgUserName + ' ' + com);} else {$('#Write [name="message"]').val('* ' + wgUserName);} return true; },		'nc': function(com, text) { //Nobody cares $('#Write [name="message"]').val( + (com ? com : i18n['nobodycares']) + ); return true; },		'devoice': function(com, text) { //IRCpwnt $('#Write [name="message"]').val('* ChanServ set channel mode -v ' + (com ? com : wgUserName)); return true; },		'coppa': function(com, text) { //Too young if(com) {$('#Write [name="message"]').val('http://coppa.org ' + com);} else {$('#Write [name="message"]').val('http://coppa.org ' + i18n['coppa']);} return true; },		'kick': 'kickban', 'ban': 'kickban', 'kb': 'kickban', 'kickban': function(com, text) { //Kickban a user if(com) { var mod = new models.KickBanCommand({userToBan: com}); this.socket.send(mod.xport); }			else {this.inlineAlert(i18n['erruser'].replace(/\$1/g, text.split(' ')[0]));} },		'unban': function(com, text) { //Unban a user if(com) { api.newQuery(POST, 'action=userrights&user=' + com + '&remove=bannedfromchat', function(result) {					if(result.userrights.removed[0] == 'bannedfromchat') {						this.inlineAlert(i18n['unbanned'].replace(/\$1/g, com));					}					else {						this.inlineAlert(i18n['notbanned'].replace(/\$1/g, com));					}				}); api.send(0, true); }			else {this.inlineAlert(i18n['erruser'].replace(/\$1/g, text.split(' ')[0]));} },		'mod': function(com, text) { //Make a user a mod if(com) { var giveChatModCommand = new models.GiveChatModCommand({userToPromote: com}); this.socket.send(giveChatModCommand.xport); }			else {this.inlineAlert(i18n['erruser'].replace(/\$1/g, text.split(' ')[0]));} },		'demod': function(com, text) { //Remove a user's mod right if(com) { api.newQuery(POST, 'action=userrights&user=' + com + '&remove=chatmoderator', function(result) {					if(result.userrights.removed[0] == 'chatmoderator') {						this.inlineAlert(i18n['demodded'].replace(/\$1/g, com));					}					else {						this.inlineAlert(i18n['notmod'].replace(/\$1/g, com));					}				}); api.send(0, true); }			else {this.inlineAlert(i18n['erruser'].replace(/\$1/g, text.split(' ')[0]));} },		'block': function(com, text) { //Block a user from private chatting you if(com) {this.blockPrivate({name: com});} else {this.inlineAlert(i18n['erruser'].replace(/\$1/g, text.split(' ')[0]));} },		'unblock': function(com, text) { //Unblock a user from private chatting you - should merge this into a toggle if(com) {this.allowPrivate({name: com});} else {this.inlineAlert(i18n['erruser'].replace(/\$1/g, text.split(' ')[0]));} },