#by wiebe @ QuakeNet



#help trout pub
bind pubm fvlomn|fvlomn "% ${botnet-nick} help trout" c_trout:help:pub

proc c_trout:help:pub { nick uhost handle chan text } {
  c_trout:pub $nick $uhost $handle $chan ""
  putloglev c $chan "[lindex [split $text] 1]: $nick $uhost $handle $chan [join [lrange [split $text] 2 end]]"
}



#help trout msg
bind msgm fvlomn|fvlomn "help trout" c_trout:help:msg

proc c_trout:help:msg { nick uhost handle text } {
  c_trout:msg $nick $uhost $handle ""
  putcmdlog "($nick!$uhost) !$handle! $text"
}



#trout pub
bind pubm fvlomn|fvlomn "% ${botnet-nick} trout" c_trout:pub
bind pubm fvlomn|fvlomn "% ${botnet-nick} trout *" c_trout:pub

proc c_trout:pub { nick uhost handle chan text } {
  set target [join [lrange [split $text] 2 end]]
  if { ![string equal $target ""] } {
    puthelp "PRIVMSG $chan :\001ACTION slaps $target around a bit with a large trout\001"
    lappend output "Slapped $target on $chan"
  } else {
    lappend output "Usage: trout <nick>"
  }
  if { [catch {set x [cnotice $nick $output]} error] || !$x } {
    foreach t $output { puthelp "NOTICE $nick :$t" }
  }
  putloglev c $chan "[lindex [split $text] 1]: $nick $uhost $handle $chan [join [lrange [split $text] 2 end]]"
}



#trout msg
bind msg fvlomn|fvlomn trout c_trout:msg

proc c_trout:msg { nick uhost handle text } {
  set chan [lindex [split $text] 0]
  set target [join [lrange [split $text] 1 end]]
  if { ![validchan $chan] && ![string equal $chan ""] } {
    lappend output "No access or unknown channel $chan"
  } elseif { [string equal $chan ""] || [string equal $target ""] } {
    lappend output "Usage: trout <channel> <nick>"
  } elseif { ![matchattr $handle fvlomn|fvlomn $chan] } {
    lappend output "No access or unknown channel $chan"
  } elseif { ![botonchan $chan] } {
    lappend output "I am not on channel on $chan"
  } else {
    puthelp "PRIVMSG $chan :\001ACTION slaps $target around a bit with a large trout\001"
    lappend output "Slapped $target on $chan"  }
  if { [catch {set x [cnotice $nick $output]} error] || !$x } {
    foreach t $output { puthelp "NOTICE $nick :$t" }
  }
  return 1
}

