add admin server uptime command
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
781d4b7907
commit
4b6938e0f6
3 changed files with 26 additions and 3 deletions
|
@ -2,6 +2,24 @@ use ruma::events::room::message::RoomMessageEventContent;
|
|||
|
||||
use crate::{services, Result};
|
||||
|
||||
pub(crate) async fn uptime(_body: Vec<&str>) -> Result<RoomMessageEventContent> {
|
||||
let seconds = services()
|
||||
.globals
|
||||
.started
|
||||
.elapsed()
|
||||
.expect("standard duration")
|
||||
.as_secs();
|
||||
let result = format!(
|
||||
"up {} days, {} hours, {} minutes, {} seconds.",
|
||||
seconds / 86400,
|
||||
(seconds % 86400) / 60 / 60,
|
||||
(seconds % 3600) / 60,
|
||||
seconds % 60,
|
||||
);
|
||||
|
||||
Ok(RoomMessageEventContent::notice_html(String::new(), result))
|
||||
}
|
||||
|
||||
pub(crate) async fn show_config(_body: Vec<&str>) -> Result<RoomMessageEventContent> {
|
||||
// Construct and send the response
|
||||
Ok(RoomMessageEventContent::text_plain(format!("{}", services().globals.config)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue