Format
This commit is contained in:
parent
cb0eaeec91
commit
25de01961f
1 changed files with 14 additions and 8 deletions
22
src/main.rs
22
src/main.rs
|
@ -37,7 +37,7 @@ struct Message {
|
|||
sender: User,
|
||||
contents: String,
|
||||
timestamp: time::OffsetDateTime,
|
||||
me_message: bool
|
||||
me_message: bool,
|
||||
}
|
||||
|
||||
type Channel = Arc<Mutex<UnwrappedChannel>>;
|
||||
|
@ -170,7 +170,7 @@ fn handle_client(mut stream: TcpStream, channel: Channel) {
|
|||
sender: netbot.clone(),
|
||||
contents: format!("User {} has joined!", user.name),
|
||||
timestamp: time::OffsetDateTime::now_local().unwrap(),
|
||||
me_message: false
|
||||
me_message: false,
|
||||
});
|
||||
|
||||
let mut buf = Vec::<u8>::new();
|
||||
|
@ -190,7 +190,7 @@ fn handle_client(mut stream: TcpStream, channel: Channel) {
|
|||
sender: netbot.clone(),
|
||||
contents: format!("User {} has left.", user.name),
|
||||
timestamp: time::OffsetDateTime::now_local().unwrap(),
|
||||
me_message: false
|
||||
me_message: false,
|
||||
});
|
||||
|
||||
recieve_terminate_send.send(()).unwrap();
|
||||
|
@ -211,10 +211,12 @@ fn handle_client(mut stream: TcpStream, channel: Channel) {
|
|||
sender: user.clone(),
|
||||
contents,
|
||||
timestamp: time::OffsetDateTime::now_local().unwrap(),
|
||||
me_message: false
|
||||
me_message: false,
|
||||
});
|
||||
} else {
|
||||
if contents.split(" ").collect::<Vec<&str>>()[0] == "/help" || contents.split(" ").collect::<Vec<&str>>()[0] == "/?" {
|
||||
if contents.split(" ").collect::<Vec<&str>>()[0] == "/help"
|
||||
|| contents.split(" ").collect::<Vec<&str>>()[0] == "/?"
|
||||
{
|
||||
stream
|
||||
.write_all(
|
||||
b"\x1b[0m\x1b[32mValid commands:\n \
|
||||
|
@ -227,7 +229,9 @@ fn handle_client(mut stream: TcpStream, channel: Channel) {
|
|||
)
|
||||
.unwrap();
|
||||
} else if contents.split(" ").collect::<Vec<&str>>()[0] == "/me" {
|
||||
if contents.split(" ").collect::<Vec<&str>>().len() < 2 || contents.split(" ").collect::<Vec<&str>>()[1] == "" {
|
||||
if contents.split(" ").collect::<Vec<&str>>().len() < 2
|
||||
|| contents.split(" ").collect::<Vec<&str>>()[1] == ""
|
||||
{
|
||||
stream
|
||||
.write_fmt(format_args!(
|
||||
"\x1b[0m\x1b[31mYou need to provide at least one argument to /me!\n\x1b[0m",
|
||||
|
@ -238,10 +242,12 @@ fn handle_client(mut stream: TcpStream, channel: Channel) {
|
|||
sender: user.clone(),
|
||||
contents: contents.replace("/me ", ""),
|
||||
timestamp: time::OffsetDateTime::now_local().unwrap(),
|
||||
me_message: true
|
||||
me_message: true,
|
||||
});
|
||||
}
|
||||
} else if contents.split(" ").collect::<Vec<&str>>()[0] == "/status" || contents == "/user" {
|
||||
} else if contents.split(" ").collect::<Vec<&str>>()[0] == "/status"
|
||||
|| contents == "/user"
|
||||
{
|
||||
let contents = contents.split(" ").collect::<Vec<&str>>();
|
||||
if contents.len() == 1 {
|
||||
stream
|
||||
|
|
Loading…
Add table
Reference in a new issue