Software / code / prosody
Comparison
plugins/mod_console.lua @ 1604:5097583259e0
mod_console: Show status and priority of clients
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 26 Jul 2009 17:05:18 +0100 |
| parent | 1582:80d3d95aa83c |
| child | 1618:ba2a92230b77 |
comparison
equal
deleted
inserted
replaced
| 1603:d11606859400 | 1604:5097583259e0 |
|---|---|
| 323 end | 323 end |
| 324 end | 324 end |
| 325 | 325 |
| 326 function def_env.c2s:show(match_jid) | 326 function def_env.c2s:show(match_jid) |
| 327 local print, count = self.session.print, 0; | 327 local print, count = self.session.print, 0; |
| 328 show_c2s(function (jid) | 328 show_c2s(function (jid, session) |
| 329 if (not match_jid) or jid:match(match_jid) then | 329 if (not match_jid) or jid:match(match_jid) then |
| 330 count = count + 1; | 330 count = count + 1; |
| 331 print(jid); | 331 local status, priority = "unavailable", tostring(session.priority or "-"); |
| 332 if session.presence then | |
| 333 status = session.presence:child_with_name("show"); | |
| 334 if status then | |
| 335 status = status:get_text() or "[invalid!]"; | |
| 336 else | |
| 337 status = "available"; | |
| 338 end | |
| 339 end | |
| 340 print(jid.." - "..status.."("..priority..")"); | |
| 332 end | 341 end |
| 333 end); | 342 end); |
| 334 return true, "Total: "..count.." clients"; | 343 return true, "Total: "..count.." clients"; |
| 335 end | 344 end |
| 336 | 345 |