1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Add version info chat command

This commit is contained in:
NG (Graham)
2025-09-14 12:23:37 -04:00
parent 525fa8b87e
commit c9f9d146e8
6 changed files with 29 additions and 0 deletions

1
Cargo.lock generated
View File

@@ -2669,6 +2669,7 @@ dependencies = [
"async-trait",
"clap",
"env_logger",
"git-version",
"log",
"oj_polariton_auth",
"oj_rc_core",

View File

@@ -14463,6 +14463,13 @@
"built_in": "TotalUsers"
}
},
{
"regex": "\\?version",
"op": {
"type": "BuiltIn",
"built_in": "Version"
}
},
{
"regex": "\\?help",
"op": {

View File

@@ -20,3 +20,4 @@ serde.workspace = true
serde_json.workspace = true
regex = "1"
async-trait.workspace = true
git-version.workspace = true

View File

@@ -109,6 +109,7 @@ impl ChatOperation {
enum BuiltIn {
OnlineUsers,
TotalUsers,
Version,
Help,
}
@@ -117,6 +118,7 @@ impl BuiltIn {
match b_in {
oj_rc_core::persist::BuiltInChatOperation::OnlineUsers => Self::OnlineUsers,
oj_rc_core::persist::BuiltInChatOperation::TotalUsers => Self::TotalUsers,
oj_rc_core::persist::BuiltInChatOperation::Version => Self::Version,
oj_rc_core::persist::BuiltInChatOperation::Help => Self::Help,
}
}
@@ -145,6 +147,15 @@ impl BuiltIn {
Err(e) => e.error_msg().map(|x| x.to_owned()).unwrap_or_else(|| "Failed to retrieve registered users".to_owned()),
}
},
Self::Version => {
let name = env!("CARGO_PKG_NAME");
let version = env!("CARGO_PKG_VERSION");
let git_version = git_version::git_version!(args = ["--always", "--dirty=+"]);
let authors = env!("CARGO_PKG_AUTHORS");
let license = env!("CARGO_PKG_LICENSE");
let repo = env!("CARGO_PKG_REPOSITORY");
format!("{} {}:{}\n[{}]\n{} {}", name, version, git_version, authors, license, repo)
}
Self::Help => {
use core::fmt::Write;
let mut msg = String::new();
@@ -164,6 +175,7 @@ impl BuiltIn {
match self {
Self::OnlineUsers => "Show total users online".to_owned(),
Self::TotalUsers => "Show total users registered".to_owned(),
Self::Version => "Show chat server version information".to_owned(),
Self::Help => "Display this message".to_owned(),
}
}

View File

@@ -33,6 +33,7 @@ pub enum ChatOperation {
pub enum BuiltInChatOperation {
OnlineUsers,
TotalUsers,
Version,
Help,
}

View File

@@ -474,6 +474,13 @@ def main(asset_in, cubes=None, weapons=None, movement=None):
"built_in": "TotalUsers"
}
},
{
"regex": "\\?version",
"op": {
"type": "BuiltIn",
"built_in": "Version"
}
},
{
"regex": "\\?help",
"op": {