TeraProxy лет назад: 9
Родитель
Сommit
db803e0451
2 измененных файлов с 27 добавлено и 7 удалено
  1. 7 4
      README.md
  2. 20 3
      index.js

+ 7 - 4
README.md

@@ -3,14 +3,17 @@ A tera-proxy module that prevents you from getting back to the character select
 This has the side effect that the server's AFK check will not kick you out of the game.  
 This has the side effect that the server's AFK check will not kick you out of the game.  
   
   
 ## Usage  
 ## Usage  
-While in game, open a whisper chat session with "!AFKer" by typing "/w !afker" in chat and hitting the space bar.
+While ingame, open a whisper chat session with "!AFKer" by typing "/w !afker" in chat and hitting the space bar.
 This serves as the script's command interface. 
 This serves as the script's command interface. 
 The following commands are supported:  
 The following commands are supported:  
   
   
 * on - Enables the script  
 * on - Enables the script  
-* off - Disables the script  
+* off - Disables the script (default)  
   
   
-Any other input returns a summary of above commands in the game.
+Any other input returns a summary of above commands in the game.  
+  
+Alternative commands in all other chats:  
+* !afk - Toggles between "on" and "off" state  
   
   
 ## Safety
 ## Safety
-Whatever you send to "!AFKer" in game is intercepted client-side. The chat is NOT sent to the server.
+Whatever you send to "!AFKer" ingame is intercepted client-side. The chat is NOT sent to the server.

+ 20 - 3
index.js

@@ -20,13 +20,14 @@ module.exports = function AFKer(dispatch) {
 		if(event.target.toUpperCase() === "!afker".toUpperCase()) {
 		if(event.target.toUpperCase() === "!afker".toUpperCase()) {
 			if (/^<FONT>on?<\/FONT>$/i.test(event.message)) {
 			if (/^<FONT>on?<\/FONT>$/i.test(event.message)) {
 				enabled = true
 				enabled = true
-				message('AFKer <font color="#00EE00">enabled</font>.')
+				message('AFKer <font color="#56B4E9">enabled</font>.')
 			}
 			}
 			else if (/^<FONT>off?<\/FONT>$/i.test(event.message)) {
 			else if (/^<FONT>off?<\/FONT>$/i.test(event.message)) {
 				enabled = false
 				enabled = false
-				message('AFKer <font color="#DC143C">disabled</font>.')
+				message('AFKer <font color="#E69F00">disabled</font>.')
 			}
 			}
-			else message('Commands: "on" (enable AFKer),'
+			else message('Commands:<br>'
+								+ ' "on" (enable AFKer),<br>'
 								+ ' "off" (disable AFKer)'
 								+ ' "off" (disable AFKer)'
 						)
 						)
 			return false
 			return false
@@ -44,4 +45,20 @@ module.exports = function AFKer(dispatch) {
 			message: msg
 			message: msg
 		})
 		})
 	}
 	}
+	
+	dispatch.hook('C_CHAT', 1, event => {
+		if(/^<FONT>!afk<\/FONT>$/i.test(event.message)) {
+			if(!enabled) {
+				enabled = true
+				message('AFKer <font color="#56B4E9">enabled</font>.')
+				console.log('AFKer enabled.')
+			}
+			else {
+				enabled = false
+				message('AFKer <font color="#E69F00">disabled</font>.')
+				console.log('AFKer disabled.')
+			}
+			return false
+		}
+	})
 }
 }