Add a loop to Matrix login
This commit is contained in:
parent
2e229b70d9
commit
70108247d4
@ -126,6 +126,7 @@ async fn main() {
|
||||
|
||||
let matrix_configuration = bot_configuration.matrix.to_owned();
|
||||
if matrix_configuration.enabled {
|
||||
log_message(Matrix, &"Matrix is enabled! Logging in...".to_string());
|
||||
tokio::spawn(login_and_sync(matrix_configuration, state.clone()));
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ struct MatrixState {
|
||||
}
|
||||
|
||||
pub async fn login_and_sync(matrix_configuration: MatrixConfiguration, bot_state: Arc<State>) {
|
||||
log_message(Matrix, &"Matrix is enabled! Logging in...".to_string());
|
||||
loop {
|
||||
let client_builder =
|
||||
matrix_sdk::Client::builder().homeserver_url(&matrix_configuration.homeserver_url);
|
||||
let client = match client_builder.build().await {
|
||||
@ -67,7 +67,7 @@ pub async fn login_and_sync(matrix_configuration: MatrixConfiguration, bot_state
|
||||
&format!("Successfully logged in as {}!", display_name),
|
||||
);
|
||||
let matrix_state = MatrixState {
|
||||
bot_state,
|
||||
bot_state: bot_state.clone(),
|
||||
matrix_configuration: matrix_configuration.clone(),
|
||||
display_name,
|
||||
};
|
||||
@ -78,6 +78,7 @@ pub async fn login_and_sync(matrix_configuration: MatrixConfiguration, bot_state
|
||||
Ok(_) => (),
|
||||
Err(error) => log_message(MatrixError, &format!("Unable to synchronize: {}", error)),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
async fn room_message_handler(
|
||||
|
Loading…
x
Reference in New Issue
Block a user