aboutsummaryrefslogtreecommitdiff
path: root/lib/Matrix
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Matrix')
-rw-r--r--lib/Matrix/Client.pm611
-rw-r--r--lib/Matrix/Response.pm614
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/Matrix/Client.pm6 b/lib/Matrix/Client.pm6
index 56be81c..0d4f400 100644
--- a/lib/Matrix/Client.pm6
+++ b/lib/Matrix/Client.pm6
@@ -106,6 +106,17 @@ method whoami {
$!user-id
}
+method presence(Matrix::Client:D: $user-id? --> Matrix::Response::Presence) {
+ my $id = $user-id // $.whoami;
+ my $data = from-json($.get("/presence/$id/status").content);
+ Matrix::Response::Presence.new(|$data)
+}
+
+method set-presence(Matrix::Client:D: Str $presence, Str :$status-message = "") {
+ $.put("/presence/$.whoami/status",
+ :$presence, :status_msg($status-message));
+}
+
# Syncronization
multi method sync(Hash :$sync-filter is copy, :$since = "") {
diff --git a/lib/Matrix/Response.pm6 b/lib/Matrix/Response.pm6
index 57417b7..d8f68f0 100644
--- a/lib/Matrix/Response.pm6
+++ b/lib/Matrix/Response.pm6
@@ -99,3 +99,17 @@ class Matrix::Response::Sync {
:@joined-rooms, :@invited-rooms);
}
}
+
+class Presence {
+ has Str $.presence is required;
+ has Int $.last-active-ago;
+ has Str $.status-message;
+ has Bool $.currently-active;
+
+ submethod BUILD(
+ Str :$!presence,
+ :last_active_ago(:$!last-active-ago) = 0,
+ :status_message(:$!status-message) = "",
+ :currently_active(:$!currently-active) = False
+ ) { }
+}