diff --git a/Cargo.lock b/Cargo.lock index e6b952c..977e03c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2669,6 +2669,7 @@ dependencies = [ "async-trait", "clap", "env_logger", + "git-version", "log", "oj_polariton_auth", "oj_rc_core", diff --git a/assets/robocraft/config.json b/assets/robocraft/config.json index 3061bc7..3ae87fc 100644 --- a/assets/robocraft/config.json +++ b/assets/robocraft/config.json @@ -14463,6 +14463,13 @@ "built_in": "TotalUsers" } }, + { + "regex": "\\?version", + "op": { + "type": "BuiltIn", + "built_in": "Version" + } + }, { "regex": "\\?help", "op": { diff --git a/rc_chat_room/Cargo.toml b/rc_chat_room/Cargo.toml index e2664db..959489e 100644 --- a/rc_chat_room/Cargo.toml +++ b/rc_chat_room/Cargo.toml @@ -20,3 +20,4 @@ serde.workspace = true serde_json.workspace = true regex = "1" async-trait.workspace = true +git-version.workspace = true diff --git a/rc_chat_room/src/state/chat/config.rs b/rc_chat_room/src/state/chat/config.rs index ecc2869..58b4df1 100644 --- a/rc_chat_room/src/state/chat/config.rs +++ b/rc_chat_room/src/state/chat/config.rs @@ -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(), } } diff --git a/rc_core/src/persist/chat.rs b/rc_core/src/persist/chat.rs index 29beba4..f3dc1d6 100644 --- a/rc_core/src/persist/chat.rs +++ b/rc_core/src/persist/chat.rs @@ -33,6 +33,7 @@ pub enum ChatOperation { pub enum BuiltInChatOperation { OnlineUsers, TotalUsers, + Version, Help, } diff --git a/utils/cube_gen.py b/utils/cube_gen.py index 524a0e0..2d651c8 100755 --- a/utils/cube_gen.py +++ b/utils/cube_gen.py @@ -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": {