summaryrefslogtreecommitdiff
path: root/examples/send-message.raku
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@gmail.com>2020-03-24 19:37:11 -0300
committerMatias Linares <matiaslina@gmail.com>2020-03-24 19:37:11 -0300
commite50b8fa9e02b19ece80ebeb576051e451d3a7812 (patch)
tree037db346e5deacfe21fe0bbae1b496331e3c117e /examples/send-message.raku
parente39257df2688137d57d88d502f7198425d5dfcd5 (diff)
downloadperl6-matrix-client-e50b8fa9e02b19ece80ebeb576051e451d3a7812.tar.gz
Rename some things to from perl6 to raku
Diffstat (limited to 'examples/send-message.raku')
-rw-r--r--examples/send-message.raku24
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/send-message.raku b/examples/send-message.raku
new file mode 100644
index 0000000..2a8202a
--- /dev/null
+++ b/examples/send-message.raku
@@ -0,0 +1,24 @@
+#!/usr/bin/env raku
+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<MATRIX_HOMESERVER>),
+ :access-token($*ENV<MATRIX_ACCESS_TOKEN>);
+
+ 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;
+}