From 2cf07a9c64321b393d0f25f858e49c7ec1dc2e42 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 26 Apr 2023 13:17:37 +0000 Subject: [PATCH] Slight progress on the matrix client --- src/matrix/main.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/matrix/main.rs b/src/matrix/main.rs index 5960d07..62bc8b9 100644 --- a/src/matrix/main.rs +++ b/src/matrix/main.rs @@ -1,6 +1,7 @@ use std::env; -use matrix_sdk::{Client}; -use matrix_sdk::config::{SyncRoomMessageEvent, SyncSettings}; +use matrix_sdk::{Client, LoginBuilder}; +use matrix_sdk::config::{SyncSettings}; +use matrix_sdk::ruma::events::room::message::{SyncRoomMessageEvent}; #[tokio::main] @@ -11,19 +12,20 @@ async fn main() -> ! { let user_id: String = env::var("MATRIX_USER_ID") .expect("MATRIX_USER_ID to be defined"); - let user_password: String = env::var("MATRIX_USER_PASSWORD") - .expect("MATRIX_USER_PASSWORD to be defined"); + + let shared_secret: String = env::var("MATRIX_SHARED_SECRET") + .expect("MATRIX_SHARED_SECRET to be defined"); let client = Client::builder() .homeserver_url(homeserver_url) .build() .await?; - - client.login_username(&user_id, &user_password).send().await?; client.add_event_handler(|ev: SyncRoomMessageEvent| async move { println!("Received a message {:?}", ev); }); - client.sync(SyncSettings::default()).await; + loop { + client.sync(SyncSettings::default()).await; + } } \ No newline at end of file