####################################################
# by wiebe @ QuakeNet
#
####################################################


####################################################
# hello:help:msg
####################################################
bind msgm fvlomn|fvlomn "help hello" hello:help:msgm
proc hello:help:msgm { n u h t } {
  if {[matchattr $h bkZ]} { return 0 }
  lappend o "hello: usage hello \[<nick>\]"
  lappend o "hello: sends you or the given nick introduction to this bot, only a global master or owner can specify a nick."
  if {[string equal [info procs cnotice] ""]} { foreach l $o { puthelp "NOTICE $n :$l" }
  } else { foreach l $o { cnotice $n $l puthelp "hello: " } }
  putcmdlog "($n!$u) !$h! help hello"
  return 1
}


####################################################
# hello:msg
####################################################
bind msg fvlomn|fvlomn hello hello:msg
proc hello:msg { n u h t } {
  if {[matchattr $h bkZ]} { return 0 }
  set o [hello:hello $n $h $t]
  if {[string equal [info procs cnotice] ""]} { foreach l $o { puthelp "NOTICE $n :$l" }
  } else { foreach l $o { cnotice $n $l puthelp "hello: " } }
  return 1
}


####################################################
# hello:hello
####################################################
proc hello:hello { n h t } {
  set t [lindex [split $t] 0]; set i [nick2hand $t]
  if {[string equal $t ""] || [string equal -nocase $t $n]} {
    lappend o "Hello $n, I am ${::botnet-nick} and you are known to me as $h."
    if {[string equal [getuser $h pass] ""]} {
      lappend o "You have not set a password, please do so now: '/msg $::botnick newpass'"
    }
    lappend o "There are several commands available on this bot, depending on your access."
    lappend o "For public commands: type in the channel '${::botnet-nick} help' - or '/msg $::botnick help <chan>'. For private commands: '/msg $::botnick help'. Note: commands available in public and in private differ. The help function explains each command. For more info '/msg $::botnick help help'"
  } elseif {![matchattr $h mn]} {
    lappend o "hello: no access, you are not a global master or owner"
  } elseif {![onchan $t]} { lappend o "hello: user $t\017 is not on any of my channels."
  } elseif {[string equal $i *]} { lappend o "hello: user $t is not known."
  } elseif {[matchattr $i b]} { lappend o "hello: user $t ($i) is a bot."
  } elseif {[matchattr $i k]} { lappend o "hello: user $t ($i) is global banned (+k)."
  } elseif {[matchattr $i Z]} { lappend o "hello: user $t ($i) is suspended (+Z)."
  } elseif {![hello:check $i]} { lappend o "hello: user $t ($i) has no access."
  } else {
    lappend p "Hello $t, I am ${::botnet-nick} and you are known to me as $i."
    if {[string equal [getuser $i pass] ""]} {
      lappend p "You have not set a password, please do so now: '/msg $::botnick newpass'"
    }
    lappend p "There are several commands available on this bot, depending on your access."
    lappend p "For public commands: type in the channel '${::botnet-nick} help' - or '/msg $::botnick help <chan>'. For private commands: '/msg $::botnick help'. Note: commands available in public and in private differ. The help function explains each command. For more info '/msg $::botnick help help'"
    if {[string equal [info procs cnotice] ""]} { foreach l $p { puthelp "NOTICE $t :$l" }
    } else { foreach l $p { cnotice $t $l puthelp "hello: " } }
    lappend o "hello: sent introduction to $t ($i)"
  }
  return $o
}


####################################################
# hello:check
####################################################
proc hello:check { h } {
  if {[matchattr $h fvlomn]} { return 1 }
  foreach c [channels] { if {[matchattr $h fvlomn|fvlomn $c]} { return 1 } }
  return 0
}


set scriptdb(hello) {
  "provides hello command to introduction to the bot"
}

