1
Fork 0
mirror of https://github.com/Steffo99/patched-porobot.git synced 2024-12-22 17:44:22 +00:00

Slight progress on the matrix client

This commit is contained in:
Steffo 2023-04-26 13:17:37 +00:00 committed by GitHub
parent 62ec6fa3f7
commit 2cf07a9c64
Signed by: github
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
}
}