Changeset 7cdf756ca67dbcf29abc6a767985f62a637c2e7f

Show
Ignore:
Timestamp:
01/25/07 15:46:26 (3 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Parents:
71e33caeb86dbdb2b5b471da2d3dab3cd746afb8
Children:
c25a20fcbef752a45d4e0f8a19d35b2fda93190f
git-committer:
Alejandro R. Sedeño <asedeno@mit.edu> / 2007-01-25T20:46:26Z+0000
Message:
* Added `jmuc presence -a' to show presence for all MUCs
* Updated jmuc docs
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • perl/modules/jabber.pl

    r71e33ca r7cdf756  
    373373            description => "jmuc sends jabber commands related to muc.\n\n" 
    374374              . "The following commands are available\n\n" 
    375               . "join MUC    Join a muc.\n\n" 
    376               . "part MUC    Part a muc.\n" 
     375              . "join <muc>  Join a muc.\n\n" 
     376              . "part <muc>  Part a muc.\n" 
    377377              . "            The muc is taken from the current message if not supplied.\n\n" 
    378               . "invite JID MUC\n" 
    379               . "            Invite JID to MUC.\n" 
     378              . "invite <jid> <muc>\n" 
     379              . "            Invite <jid> to <muc>.\n" 
    380380              . "            The muc is taken from the current message if not supplied.\n\n" 
    381               . "configure MUC\n" 
    382               . "            Configure [muc].\n" 
    383               . "            Necessary to initalize a new MUC\n" 
    384               . "            At present, only the default configuration is supported.", 
     381              . "configure <muc>\n" 
     382              . "            Configures a MUC.\n" 
     383              . "            Necessary to initalize a new MUC.\n" 
     384              . "            At present, only the default configuration is supported.\n" 
     385              . "            The muc is taken from the current message if not supplied.\n\n" 
     386              . "presence <muc>\n" 
     387              . "            Shows the roster for <muc>.\n" 
     388              . "            The muc is taken from the current message if not supplied.\n\n" 
     389              . "presence -a\n" 
     390              . "            Shows rosters for all MUCs you're participating in.\n\n", 
    385391            usage => "jmuc COMMAND ARGS" 
    386392        } 
     
    752758} 
    753759 
     760sub jmuc_presence_single { 
     761    my $m = shift; 
     762    my @jids = $m->Presence(); 
     763    return "JIDs present in " . $m->BaseJID . "\n\t" 
     764      . join("\n\t", map {$_->GetResource}@jids) . "\n"; 
     765} 
     766 
    754767sub jmuc_presence { 
    755768    my ( $jid, $muc, @args ) = @_; 
     
    758771    die("Usage: jmuc presence MUC") unless $muc; 
    759772 
    760     my $m = $conn->getConnectionFromJID($jid)->FindMUC(jid => $muc); 
    761     die("No such muc: $muc") unless $m; 
    762  
    763     my @jids = $m->Presence(); 
    764     BarnOwl::popless_ztext("JIDs present in " . $m->BaseJID . "\n\t" . 
    765                            join("\n\t", map {$_->GetResource}@jids) . "\n"); 
     773    if ($muc eq '-a') { 
     774        my $str = ""; 
     775        foreach my $jid ($conn->getJIDs()) { 
     776            $str .= boldify("Conferences for $jid:\n"); 
     777            my $connection = $conn->getConnectionFromJID($jid); 
     778            foreach my $muc ($connection->MUCs) { 
     779                $str .= jmuc_presence_single($muc)."\n"; 
     780            } 
     781        } 
     782        BarnOwl::popless_ztext($str); 
     783    } 
     784    else { 
     785        my $m = $conn->getConnectionFromJID($jid)->FindMUC(jid => $muc); 
     786        die("No such muc: $muc") unless $m; 
     787        BarnOwl::popless_ztext(jmuc_presence_single($m)); 
     788    } 
    766789} 
    767790