This commit is contained in:
parent
b753bb235d
commit
71ab3b52ec
8 changed files with 36 additions and 10 deletions
|
|
@ -63,6 +63,8 @@ pub struct MessageArgs {
|
|||
client: Option<String>,
|
||||
#[arg(long)]
|
||||
server: bool,
|
||||
#[arg(long)]
|
||||
pub poke: bool,
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
|
|
@ -199,4 +201,4 @@ impl UpdateArgs {
|
|||
|
||||
pub fn init() -> Commands {
|
||||
Cli::parse().command
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,6 +114,12 @@ pub fn sendtextmessage(connection: &mut Telnet, target: SendTextMessageTarget, m
|
|||
send_command(connection, &format!("sendtextmessage {} {}", msg, String::from(target)), false)
|
||||
}
|
||||
|
||||
pub fn clientpoke(connection: &mut Telnet, clid: i32, msg: String) -> Result<Response, String> {
|
||||
let msg = parameter_to_string((String::from("msg"), msg));
|
||||
let clid = parameter_to_string((String::from("clid"), clid.to_string()));
|
||||
send_command(connection, &format!("clientpoke {} {}", msg, clid), false)
|
||||
}
|
||||
|
||||
pub fn clientnotifyregister(connection: &mut Telnet, schandlerid: u32, event: EventType) -> Result<Response, String> {
|
||||
send_command(connection, &format!("clientnotifyregister schandlerid={} event={}", schandlerid, String::from(&event)), false)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ fn main() -> Result<(), Error> {
|
|||
let target = args.target(&mut connection)
|
||||
.map_err(|msg| make_action_error("message target", msg))?;
|
||||
|
||||
match wrappers::send_text_message(&mut connection, target, args.message) {
|
||||
match wrappers::send_text_message(&mut connection, target, args.message, args.poke) {
|
||||
Ok(_) => println!("Successfully sent message."),
|
||||
Err(msg) => {
|
||||
return Err(make_action_error("send message", msg));
|
||||
|
|
@ -184,4 +184,4 @@ fn main() -> Result<(), Error> {
|
|||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,6 +166,15 @@ pub fn update_client(connection: &mut Telnet, parameters: ParameterList) -> Resu
|
|||
commands::clientupdate(connection, parameters)
|
||||
}
|
||||
|
||||
pub fn send_text_message(connection: &mut Telnet, target: SendTextMessageTarget, msg: String) -> Result<Response, String> {
|
||||
commands::sendtextmessage(connection, target, msg)
|
||||
}
|
||||
pub fn send_text_message(connection: &mut Telnet, target: SendTextMessageTarget, msg: String, poke: bool) -> Result<Response, String> {
|
||||
if poke {
|
||||
if let SendTextMessageTarget::Client(client) = target {
|
||||
return commands::clientpoke(connection, client.clid, msg);
|
||||
} else {
|
||||
return Err(String::from("Poke can only be sent to clients."));
|
||||
}
|
||||
}
|
||||
else {
|
||||
commands::sendtextmessage(connection, target, msg)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue