Changeset 7cdf756


Ignore:
Timestamp:
Jan 25, 2007, 3:46:26 PM (14 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
c25a20f
Parents:
71e33ca
Message:
* Added `jmuc presence -a' to show presence for all MUCs
* Updated jmuc docs
File:
1 edited

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
Note: See TracChangeset for help on using the changeset viewer.