diff options
author | Matias Linares <matiaslina@openmailbox.org> | 2018-06-09 12:39:02 -0300 |
---|---|---|
committer | Matias Linares <matiaslina@openmailbox.org> | 2018-06-09 12:39:02 -0300 |
commit | 89fd81cf9909d804b08dbc8d47d2eb8f82d4c80c (patch) | |
tree | 712e3bc79d5e6b08581c5926edbe2b263c8d52a7 | |
parent | 738766a38ec43a3de904561a9669fe9eb6be3408 (diff) | |
download | perl6-matrix-client-89fd81cf9909d804b08dbc8d47d2eb8f82d4c80c.tar.gz |
Fix examples in documentation
-rw-r--r-- | docs/basics.pod6 | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/docs/basics.pod6 b/docs/basics.pod6 index a6f5d45..694983f 100644 --- a/docs/basics.pod6 +++ b/docs/basics.pod6 @@ -10,14 +10,17 @@ the homeserver, and C<login> into it. my Matrix::Client $client .= new: :home-server<https://matrix.org>; $client.login($username, $password); + say $client.access-token; In case you have an access-token, you can pass it as a parameter -to C<new>. In this case is not necessary to call C<login> +to C<new>. In this case is not necessary to call C<login>. my Matrix::Client $client .= new: :home-server<https://matrix.org>, :access-token($access-token); + say $client.whoami; # @yourusername:home-server + =head2 Syncing Calling sync will return a C<Matrix::Response::Sync> that abstract the @@ -28,7 +31,7 @@ from the server like: =item joined rooms =item room invites -It should be noted that the C<.next-batch> will have the C<:since> argument +Beware that the C<.next-batch> will have the C<:since> argument that is passed to the next C<sync>. If not provided, the response will have repeated data. @@ -54,19 +57,21 @@ L<here|https://matrix.org/docs/spec/client_server/r0.3.0.html#post-matrix-client # Passing a hash. my $response = $client.sync( - filter => { room => timeline => limit => 1} + sync-filter => { room => timeline => limit => 1} ); # Passing a json as parameter - my $response = $client.sync( - filter => '{"room":{"timeline":{ "limit": 1}}}' + my $json-response = $client.sync( + sync-filter => '{"room":{"timeline":{ "limit": 1}}}' ); As for now, you can't send a filter_id of an already created filter. -=head2 Sending messages +=head2 Sending events + +There's two ways to send events to a channel. The only event supported +is C<m.room.message> -There's two ways to send messages to a channel. =item C<.send($room-id, $message, :$type)> from C<Matrix::Client> =item C<.send($message, :$type)> from C<Matrix::Client::Room> @@ -79,7 +84,7 @@ Here's an example of the two: =head2 Async loop -The client supports an async loop that can replace a C<loop { $client.sync; … }> +C<Matrix::Client> supports an async loop that can replace a C<loop { $client.sync; … }> since it's a common thing to do. It starts a new thread that runs that loop sending all the events through a C<Supplier>. @@ -88,10 +93,10 @@ sending all the events through a C<Supplier>. react { whenever $supply -> $s { when $s ~~ Matrix::Response::InviteInfo { - say "Got an invite from {$s.room-id} + say "Got an invite from {$s.room-id}"; } - when $s ~~ Matrix::Response::RoomInfo { - say "Got a room event from {$s.room-id} + when $s ~~ Matrix::Response::StateEvent { + say "Got a room event from {$s.room-id}"; } } } |