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) Ok(SendTextMessageTarget::Server)
} else if let Some(client) = &self.client { } else if let Some(client) = &self.client {
if let Some(client) = wrappers::find_client(connection, client, self.strict_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()); return Err("Could not find client.".to_string());
} else { } else {

View file

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