index.js 822 B

12345678910111213141516171819202122232425262728
  1. const Command = require('command')
  2. module.exports = function AFKer(dispatch) {
  3. let enabled = true,
  4. afk = false,
  5. afkCheck = null
  6. dispatch.hook('C_PLAYER_LOCATION', 1, () => {
  7. clearTimeout(afkCheck)
  8. afk = false
  9. afkCheck = setTimeout(() => {afk = true}, 3600000) // 1 hour
  10. })
  11. dispatch.hook('C_RETURN_TO_LOBBY', 1, () => {
  12. if (enabled && afk) return false // Prevents you from being automatically logged out while AFK
  13. })
  14. // ################# //
  15. // ### Chat Hook ### //
  16. // ################# //
  17. const command = Command(dispatch)
  18. command.add('afk', () => {
  19. enabled = !enabled
  20. command.message('[AFKer] ' + (enabled ? '<font color="#56B4E9">enabled</font>' : '<font color="#E69F00">disabled</font>'))
  21. console.log('[AFKer] ' + (enabled ? 'enabled' : 'disabled'))
  22. })
  23. }