=== modified file 'zirc' --- zirc 2006-06-30 09:12:14 +0000 +++ zirc 2006-06-30 12:15:17 +0000 @@ -50,8 +50,7 @@ zirc_disconnect fi -ZIRC_VARS=( ZIRC_LAST ZIRC_CHANNELS ZIRC_CURRENT ZIRC_LOWERCASER ZIRC_FD ZIRC_S -ERVER "${ZIRC_PARAMS[@]}" ) +ZIRC_VARS=( ZIRC_LAST ZIRC_CHANNELS ZIRC_CURRENT ZIRC_LOWERCASER ZIRC_FD ZIRC_SERVER "${ZIRC_PARAMS[@]}" ) ZIRC_UNSETSTRING="unset ${ZIRC_VARS[*]}" eval "$ZIRC_UNSETSTRING" @@ -919,6 +918,140 @@ ! [[ -z "$ZIRC_FD" ]] } +# Sets channel modes +function zirc_mode { + local modes="${(j: :)@}" + + if [[ -z "$modes" ]]; then + echo "Usage: $0 " + echo "Set channel modes to ." + echo "Sends to the current focus (Current: '$ZIRC_CURRENT')." + return 1 + fi + zirc_connected || { echo "Not connected" ; return 1 } + _zirc_write "MODE ${ZIRC_CURRENT} ${modes}" +} + +# Set a single mode for a list of users +function _zirc_batch_mode { + local mode="$1" + shift + local users="${(j: :)@}" + + for user in $users; do + zirc_mode "$mode" "$user" + done +} + +# Give operator status to user(s) +function zirc_op { + if [[ -z "$@" ]]; then + echo "Usage: $0 " + echo "Give operator status to ." + echo "Works on the current focus (Current: '$ZIRC_CURRENT')." + return 1 + fi + + zirc_connected || { echo "Not connected" ; return 1} + + _zirc_batch_mode "+o" $@ +} + +# Revoke operator status from user(s) +function zirc_deop { + if [[ -z "$@" ]]; then + echo "Usage: $0 " + echo "Revoke operator status from ." + echo "Works on the current focus (Current: '$ZIRC_CURRENT')." + return 1 + fi + + zirc_connected || { echo "Not connected" ; return 1} + + _zirc_batch_mode "-o" $@ +} + +# Give a voice flag to user(s) +function zirc_voice { + if [[ -z "$@" ]]; then + echo "Usage: $0 " + echo "Give a voice flag to ." + echo "Works on the current focus (Current: '$ZIRC_CURRENT')." + return 1 + fi + + zirc_connected || { echo "Not connected" ; return 1} + + _zirc_batch_mode "+v" $@ +} + +# Revoke the voice flag from user(s) +function zirc_devoice { + if [[ -z "$@" ]]; then + echo "Usage: $0 " + echo "Revoke the voice flag from ." + echo "Works on the current focus (Current: '$ZIRC_CURRENT')." + return 1 + fi + + zirc_connected || { echo "Not connected" ; return 1} + + _zirc_batch_mode "-v" $@ +} + +# Query the names on a channel +function zirc_names { + zirc_connected || { echo "Not connected" ; return 1} + + _zirc_write "NAMES $ZIRC_CURRENT" +} + +# Issue a WHOIS request +function zirc_whois { + if [[ -z "$1" ]]; then + echo "Usage: $0 " + echo "Get detailed information about ." + return 1 + fi + + zirc_connected || { echo "Not connected" ; return 1} + + _zirc_write "WHOIS $1" +} + +# Issue a WHO request +function zirc_who { + local chan="${1:-${ZIRC_CURRENT}}" + + zirc_connected || { echo "Not connected" ; return 1} + + _zirc_write "WHO $chan" +} + +# Kick user from the current channel +function zirc_kick { + if [[ -z "$@" ]]; then + echo "Usage: $0 []" + echo "Kick from the current channel, due to ." + echo "Works on the current focus (Current: '$ZIRC_CURRENT')." + return 1 + fi + + zirc_connected || { echo "Not connected" ; return 1} + + local user=$1 + shift + + _zirc_write "KICK $ZIRC_CURRENT $user ${@:+:$@}" +} + +# Sets/unsets the automatic away message +function zirc_away { + zirc_connected || { echo "Not connected" ; return 1} + + _zirc_write "AWAY ${@:+:$@}" +} + # Connect to a server function zirc_connect { if ! [[ -z "$ZIRC_FD" ]]; then @@ -980,5 +1113,15 @@ alias query='zirc_query' alias connect='zirc_connect' alias help='zirc_help' + alias mode='zirc_mode' + alias op='zirc_op' + alias deop='zirc_deop' + alias voice='zirc_voice' + alias devoice='zirc_devoice' + alias names='zirc_names' + alias whois='zirc_whois' + alias who='zirc_who' + alias kick='zirc_kick' + alias away='zirc_away' } # }}}3