diff options
Diffstat (limited to 'lib/Matrix')
-rw-r--r-- | lib/Matrix/Client.pm6 | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/Matrix/Client.pm6 b/lib/Matrix/Client.pm6 index 5e4914a..fe3e259 100644 --- a/lib/Matrix/Client.pm6 +++ b/lib/Matrix/Client.pm6 @@ -198,3 +198,31 @@ method upload(IO::Path $path, Str $filename?) { my $data = from-json($res.content); $data<content_uri> // ""; } + +# Misc + +method run(Int :$sleep = 10, :$sync-filter? --> Supply) { + my $s = Supplier.new; + my $supply = $s.Supply; + my $since = ""; + + start { + loop { + my $sync = $.sync(:$since, :$sync-filter); + $since = $sync.next-batch; + say $since; + + for $sync.invited-rooms -> $info { + $s.emit($info); + } + + for $sync.joined-rooms -> $room { + for $room.timeline.events -> $event { + $s.emit($event) + } + } + sleep $sleep; + } + } + $supply +} |