#by wiebe @ QuakeNet
#requires showmode.tcl



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

proc c_showmode:help:pub { nick uhost handle chan text } {
  lappend output "Usage: showmode <channel>"
  lappend output "Shows the modes and creation time for the given channel."
  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]]"
}



#help showmode msg
bind msgm fvlomn|fvlomn "help showmode" c_showmode:help:msg

proc c_showmode:help:msg { nick uhost handle text } {
  lappend output "Usage: showmode <channel>"
  lappend output "Shows the modes and creation time for the given channel where the bot is."
  if { [catch {set x [cnotice $nick $output]} error] || !$x } {
    foreach t $output { puthelp "NOTICE $nick :$t" }
  }
  putcmdlog "($nick!$uhost) !$handle! $text"
}



#showmode pub
bind pubm fvlomn|fvlomn "% ${botnet-nick} showmode" c_showmode:pub
bind pubm fvlomn|fvlomn "% ${botnet-nick} showmode *" c_showmode:pub

proc c_showmode:pub { nick uhost handle chan text } {
  set text2 [join [lrange [split $text] 2 end]]
  if { [catch {showmode:pub $nick $uhost $handle $chan $text2} error] } {
    putlog "ERROR using showmode.tcl, perhaps you have not loaded it?"
    error $error
  }
  putloglev c $chan "[lindex [split $text] 1]: $nick $uhost $handle $chan [join [lrange [split $text] 2 end]]"
}



#showmode msg
bind msg fvlomn|fvlomn showmode c_showmode:msg

proc c_showmode:msg { nick uhost handle text } {
  set chan [lindex [split $text] 0]
  if { ![validchan $chan] && ![string equal $chan ""] } {
    lappend output "No access or unknown channel $chan"
  } elseif { [string equal $chan ""] } {
    lappend output "Usage: showmode <channel>"
  } elseif { ![matchattr $handle fvlomn|fvlomn $chan] } {
    lappend output "No access or unknown channel $chan"
  } elseif { ![botonchan $chan] } {
    lappend output "I am not on channel $chan"
  } else {
    set mode [lindex [split [getchanmode $chan]] 0]
    lappend output "Modes on $chan are $mode"
  }
  if { [catch {set x [cnotice $nick $output]} error] || !$x } {
    foreach t $output { puthelp "NOTICE $nick :$t" }
  }
  return 1
}

