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,
|
sender: User,
|
||||||
contents: String,
|
contents: String,
|
||||||
timestamp: time::OffsetDateTime,
|
timestamp: time::OffsetDateTime,
|
||||||
me_message: bool
|
me_message: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
type Channel = Arc<Mutex<UnwrappedChannel>>;
|
type Channel = Arc<Mutex<UnwrappedChannel>>;
|
||||||
|
@ -170,7 +170,7 @@ fn handle_client(mut stream: TcpStream, channel: Channel) {
|
||||||
sender: netbot.clone(),
|
sender: netbot.clone(),
|
||||||
contents: format!("User {} has joined!", user.name),
|
contents: format!("User {} has joined!", user.name),
|
||||||
timestamp: time::OffsetDateTime::now_local().unwrap(),
|
timestamp: time::OffsetDateTime::now_local().unwrap(),
|
||||||
me_message: false
|
me_message: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut buf = Vec::<u8>::new();
|
let mut buf = Vec::<u8>::new();
|
||||||
|
@ -190,7 +190,7 @@ fn handle_client(mut stream: TcpStream, channel: Channel) {
|
||||||
sender: netbot.clone(),
|
sender: netbot.clone(),
|
||||||
contents: format!("User {} has left.", user.name),
|
contents: format!("User {} has left.", user.name),
|
||||||
timestamp: time::OffsetDateTime::now_local().unwrap(),
|
timestamp: time::OffsetDateTime::now_local().unwrap(),
|
||||||
me_message: false
|
me_message: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
recieve_terminate_send.send(()).unwrap();
|
recieve_terminate_send.send(()).unwrap();
|
||||||
|
@ -211,10 +211,12 @@ fn handle_client(mut stream: TcpStream, channel: Channel) {
|
||||||
sender: user.clone(),
|
sender: user.clone(),
|
||||||
contents,
|
contents,
|
||||||
timestamp: time::OffsetDateTime::now_local().unwrap(),
|
timestamp: time::OffsetDateTime::now_local().unwrap(),
|
||||||
me_message: false
|
me_message: false,
|
||||||
});
|
});
|
||||||
} else {
|
} 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
|
stream
|
||||||
.write_all(
|
.write_all(
|
||||||
b"\x1b[0m\x1b[32mValid commands:\n \
|
b"\x1b[0m\x1b[32mValid commands:\n \
|
||||||
|
@ -227,7 +229,9 @@ fn handle_client(mut stream: TcpStream, channel: Channel) {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
} else if contents.split(" ").collect::<Vec<&str>>()[0] == "/me" {
|
} 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
|
stream
|
||||||
.write_fmt(format_args!(
|
.write_fmt(format_args!(
|
||||||
"\x1b[0m\x1b[31mYou need to provide at least one argument to /me!\n\x1b[0m",
|
"\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(),
|
sender: user.clone(),
|
||||||
contents: contents.replace("/me ", ""),
|
contents: contents.replace("/me ", ""),
|
||||||
timestamp: time::OffsetDateTime::now_local().unwrap(),
|
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>>();
|
let contents = contents.split(" ").collect::<Vec<&str>>();
|
||||||
if contents.len() == 1 {
|
if contents.len() == 1 {
|
||||||
stream
|
stream
|
||||||
|
|
Loading…
Add table
Reference in a new issue