Run Matrix commands in a task
This commit is contained in:
parent
04cd440c50
commit
771057925d
@ -97,7 +97,7 @@ async fn room_message_handler(
|
|||||||
.contains(&event.sender.to_string())
|
.contains(&event.sender.to_string())
|
||||||
&& text_content.body.starts_with(&state.display_name)
|
&& text_content.body.starts_with(&state.display_name)
|
||||||
{
|
{
|
||||||
let bot_state = &state.bot_state;
|
let bot_state = state.bot_state.clone();
|
||||||
let client = bot_state.client.lock().unwrap().to_owned();
|
let client = bot_state.client.lock().unwrap().to_owned();
|
||||||
let mut client = match client {
|
let mut client = match client {
|
||||||
Some(client) => client,
|
Some(client) => client,
|
||||||
@ -114,7 +114,7 @@ async fn room_message_handler(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let command = &text_content
|
let command = text_content
|
||||||
.body
|
.body
|
||||||
.trim_start_matches(&state.display_name)
|
.trim_start_matches(&state.display_name)
|
||||||
.trim_start_matches(":")
|
.trim_start_matches(":")
|
||||||
@ -128,6 +128,7 @@ async fn room_message_handler(
|
|||||||
command
|
command
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
tokio::task::spawn(async move {
|
||||||
log_error(
|
log_error(
|
||||||
room.send(
|
room.send(
|
||||||
RoomMessageEventContent::text_plain(
|
RoomMessageEventContent::text_plain(
|
||||||
@ -143,6 +144,7 @@ async fn room_message_handler(
|
|||||||
)
|
)
|
||||||
.await,
|
.await,
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user