diff options
author | Matias Linares <matiaslina@gmail.com> | 2019-06-29 12:13:57 -0300 |
---|---|---|
committer | Matias Linares <matiaslina@gmail.com> | 2019-06-29 12:13:57 -0300 |
commit | 5bb94eac4f7613cc5275a68eaa095e0be37003fd (patch) | |
tree | d53796cabea99630e3170a2c6241a3cf8893adbc | |
parent | e328870a0fca2f0717ba46886b3d16109320a3ba (diff) | |
download | perl6-matrix-client-5bb94eac4f7613cc5275a68eaa095e0be37003fd.tar.gz |
Add generic send event method
-rw-r--r-- | lib/Matrix/Client.pm6 | 15 |
1 files changed, 13 insertions, 2 deletions
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)<event_id> } +#| 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)<event_id> +} + #| 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 { |