Comparison

plugins/mod_admin_telnet.lua @ 10859:8de0057b4279

mod_admin_shell, mod_admin_telnet, util.prosodyctl.shell: Separate output from final result Fixes the client pausing for input after output from commands.
author Matthew Wild <mwild1@gmail.com>
date Mon, 01 Jun 2020 16:14:06 +0100
parent 10857:826023c3322b
child 12977:74b9e05af71e
comparison
equal deleted inserted replaced
10858:efa49d484560 10859:8de0057b4279
63 63
64 function console:new_session(conn) 64 function console:new_session(conn)
65 local w = function(s) conn:write(s:gsub("\n", "\r\n")); end; 65 local w = function(s) conn:write(s:gsub("\n", "\r\n")); end;
66 local session = { conn = conn; 66 local session = { conn = conn;
67 send = function (t) 67 send = function (t)
68 if st.is_stanza(t) and t.name == "repl-result" then 68 if st.is_stanza(t) and (t.name == "repl-result" or t.name == "repl-output") then
69 t = "| "..t:get_text().."\n"; 69 t = "| "..t:get_text().."\n";
70 end 70 end
71 w(tostring(t)); 71 w(tostring(t));
72 end; 72 end;
73 print = function (...) 73 print = function (...)
104 if line == "bye" or line == "quit" or line == "exit" or line:byte() == 4 then 104 if line == "bye" or line == "quit" or line == "exit" or line:byte() == 4 then
105 session.print("See you!"); 105 session.print("See you!");
106 session:disconnect(); 106 session:disconnect();
107 return; 107 return;
108 end 108 end
109 return module:fire_event("admin/repl-line", { origin = session, stanza = st.stanza("repl"):text(line) }); 109 return module:fire_event("admin/repl-input", { origin = session, stanza = st.stanza("repl-input"):text(line) });
110 end 110 end
111 111
112 local sessions = {}; 112 local sessions = {};
113 113
114 function module.save() 114 function module.save()