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();
|
let matrix_configuration = bot_configuration.matrix.to_owned();
|
||||||
if matrix_configuration.enabled {
|
if matrix_configuration.enabled {
|
||||||
|
log_message(Matrix, &"Matrix is enabled! Logging in...".to_string());
|
||||||
tokio::spawn(login_and_sync(matrix_configuration, state.clone()));
|
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>) {
|
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 =
|
let client_builder =
|
||||||
matrix_sdk::Client::builder().homeserver_url(&matrix_configuration.homeserver_url);
|
matrix_sdk::Client::builder().homeserver_url(&matrix_configuration.homeserver_url);
|
||||||
let client = match client_builder.build().await {
|
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),
|
&format!("Successfully logged in as {}!", display_name),
|
||||||
);
|
);
|
||||||
let matrix_state = MatrixState {
|
let matrix_state = MatrixState {
|
||||||
bot_state,
|
bot_state: bot_state.clone(),
|
||||||
matrix_configuration: matrix_configuration.clone(),
|
matrix_configuration: matrix_configuration.clone(),
|
||||||
display_name,
|
display_name,
|
||||||
};
|
};
|
||||||
@ -79,6 +79,7 @@ pub async fn login_and_sync(matrix_configuration: MatrixConfiguration, bot_state
|
|||||||
Err(error) => log_message(MatrixError, &format!("Unable to synchronize: {}", error)),
|
Err(error) => log_message(MatrixError, &format!("Unable to synchronize: {}", error)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async fn room_message_handler(
|
async fn room_message_handler(
|
||||||
event: OriginalSyncRoomMessageEvent,
|
event: OriginalSyncRoomMessageEvent,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user