From 4e7697c558fa2134e1fc01efc72990138f2745e0 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Tue, 23 Mar 2021 13:03:15 -0700 Subject: feature: Send WORLDSMASTER greeting on join Created function `create_text_command_with_action` which is stable, but only with the preset action. Will expand on this once an understanding of how actions work is met. --- src/cmd/text.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/cmd') diff --git a/src/cmd/text.rs b/src/cmd/text.rs index 6fc42be..a0ada32 100644 --- a/src/cmd/text.rs +++ b/src/cmd/text.rs @@ -17,4 +17,30 @@ pub fn create_text_command(user: &str, message: &str) -> Vec { // from_utf8( // &buffer[6..*&buffer.get(0).unwrap().to_owned() as usize] // ).unwrap() -// } \ No newline at end of file +// } + +pub fn create_text_command_with_action( + user: &str, + message: &str, + // action: &str // Not accepting input until I figure out how actions work. +) -> Vec { + let mut text = Vec::with_capacity(6 + user.len() + message.len()); + text.push(0x01); // ? + text.push(0x0E); // Command type + text.push(0x00); // Assumed to be a divider. + text.push(user.len() as u8); // 'user' length + for i in user.bytes() { text.push(i); } // Pushing 'user' + text.push(message.len() as u8); // 'message' length + for i in message.bytes() { text.push(i); } // Pushing `message` + + let action: [u8; 18] = [ + 0x12, 0x01, 0x11, 0x00, 0x05, 0x54, 0x52, 0x41, + 0x44, 0x45, 0x07, 0x26, 0x7c, 0x2b, 0x69, 0x6e, + 0x76, 0x3e + ]; + for i in action.iter() { text.push(*i); } + + text.insert(0, text.len() as u8 + 1); // Insert data length as first byte. + + text // Return created array +} -- cgit v1.2.3