equal
deleted
inserted
replaced
32 local origin, stanza = event.origin, event.stanza; |
32 local origin, stanza = event.origin, event.stanza; |
33 if stanza.attr.type == "set" and stanza.tags[1] and stanza.tags[1].name == "command" then |
33 if stanza.attr.type == "set" and stanza.tags[1] and stanza.tags[1].name == "command" then |
34 local node = stanza.tags[1].attr.node |
34 local node = stanza.tags[1].attr.node |
35 for i = 1, #commands do |
35 for i = 1, #commands do |
36 if commands[i].node == node then |
36 if commands[i].node == node then |
|
37 -- check whether user has permission to execute this command first |
|
38 if commands[i].permission == "admin" and not is_admin(stanza.attr.from) then |
|
39 origin.send(st.error_reply(stanza, "auth", "forbidden", "You don't have permission to execute this command"):up() |
|
40 :add_child(commands[i]:cmdtag("canceled") |
|
41 :tag("note", {type="error"}):text("You don't have permission to execute this command"))); |
|
42 return true |
|
43 end |
|
44 -- User has permission now execute the command |
37 return commands[i].handler(commands[i], origin, stanza); |
45 return commands[i].handler(commands[i], origin, stanza); |
38 end |
46 end |
39 end |
47 end |
40 end |
48 end |
41 end, 500); |
49 end, 500); |