From 5bb94eac4f7613cc5275a68eaa095e0be37003fd Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Sat, 29 Jun 2019 12:13:57 -0300 Subject: Add generic send event method --- lib/Matrix/Client.pm6 | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'lib/Matrix/Client.pm6') diff --git a/lib/Matrix/Client.pm6 b/lib/Matrix/Client.pm6 index 6d60660..1a24790 100644 --- a/lib/Matrix/Client.pm6 +++ b/lib/Matrix/Client.pm6 @@ -275,6 +275,17 @@ method send(Str $room-id, Str $body, :$type? = "m.text") { from-json($res.content) } +#| PUT - /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId} +method send-event(Str $room-id, Str :$event-type, :$content, :$txn-id? is copy, :$timestamp?) { + unless $txn-id.defined { + $txn-id = $Matrix::Client::Common::TXN-ID++; + } + + my $path = "/rooms/$room-id/send/$event-type/$txn-id"; + my $res = $.put($path, |$content); + from-json($res.content) +} + #| GET - /_matrix/client/r0/directory/room/{roomAlias} method get-room-id($room-alias) { my $res = $.get("/directory/room/$room-alias"); @@ -309,10 +320,10 @@ method upload(IO::Path $path, Str $filename?) { # Misc -method run(Int :$sleep = 10, :$sync-filter? --> Supply) { +method run(Int :$sleep = 10, :$sync-filter?, :$start-since? --> Supply) { my $s = Supplier.new; my $supply = $s.Supply; - my $since = ""; + my $since = $start-since // ""; start { loop { -- cgit v1.2.3-54-g00ecf