Merge 0.6->0.7
authorWaqas Hussain <waqas20@gmail.com>
Fri, 7 May 2010 11:17:48 +0000 (16:17 +0500)
committerWaqas Hussain <waqas20@gmail.com>
Fri, 7 May 2010 11:17:48 +0000 (16:17 +0500)
1  2 
core/configmanager.lua
plugins/mod_console.lua
plugins/mod_posix.lua
plugins/muc/muc.lib.lua

Simple merge
index 4180e2b62543af2fe51dd778bff70773cdf4546b,a33302d979db53c870aa7ae3e7a9f9689b416afa..e87ef536158cf39afb295406fcd929cdcc6dfa5a
@@@ -53,77 -53,77 +53,78 @@@ en
  
  local sessions = {};
  
 -function console_listener.listener(conn, data)
 +function console_listener.onconnect(conn)
 +      -- Handle new connection
 +      local session = console:new_session(conn);
 +      sessions[conn] = session;
 +      printbanner(session);
 +      session.send(string.char(0));
 +end
 +
 +function console_listener.onincoming(conn, data)
        local session = sessions[conn];
 -      
 -      if not session then
 -              -- Handle new connection
 -              session = console:new_session(conn);
 -              sessions[conn] = session;
 -              printbanner(session);
 -      end
 -      if data then
 -              -- Handle data
 -              (function(session, data)
 -                      local useglobalenv;
 -                      
 -                      if data:match("^>") then
 -                              data = data:gsub("^>", "");
 -                              useglobalenv = true;
 -                      elseif data == "\004" then
 -                              commands["bye"](session, data);
 +
 +      -- Handle data
 +      (function(session, data)
 +              local useglobalenv;
 +              
 +              if data:match("^>") then
 +                      data = data:gsub("^>", "");
 +                      useglobalenv = true;
 +              elseif data == "\004" then
 +                      commands["bye"](session, data);
 +                      return;
 +              else
 +                      local command = data:lower();
 +                      command = data:match("^%w+") or data:match("%p");
 +                      if commands[command] then
 +                              commands[command](session, data);
                                return;
 -                      else
 -                              local command = data:lower();
 -                              command = data:match("^%w+") or data:match("%p");
 -                              if commands[command] then
 -                                      commands[command](session, data);
 -                                      return;
 -                              end
                        end
 +              end
  
 -                      session.env._ = data;
 -                      
 -                      local chunkname = "=console";
 -                      local chunk, err = loadstring("return "..data, chunkname);
 +              session.env._ = data;
 +              
-               local chunk, err = loadstring("return "..data);
++              local chunkname = "=console";
++              local chunk, err = loadstring("return "..data, chunkname);
 +              if not chunk then
-                       chunk, err = loadstring(data);
++                      chunk, err = loadstring(data, chunkname);
                        if not chunk then
 -                              chunk, err = loadstring(data, chunkname);
 -                              if not chunk then
 -                                      err = err:gsub("^%[string .-%]:%d+: ", "");
 -                                      err = err:gsub("^:%d+: ", "");
 -                                      err = err:gsub("'<eof>'", "the end of the line");
 -                                      session.print("Sorry, I couldn't understand that... "..err);
 -                                      return;
 -                              end
 -                      end
 -                      
 -                      setfenv(chunk, (useglobalenv and redirect_output(_G, session)) or session.env or nil);
 -                      
 -                      local ranok, taskok, message = pcall(chunk);
 -                      
 -                      if not (ranok or message or useglobalenv) and commands[data:lower()] then
 -                              commands[data:lower()](session, data);
 -                              return;
 -                      end
 -                      
 -                      if not ranok then
 -                              session.print("Fatal error while running command, it did not complete");
 -                              session.print("Error: "..taskok);
 -                              return;
 -                      end
 -                      
 -                      if not message then
 -                              session.print("Result: "..tostring(taskok));
 -                              return;
 -                      elseif (not taskok) and message then
 -                              session.print("Command completed with a problem");
 -                              session.print("Message: "..tostring(message));
 +                              err = err:gsub("^%[string .-%]:%d+: ", "");
 +                              err = err:gsub("^:%d+: ", "");
 +                              err = err:gsub("'<eof>'", "the end of the line");
 +                              session.print("Sorry, I couldn't understand that... "..err);
                                return;
                        end
 -                      
 -                      session.print("OK: "..tostring(message));
 -              end)(session, data);
 -      end
 +              end
 +              
 +              setfenv(chunk, (useglobalenv and redirect_output(_G, session)) or session.env or nil);
 +              
 +              local ranok, taskok, message = pcall(chunk);
 +              
 +              if not (ranok or message or useglobalenv) and commands[data:lower()] then
 +                      commands[data:lower()](session, data);
 +                      return;
 +              end
 +              
 +              if not ranok then
 +                      session.print("Fatal error while running command, it did not complete");
 +                      session.print("Error: "..taskok);
 +                      return;
 +              end
 +              
 +              if not message then
 +                      session.print("Result: "..tostring(taskok));
 +                      return;
 +              elseif (not taskok) and message then
 +                      session.print("Command completed with a problem");
 +                      session.print("Message: "..tostring(message));
 +                      return;
 +              end
 +              
 +              session.print("OK: "..tostring(message));
 +      end)(session, data);
 +      
        session.send(string.char(0));
  end
  
Simple merge
index 273e21ce94214b585d54580b60eb658b6d59f5af,75289cc1584c88e061de22eb5e5e83da67d39c16..18c80325bbd1bce5db492b36643407d4d1b4bf65
@@@ -357,7 -328,7 +319,12 @@@ function room_mt:handle_to_occupant(ori
                                                                :tag("item", {affiliation=affiliation or "none", role=role or "none"}):up()
                                                                :tag("status", {code='110'}));
                                                end
-                                               self:send_history(from, stanza);
++                                              if self._data.whois == 'anyone' then -- non-anonymous?
++                                                      self:_route_stanza(st.stanza("message", {from=to, to=from, type='groupchat'})
++                                                              :tag("x", {xmlns='http://jabber.org/protocol/muc#user'})
++                                                              :tag("status", {code='100'}));
++                                              end
+                                               self:send_history(from);
                                        else -- banned
                                                local reply = st.error_reply(stanza, "auth", "forbidden"):up();
                                                reply.tags[1].attr.code = "403";