Software /
code /
prosody
Comparison
plugins/mod_admin_telnet.lua @ 5520:75230be5be58
mod_admin_telnet: Add muc:create(room) (thanks SkyBlue)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 25 Apr 2013 20:37:20 +0100 |
parent | 5278:f79be67e5666 |
child | 5567:c4ab25b35a55 |
comparison
equal
deleted
inserted
replaced
5519:06e188268df1 | 5520:75230be5be58 |
---|---|
901 __tostring = function (self) | 901 __tostring = function (self) |
902 return "MUC room <"..self.room.jid..">"; | 902 return "MUC room <"..self.room.jid..">"; |
903 end; | 903 end; |
904 }; | 904 }; |
905 | 905 |
906 function def_env.muc:room(room_jid) | 906 local function check_muc(jid) |
907 local room_name, host = jid_split(room_jid); | 907 local room_name, host = jid_split(jid); |
908 if not hosts[host] then | 908 if not hosts[host] then |
909 return nil, "No such host: "..host; | 909 return nil, "No such host: "..host; |
910 elseif not hosts[host].modules.muc then | 910 elseif not hosts[host].modules.muc then |
911 return nil, "Host '"..host.."' is not a MUC service"; | 911 return nil, "Host '"..host.."' is not a MUC service"; |
912 end | 912 end |
913 return room_name, host; | |
914 end | |
915 | |
916 function def_env.muc:create(room_jid) | |
917 local room, host = check_muc(room_jid); | |
918 return hosts[host].modules.muc.create_room(room_jid); | |
919 end | |
920 | |
921 function def_env.muc:room(room_jid) | |
922 local room_name, host = check_muc(room_jid); | |
913 local room_obj = hosts[host].modules.muc.rooms[room_jid]; | 923 local room_obj = hosts[host].modules.muc.rooms[room_jid]; |
914 if not room_obj then | 924 if not room_obj then |
915 return nil, "No such room: "..room_jid; | 925 return nil, "No such room: "..room_jid; |
916 end | 926 end |
917 return setmetatable({ room = room_obj }, console_room_mt); | 927 return setmetatable({ room = room_obj }, console_room_mt); |