forked from cyritegamestudios/trust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrustRemoteCommands.lua
More file actions
80 lines (65 loc) · 1.93 KB
/
TrustRemoteCommands.lua
File metadata and controls
80 lines (65 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
local Whitelist = require('settings/settings').Whitelist
local TrustRemoteCommands = {}
TrustRemoteCommands.__index = TrustRemoteCommands
local native_commands_whitelist = L{
'refa all',
'warp',
'pcmd leave',
'pcmd add',
'pcmd kick',
'pcmd leader',
'acmd add',
'acmd leave',
'acmd kick',
'acmd breakup',
'acmd leader',
'attack',
'attackoff',
'jobability',
'magic',
'weaponskill',
}
function TrustRemoteCommands.new()
local self = setmetatable({
events = {};
}, TrustRemoteCommands)
self:on_init()
return self
end
function TrustRemoteCommands:destroy()
for _,event in pairs(self.events) do
windower.unregister_event(event)
end
end
function TrustRemoteCommands:on_init()
self.events.chat_message = windower.register_event('chat message', function(message, sender, mode, gm)
if mode == 3 and not gm and self:get_whitelist():contains(sender) then
local args = string.split(message, ' ')
if args[1] == 'trust' then
windower.send_command('input // '..message)
else
for _, prefix in ipairs(native_commands_whitelist) do
if message:match("^" .. prefix) then
self:handle_native_command(sender, message)
return
end
end
end
end
end)
end
function TrustRemoteCommands:get_whitelist()
return Whitelist:all():map(function(user) return user.id end)
end
function TrustRemoteCommands:destroy()
if self.action_events then
for _,event in pairs(self.action_events) do
windower.unregister_event(event)
end
end
end
function TrustRemoteCommands:handle_native_command(sender, command)
windower.chat.input('/'..command)
addon_message(209, 'Executing remote command from '..sender..': '..command)
end
return TrustRemoteCommands