Software /
code /
prosody
Comparison
plugins/mod_console.lua @ 2512:d04b0eeeb954
mod_console: Update !! shortcut for new connection API
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 28 Jan 2010 15:17:55 +0000 |
parent | 2296:23e84604fb00 |
child | 2700:3cb04cdc0193 |
comparison
equal
deleted
inserted
replaced
2511:a81c710b1708 | 2512:d04b0eeeb954 |
---|---|
146 commands.quit, commands.exit = commands.bye, commands.bye; | 146 commands.quit, commands.exit = commands.bye, commands.bye; |
147 | 147 |
148 commands["!"] = function (session, data) | 148 commands["!"] = function (session, data) |
149 if data:match("^!!") then | 149 if data:match("^!!") then |
150 session.print("!> "..session.env._); | 150 session.print("!> "..session.env._); |
151 return console_listener.listener(session.conn, session.env._); | 151 return console_listener.onincoming(session.conn, session.env._); |
152 end | 152 end |
153 local old, new = data:match("^!(.-[^\\])!(.-)!$"); | 153 local old, new = data:match("^!(.-[^\\])!(.-)!$"); |
154 if old and new then | 154 if old and new then |
155 local ok, res = pcall(string.gsub, session.env._, old, new); | 155 local ok, res = pcall(string.gsub, session.env._, old, new); |
156 if not ok then | 156 if not ok then |
157 session.print(res) | 157 session.print(res) |
158 return; | 158 return; |
159 end | 159 end |
160 session.print("!> "..res); | 160 session.print("!> "..res); |
161 return console_listener.listener(session.conn, res); | 161 return console_listener.onincoming(session.conn, res); |
162 end | 162 end |
163 session.print("Sorry, not sure what you want"); | 163 session.print("Sorry, not sure what you want"); |
164 end | 164 end |
165 | 165 |
166 function commands.help(session, data) | 166 function commands.help(session, data) |