#
# $Source: /home/nlfm/Working/Zircon/Released/lib/RCS/userCmds.tcl,v $
# $Date: 1997/02/11 16:38:57 $
# $Revision: 1.18.1.6 $
#
package provide zircon 1.18
#
#	Users cmds
#
proc doInvite {net nk chan} {
    switch {} $nk return
    switch {} $chan return
    $net configure -lastuser $nk
    $net INVITE $nk $chan
}

proc userInvite {net chan} {
    global ztrans
    set lu [$net lastuser]
    mkEntryBox .@inv$net $ztrans(invite) {Enter user and channel:} \
      [list [list $ztrans(user) $lu] [list $ztrans(channel) $chan]] \
      "$ztrans(ok) {doInvite $net}" "$ztrans(cancel) {}"
}
#
proc doMsg {net nk} {
    switch {} $nk return
    Message :: make $nk $net
    $net configure -lastuser $nk
}
#
proc userMessage {net} {
    global ztrans
    mkEntryBox .@msg$net $ztrans(message) {Enter user name:} \
      [list [list $ztrans(user) [$net lastuser]]] \
      "$ztrans(ok) {doMsg $net}" "$ztrans(cancel) {}"
}
#
proc doFing {net nk} {
    switch {} $nk return
    $net configure -lastuser $nk
    finger $net $nk
} 
#
proc userFinger {net} {
    global ztrans
    mkEntryBox .@fng$net $ztrans(finger) {Enter user name:} \
      [list [list $ztrans(user) [$net lastuser]]] \
      "$ztrans(ok) {doFing $net}" "$ztrans(cancel) {}"
}
#
proc userNotice {net} {
    global ztrans
    mkEntryBox .@not$net $ztrans(notice) {Enter user name and notice text:} \
      [list [list $ztrans(user) [$net lastuser]] [list $ztrans(notice) {}]] \
      "$ztrans(ok) {doNet $net NOTICE}" "$ztrans(cancel) {}"
}
#
proc doNet {net cmd nk op} {
    switch {} $nk return
    $net configure -lastuser $nk
    $net $cmd $nk $op
}
#
proc userWhois {net} {
    global ztrans
    mkEntryBox .@wis$net $ztrans(whois) {Enter user name and server:} \
      [list [list $ztrans(user) [$net lastuser]] [list Where {}]] \
      "$ztrans(ok) {doNet $net WHOIS}" "$ztrans(cancel) {}"
}
#
proc userWhowas {net} {
    global ztrans
    mkEntryBox .@was$net $ztrans(whowas) {Enter user name and count:} \
      [list [list $ztrans(user) [$net lastuser]] [list Count {}]] "\
      $ztrans(ok) {doNet $net WHOWAS}" "$ztrans(cancel) {}"
}
#
proc doUMode {net nk mode} {
    if {![string match {} $nk] && [string match {[+-]*} mode]} {
	$net configure -lastuser $Nk
	$net qSend MODE $nk :$mode
    }
}
#
proc userMode {net} {
    global ztrans
    mkEntryBox .@umd$net {User Mode} {Enter user and mode:} \
      [list [list $ztrans(user) [$net lastuser]] [list $ztrans(mode) {}]] \
      "$ztrans(ok) {doUMode $net}" "$ztrans(cancel) {}"
}
#
proc userCmd {net cmd args} {
    switch -exact -- $cmd {
    Mode { userMode $net}
    Finger {userFinger $net}
    Invite { userInvite $net {} }
    Message {userMessage $net}
    Notice {userNotice $net}
    Kill {userKill $net}
    Whois {userWhois $net}
    Whowas {userWhowas $net}
    default {
	    global ztrans
	    mkEntryBox .@$cmd$net [trans $cmd] {Enter user pattern:} \
	      [list [list $ztrans(user) [$net lastuser]]] \
	      "$ztrans(ok) {uSend $net [string toupper $cmd]}" \
	      "$ztrans(cancel) {}"
	}
    }
}
#
proc uSend {net cmd nk} {
    switch {} $nk return
    $net configure -lastuser $nk
    $net qSend $cmd :$nk
}


