line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public License |
2
|
|
|
|
|
|
|
# or the Artistic License (the same terms as Perl itself) |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# (C) Paul Evans, 2016 -- leonerd@leonerd.org.uk |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package App::MatrixTool::Command::client::list_rooms; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
774
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
9
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
10
|
1
|
|
|
1
|
|
4
|
use base qw( App::MatrixTool::Command::client ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
80
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
5
|
use constant DESCRIPTION => "List the rooms the user is in"; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
46
|
|
15
|
1
|
|
|
1
|
|
4
|
use constant ARGUMENTS => (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
46
|
|
16
|
1
|
|
|
1
|
|
4
|
use constant OPTIONS => (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
171
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
matrixtool client list-rooms - List the room IDs I am a member of |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
This command prints a list of room IDs that the calling user has C |
25
|
|
|
|
|
|
|
membership of. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub run |
30
|
|
|
|
|
|
|
{ |
31
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# the Matrix spec doesn't have a nice way to ask what rooms I'm a member |
34
|
|
|
|
|
|
|
# of. About the best we can do is a /sync request with a filter that asks |
35
|
|
|
|
|
|
|
# for just the m.room.create event in each room while throwing away all the |
36
|
|
|
|
|
|
|
# timeline, account_data and presence. |
37
|
|
|
|
|
|
|
# See also |
38
|
|
|
|
|
|
|
# https://github.com/matrix-org/matrix-doc/issues/734 |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$self->do_json( GET => "/_matrix/client/r0/sync", |
41
|
|
|
|
|
|
|
params => { |
42
|
|
|
|
|
|
|
filter => |
43
|
|
|
|
|
|
|
'{"room":{' . |
44
|
|
|
|
|
|
|
'"timeline":{"limit":0},' . |
45
|
|
|
|
|
|
|
'"state":{"types":["m.room.create"]},' . |
46
|
|
|
|
|
|
|
'"ephemeral":{"types":[]}' . |
47
|
|
|
|
|
|
|
'},' . |
48
|
|
|
|
|
|
|
'"presence":{"types":[]},' . |
49
|
|
|
|
|
|
|
'"account_data":{"types":[]}}', |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
)->then( sub { |
52
|
0
|
|
|
0
|
|
|
my ( $body ) = @_; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $rooms = $body->{rooms}; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
print "$_\n" for keys %{ $rooms->{join} }; |
|
0
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# TODO: think about invite and leave |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
Future->done; |
60
|
0
|
|
|
|
|
|
}); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 AUTHOR |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Paul Evans |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
0x55AA; |