;@@@
;@@@ DreamBot IRC Bot 5.4
;@@@ File description: help module
;@@@ Design & coding: DreamBot development team
;@@@ (C) Copyright 2004-2006 DreamBot development team. All rights reserved. 
;@@@

on 400:text:*helpmode*:#: {
  if ($1 == %c $+ helpmode) {
    if ($2 == $null) { .msg $nick Command incomplete. Syntax: %c $+ helpmode <on|off>. | halt }
    if ($2 == on) { .writeini -n ini\channels.ini $chan HelpMode On | .msg $nick The help mode for $chan has been enabled. | halt }
    if ($2 == off) { .writeini -n ini\channels.ini $chan HelpMode Off | .msg $nick The help mode for $chan has been disabled. | halt }
    else { .msg $nick $cl Error: Invalid parameters. Available options: ON/OFF. | halt }
  }
}
on 400:text:helpmode*:?: {
  if ($2 == $null) { .msg $nick Command incomplete. Syntax: /msg $me helpmode <#channel> <on|off>. | halt }
  if ($3 == $null) { .msg $nick Command incomplete. Syntax: /msg $me helpmode <#channel> <on|off>. | halt }
  if ($3 == on) { .writeini -n ini\channels.ini $2 HelpMode On | .msg $nick The help mode for $2 has been enabled. | halt }
  if ($3 == off) { .writeini -n ini\channels.ini $2 HelpMode Off | .msg $nick The help mode for $2 has been disabled. | halt }
  else { .msg $nick $cl Error: Invalid parameters. Available options: ON/OFF. | halt }
}
on 100:text:*next:#: {
  if ($1 == %c $+ next) {
    if (($readini(ini\channels.ini, $chan, HelpMode) == Off) || ($readini(ini\channels.ini, $chan, HelpMode) == $null)) { halt }
    :redo
    if (%waitlist. [ $+ [ $chan ] ] == $null) { .msg $nick No one is waiting for help on $chan $+ . | halt }
    set %next. [ $+ [ $chan ] ] $gettok(%waitlist. [ $+ [ $chan ] ],$numtok(%waitlist. [ $+ [ $chan ] ],46),46)
    set %waitlist. [ $+ [ $chan ] ] $remtok(%waitlist. [ $+ [ $chan ] ],%next. [ $+ [ $chan ] ],46)
    if (%next. [ $+ [ $chan ] ] !ison $chan) { goto redo }
    msg $chan Hello %next. [ $+ [ $chan ] ] $+ , $nick will help you with your problem. Enjoy your stay :)
    .notice %next. [ $+ [ $chan ] ] Hello and welcome to $chan $+ ! Please state your problem in one line now. You will be assisted by $nick $+ .
    if (m isin $chan($chan).mode) { qvadd $chan %next. [ $+ [ $chan ] ] }
    unset %next. [ $+ [ $chan ] ]
  }
}
on 100:text:*helped*:#: {
  if ($1 == %c $+ helped) {
    if (($readini(ini\channels.ini, $chan, HelpMode) == Off) || ($readini(ini\channels.ini, $chan, HelpMode) == $null)) { halt }
    if ($2 == $null) { .msg $nick Command incomplete. Syntax: %c $+ helped <nick>. | halt }
    if ($2 == $me) { .msg $nick I will not help myself. | halt }
    if ($2 isop $chan) { .msg $nick Channel ops can't be helped. | halt }
    if ($level($address($2,2)) > 1) { .msg $nick Bot operators can't be helped. | halt }
    if ($nick isvoice $chan) { qdvadd $chan $2 }
    .notice $2 You were assisted, now please /part $chan and have a nice day :)
  }
}
on 100:text:*idle*:#: {
  if ($1 == %c $+ idle) {
    if (($readini(ini\channels.ini, $chan, HelpMode) == Off) || ($readini(ini\channels.ini, $chan, HelpMode) == $null)) { halt }
    if ($2 == $null) { .msg $nick Command incomplete. Syntax: %c $+ idle <nick>. | halt }
    if ($2 == $me) { .msg $nick I will not idle myself. | halt }
    if ($2 isop $chan) { .msg $nick Channel ops can't be warned. | halt }
    if ($level($address($2,2)) > 1) { .msg $nick Bot operators can't be warned. | halt }
    if (($readini(ini\globals.ini, HelpMode, Idle) == Off) || ($readini(ini\globals.ini, HelpMode, Idle) == $null)) { .msg $nick The %c $+ idle command has been disabled. | halt }
    if ($read(ini\mlines.txt, s, IdleMsg) == $null) { .msg $nick No %c $+ idle msg specified. | halt }
    .notice $2 $read(ini\mlines.txt, s, IdleMsg)
  }
  if ($1 == %c $+ noidle) {
    if (($readini(ini\channels.ini, $chan, HelpMode) == Off) || ($readini(ini\channels.ini, $chan, HelpMode) == $null)) { halt }
    if ($2 == $null) { .msg $nick Command incomplete. Syntax: %c $+ noidle <nick>. | halt }
    if ($2 == $me) { .msg $nick I will not ban myself. | halt }
    if ($2 isop $chan) { .msg $nick Channel ops can't be banned. | halt }
    if ($level($address($2,2)) > 1) { .msg $nick Bot operators can't be banned. | halt }
    ban -ku60 $chan $2 2 Please do not idle in $chan $+ . Tempban: 1 minute.
  }
}
on 100:join:#: { 
  if ($readini(ini\channels.ini, $chan, HelpMode) == On) {
    qvadd $chan $nick 
  }
}
on +1!:join:#: {
  if ($readini(ini\channels.ini, $chan, HelpMode) == On) {
    set %waitlist. [ $+ [ $chan ] ] $nick $+ . $+ %waitlist. [ $+ [ $chan ] ]
    .notice $nick Please wait silently while we deal with our current guests. You will be notified when your turn will come. You are number $numtok(%waitlist. [ $+ [ $chan ] ],46) in line. Thanks! 
  }
}
on +1!:part:#: {
  if ($readini(ini\channels.ini, $chan, HelpMode) == On) {
    set %waitlist. [ $+ [ $chan ] ] $remtok(%waitlist. [ $+ [ $chan ] ],$nick,46)
  }
}
on *:kick:#: {
  if ($readini(ini\channels.ini, $chan, HelpMode) == On) {
    set %waitlist. [ $+ [ $chan ] ] $remtok(%waitlist. [ $+ [ $chan ] ],$knick,46)
  }
}
on *:op:#: {
  if ($readini(ini\channels.ini, $chan, HelpMode) == On) {
    set %waitlist. [ $+ [ $chan ] ] $remtok(%waitlist. [ $+ [ $chan ] ],$opnick,46)
  }
}
