From 89fd81cf9909d804b08dbc8d47d2eb8f82d4c80c Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Sat, 9 Jun 2018 12:39:02 -0300 Subject: Fix examples in documentation --- docs/basics.pod6 | 27 ++++++++++++++++----------- 1 file 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 into it. my Matrix::Client $client .= new: :home-server; $client.login($username, $password); + say $client.access-token; In case you have an access-token, you can pass it as a parameter -to C. In this case is not necessary to call C +to C. In this case is not necessary to call C. my Matrix::Client $client .= new: :home-server, :access-token($access-token); + say $client.whoami; # @yourusername:home-server + =head2 Syncing Calling sync will return a C 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. If not provided, the response will have repeated data. @@ -54,19 +57,21 @@ L { 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 -There's two ways to send messages to a channel. =item C<.send($room-id, $message, :$type)> from C =item C<.send($message, :$type)> from C @@ -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 +C supports an async loop that can replace a C since it's a common thing to do. It starts a new thread that runs that loop sending all the events through a C. @@ -88,10 +93,10 @@ sending all the events through a C. 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}"; } } } -- cgit v1.2.3-54-g00ecf