1
Fork 0
mirror of https://github.com/Steffo99/patched-porobot.git synced 2025-01-03 15:34:18 +00:00

Save data from the imploding codespace

This commit is contained in:
Steffo 2023-04-19 07:46:57 +00:00 committed by GitHub
parent be7b6b8bbe
commit 3b77ddb11c
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 1 deletions

View file

@ -49,7 +49,7 @@ exec = ["pretty_env_logger"]
search = ["tantivy"] search = ["tantivy"]
telegram = ["exec", "search", "teloxide", "reqwest", "tokio", "md5", "rand"] telegram = ["exec", "search", "teloxide", "reqwest", "tokio", "md5", "rand"]
discord = ["exec", "search", "serenity", "tokio", "anyhow"] discord = ["exec", "search", "serenity", "tokio", "anyhow"]
matrix = ["exec", "search", "matrix-sdk"] matrix = ["exec", "search", "matrix-sdk", "anyhow"]
[lib] [lib]

29
src/matrix/main.rs Normal file
View file

@ -0,0 +1,29 @@
use std::env;
use matrix_sdk::{Client};
use matrix_sdk::config::{SyncRoomMessageEvent, SyncSettings};
#[tokio::main]
async fn main() -> ! {
let homeserver_url = env::var("MATRIX_HOMESERVER_URL")
.expect("MATRIX_HOMESERVER_URL to be defined");
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 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;
}

View file

@ -1,3 +1,5 @@
//! Module providing utilities to be used in the `patched_porobot_matrix` executable target. //! Module providing utilities to be used in the `patched_porobot_matrix` executable target.
//! //!
//! While adding new features to this module, remember that binaries [can only access the public API of the crate](https://doc.rust-lang.org/cargo/reference/cargo-targets.html#binaries), as they considered a separate crate from the rest of the project. //! While adding new features to this module, remember that binaries [can only access the public API of the crate](https://doc.rust-lang.org/cargo/reference/cargo-targets.html#binaries), as they considered a separate crate from the rest of the project.
pub(crate) mod main;