#by wiebe @ Quakenet



#help resetbans pub
bind pubm mn|mn "% ${botnet-nick} help resetbans" c_resetbans:help:pub

proc c_resetbans:help:pub { nick uhost handle chan text } {
  lappend output "Usage: resetbans"
  lappend output "Removes all bans on the channel that aren't in the bot's ban list and refreshes any bans that should be on the channel but aren't."
  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 resetbans msg
bind msgm mn|mn "help resetbans" c_resetbans:help:msg

proc c_resetbans:help:msg { nick uhost handle text } {
  lappend output "Usage: resetbans <channel>"
  lappend output "Removes all bans on the channel that aren't in the bot's ban list and refreshes any bans that should be on the channel but aren't."
  if { [catch {set x [cnotice $nick $output]} error] || !$x } {
    foreach t $output { puthelp "NOTICE $nick :$t" }
  }
  putcmdlog "($nick!$uhost) !$handle! $text"
}



#resetbans pub
bind pubm mn|mn "% ${botnet-nick} resetbans" c_resetbans:pub
bind pubm mn|mn "% ${botnet-nick} resetbans *" c_resetbans:pub

proc c_resetbans:pub { nick uhost handle chan text } {
  set resetbans [lindex [split $text] 2]
  if { ![botisop $chan] && ![botishalfop $chan] } {
    lappend output "I am not a channel operator on $chan"
  } else {
    resetbans $chan    lappend output "Bans were reset on $chan"
  }
  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]]"
}



#resetbans msg
bind msg mn|mn resetbans c_resetbans:msg

proc c_resetbans:msg { nick uhost handle text } {
  set chan [lindex [split $text] 0]
  set resetbans [lindex [split $text] 1]
  if { ![validchan $chan] && ![string equal $chan ""] } {
    lappend output "No access or unknown channel $chan"
  } elseif { [string equal $chan ""] || [string equal $resetbans ""] } {
    lappend output "Usage: resetbans <channel>"
  } elseif { ![matchattr $handle mn|mn $chan] } {
    lappend output "No access or unknown channel $chan"
  } elseif { ![botisop $chan] && ![botishalfop $chan] } {
    lappend output "I am not a channel operator on $chan"
  } else {
    resetbans $chan
    lappend output "Bans were reset on $chan"
  }
  if { [catch {set x [cnotice $nick $output]} error] || !$x } {
    foreach t $output { puthelp "NOTICE $nick :$t" }
  }
  return 1
}

