Add message to ts-control

This commit is contained in:
Tobias Reisinger 2023-11-26 22:40:41 +01:00
parent fa959136be
commit a9fd240bd3
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
2 changed files with 32 additions and 16 deletions

View file

@ -109,7 +109,7 @@ impl MessageArgs {
Ok(SendTextMessageTarget::Server)
} else if let Some(client) = &self.client {
if let Some(client) = wrappers::find_client(connection, client, self.strict_client)? {
return Ok(SendTextMessageTarget::Client(client.cid));
return Ok(SendTextMessageTarget::Client(client.clid));
}
return Err("Could not find client.".to_string());
} else {

View file

@ -5,24 +5,34 @@ fetch-client
fetch-channel
away
not away
back"
back
message
message-user"
action=$(echo "$actions" | $DMENU)
_ts_control_get_entity() {
entity=$(teamspeak-query-lib "$1s" | $DMENU)
if [ -z "$entity" ]; then
exit 1
fi
echo "$entity"
}
_ts_control_get_message() {
message=$(printf "\n" | $DMENU -p "message")
if [ -z "$message" ]; then
exit 1
fi
echo "$message"
}
_ts_control_move_self() {
channel=$(teamspeak-query-lib channels | $DMENU)
if [ -z "$channel" ]; then
return 1
fi
channel=$(_ts_control_get_entity channel)
teamspeak-query-lib move --strict-channel "$channel"
return 0
}
_ts_control_fetch() {
target=$(teamspeak-query-lib "$1s" | $DMENU)
if [ -z "$target" ]; then
exit 1
fi
target=$(_ts_control_get_entity "$1")
teamspeak-query-lib fetch "--strict-$1" "--$1" "$target"
}
@ -41,10 +51,7 @@ case $action in
teamspeak-query-lib update --microphone=false --speakers=false
;;
"away")
message=$(printf "\n" | $DMENU -p "message")
if [ -z "$message" ]; then
exit 1
fi
message=$(_ts_control_get_message)
teamspeak-query-lib move "Away From Keyboard"
teamspeak-query-lib update --away "$message"
teamspeak-query-lib update --microphone=false --speakers=false --away "$message"
@ -54,4 +61,13 @@ case $action in
ts_control_move_self
teamspeak-query-lib update --microphone=true --speakers=true
;;
"message")
message=$(_ts_control_get_message)
teamspeak-query-lib message "$message"
;;
"message-user")
message=$(_ts_control_get_message)
user=$(_ts_control_get_entity client)
teamspeak-query-lib message --strict-client --client "$user" "$message"
;;
esac