aboutsummaryrefslogtreecommitdiff
path: root/lib/Matrix
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@openmailbox.org>2018-01-28 18:16:25 -0300
committerMatias Linares <matiaslina@openmailbox.org>2018-01-28 18:16:25 -0300
commitb1f945d6cc9853b7e0dda302c2c0ba3cd0946ae7 (patch)
tree15d5e586d1b816b384aa66102630758f9864828d /lib/Matrix
parent194a15d06d94e43c2d843904df7c474dbc8afb39 (diff)
downloadperl6-matrix-client-b1f945d6cc9853b7e0dda302c2c0ba3cd0946ae7.tar.gz
Add joined-rooms and public-rooms methods
Diffstat (limited to 'lib/Matrix')
-rw-r--r--lib/Matrix/Client.pm625
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/Matrix/Client.pm6 b/lib/Matrix/Client.pm6
index 51141eb..5091319 100644
--- a/lib/Matrix/Client.pm6
+++ b/lib/Matrix/Client.pm6
@@ -188,9 +188,32 @@ method rooms(Bool :$sync = False) {
@!rooms
}
+method joined-rooms() {
+ my $res = $.get('/joined_rooms');
+
+ unless $res.is-success {
+ note "Error getting joined rooms: {$res.status}";
+ return ();
+ }
+ my $data = from-json($res.content);
+ return $data<joined_rooms>.Seq.map(-> $room-id {
+ Matrix::Client::Room.new(
+ id => $room-id,
+ home-server => $!home-server,
+ access-token => $!access-token
+ )
+ });
+}
+
+method public-rooms() {
+ $.get('/publicRooms')
+}
+
method send(Str $room-id, Str $body, :$type? = "m.text") {
$Matrix::Client::Common::TXN-ID++;
- $.put("/rooms/$room-id/send/m.room.message/{$Matrix::Client::Common::TXN-ID}", msgtype => $type, body => $body)
+ $.put("/rooms/$room-id/send/m.room.message/{$Matrix::Client::Common::TXN-ID}",
+ msgtype => $type, body => $body
+ )
}
# Media