Software / code / prosody
Comparison
plugins/mod_console.lua @ 1763:9e4ff3b66ed1
mod_console: c2s:show(): Group listed clients by host
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 09 Sep 2009 14:35:41 +0100 |
| parent | 1623:099364ec1ab2 |
| child | 1799:c9c1987430c6 |
comparison
equal
deleted
inserted
replaced
| 1762:f522a0f195f9 | 1763:9e4ff3b66ed1 |
|---|---|
| 371 end | 371 end |
| 372 end | 372 end |
| 373 | 373 |
| 374 function def_env.c2s:show(match_jid) | 374 function def_env.c2s:show(match_jid) |
| 375 local print, count = self.session.print, 0; | 375 local print, count = self.session.print, 0; |
| 376 local curr_host; | |
| 376 show_c2s(function (jid, session) | 377 show_c2s(function (jid, session) |
| 378 if curr_host ~= session.host then | |
| 379 curr_host = session.host; | |
| 380 print(curr_host); | |
| 381 end | |
| 377 if (not match_jid) or jid:match(match_jid) then | 382 if (not match_jid) or jid:match(match_jid) then |
| 378 count = count + 1; | 383 count = count + 1; |
| 379 local status, priority = "unavailable", tostring(session.priority or "-"); | 384 local status, priority = "unavailable", tostring(session.priority or "-"); |
| 380 if session.presence then | 385 if session.presence then |
| 381 status = session.presence:child_with_name("show"); | 386 status = session.presence:child_with_name("show"); |
| 383 status = status:get_text() or "[invalid!]"; | 388 status = status:get_text() or "[invalid!]"; |
| 384 else | 389 else |
| 385 status = "available"; | 390 status = "available"; |
| 386 end | 391 end |
| 387 end | 392 end |
| 388 print(jid.." - "..status.."("..priority..")"); | 393 print(" "..jid.." - "..status.."("..priority..")"); |
| 389 end | 394 end |
| 390 end); | 395 end); |
| 391 return true, "Total: "..count.." clients"; | 396 return true, "Total: "..count.." clients"; |
| 392 end | 397 end |
| 393 | 398 |