|
@@ -1,32 +1,46 @@
|
|
|
module.exports = function AFKer(dispatch) {
|
|
module.exports = function AFKer(dispatch) {
|
|
|
- let enabled = false
|
|
|
|
|
|
|
+ let enabled = false,
|
|
|
|
|
+ cid = null,
|
|
|
|
|
+ player = ''
|
|
|
|
|
+
|
|
|
|
|
+ dispatch.hook('S_LOGIN', 1, event => {
|
|
|
|
|
+ ({cid} = event)
|
|
|
|
|
+ player = event.name
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
dispatch.hook('C_RETURN_TO_LOBBY', 1, () => {
|
|
dispatch.hook('C_RETURN_TO_LOBBY', 1, () => {
|
|
|
if (enabled) return false // Prevents you from being automatically logged out while AFK
|
|
if (enabled) return false // Prevents you from being automatically logged out while AFK
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ // ################# //
|
|
|
|
|
+ // ### Chat Hook ### //
|
|
|
|
|
+ // ################# //
|
|
|
|
|
|
|
|
dispatch.hook('C_WHISPER', 1, (event) => {
|
|
dispatch.hook('C_WHISPER', 1, (event) => {
|
|
|
- if (/^<FONT>!afker?<\/FONT>$/i.test(event.message)) {
|
|
|
|
|
- if (!enabled) {
|
|
|
|
|
|
|
+ if(event.target.toUpperCase() === "!afker".toUpperCase()) {
|
|
|
|
|
+ if (/^<FONT>on?<\/FONT>$/i.test(event.message)) {
|
|
|
enabled = true
|
|
enabled = true
|
|
|
- message('AFKer <font color="#00EE00">enabled</font>. Whisper "!afker" to disable.')
|
|
|
|
|
|
|
+ message('AFKer <font color="#00EE00">enabled</font>.')
|
|
|
}
|
|
}
|
|
|
- else {
|
|
|
|
|
|
|
+ else if (/^<FONT>off?<\/FONT>$/i.test(event.message)) {
|
|
|
enabled = false
|
|
enabled = false
|
|
|
- message('AFKer <font color="#DC143C">disabled</font>. Whisper "!afker" to enable.')
|
|
|
|
|
|
|
+ message('AFKer <font color="#DC143C">disabled</font>.')
|
|
|
}
|
|
}
|
|
|
|
|
+ else message('Commands: "on" (enable AFKer),'
|
|
|
|
|
+ + ' "off" (disable AFKer)'
|
|
|
|
|
+ )
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
function message(msg) {
|
|
function message(msg) {
|
|
|
- dispatch.toClient('S_CHAT', 1, {
|
|
|
|
|
- channel: 24,
|
|
|
|
|
- authorID: 0,
|
|
|
|
|
|
|
+ dispatch.toClient('S_WHISPER', 1, {
|
|
|
|
|
+ player: cid,
|
|
|
unk1: 0,
|
|
unk1: 0,
|
|
|
gm: 0,
|
|
gm: 0,
|
|
|
unk2: 0,
|
|
unk2: 0,
|
|
|
- authorName: '',
|
|
|
|
|
|
|
+ author: '!AFKer',
|
|
|
|
|
+ recipient: player,
|
|
|
message: msg
|
|
message: msg
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|