From ee13d9e117fd82cf88c9bf28d6ce19b331aca1cb Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Thu, 9 Aug 2018 20:18:50 -0300 Subject: Add example to send a message As requested in #12 --- examples/send-message.p6 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 examples/send-message.p6 diff --git a/examples/send-message.p6 b/examples/send-message.p6 new file mode 100644 index 0000000..4824be5 --- /dev/null +++ b/examples/send-message.p6 @@ -0,0 +1,24 @@ +#!/usr/bin/env perl6 +use v6; +use lib 'lib'; +use Matrix::Client; + +sub MAIN(:$room-id?, :$room-alias?, *@args) { + unless $room-id.so || $room-alias.so { + fail 'Missing room-id or room-alias'; + } + my Matrix::Client $client .= new: + :home-server(%*ENV), + :access-token($*ENV); + + my $id; + if $room-id.so { + $id = $room-id; + } else { + say "Searching for $room-alias"; + $id = $client.get-room-id($room-alias); + } + + my $event = $client.send($id, @args.join(' ')); + say $event; +} -- cgit v1.2.3-70-g09d2