mIRC Home    About    Download    Register    News    Help

Print Thread
#232503 07/06/11 01:39 PM
Joined: Jun 2011
Posts: 8
X
xelent Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
X
Joined: Jun 2011
Posts: 8
I found this code on the forum. It's exactly what I need. I tried to solve it, but this is to advanced for me.

Notes:
(15:17:36) (@Vliedel) look at the nwait alias
(15:17:56) (@Vliedel) you return the evaluated variable if prop = noop
(15:18:12) (@Vliedel) and else you return the non evaluated variable

Error:
* /set: invalid parameters (line 4, script1.mrc)

Code:
on *:DISCONNECT:{ unset $+(%,wait:,$cid,:*) }
 
on @*:JOIN:#:{
  set $nwait($chan).noop $nwait($chan) $nick
  $+(.timerWait:,$cid,:,$chan) 1 5 nWaitAdminMsg $chan
}
 
on !*:NICK:{
  var %x = 1, %c, %n = /(?<=^| )\Q $+ $replacecs($nick,\E,\E\\E\Q) $+ \E(?= |$)/
  while ($comchan($nick,%x)) {
    %c = $v1
    set $nwait(%c).noop $regsubex($nwait(%c),%n,$newnick)
    inc %x
  }
}
 
on *:TEXT:!next:#:{
  var %n = $nwait(#)
  while ($$gettok(%n,1,32) !isreg #) %n = $gettok(%n,2-,32)
  mode # +v $gettok(%n,1,32)
  set $nwait(#).noop $gettok(%n,2-,32)
}
 
alias nWait {
  if ($prop == noop) { return $($+(%,wait:,$cid,:,$1),2) }
  return $+(%,wait:,$cid,:,$1)
}
 
alias nWaitAdminMsg {
  if ($me !isop $1) { unset $nwait($1).noop }
  else {
    var %n = $nwait($1), %r, %x = 1
    while ($gettok(%n,%x,32)) {
      if ($v1 ison $1) { %r = %r $v1 }
      inc %x
    }
    if (!%r) { unset $nwait($1).noop }
    else {
      set $nwait($1).noop %r
      var %x = 1, %a
      while ($ulist(*,admin,%x)) { %a = $addtok(%a,$v1,44) | inc %x }
      if (%a) {
        msg %a The following users are waiting for help: %r
      }
    }
  }
}


Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
It looks like one problem is from the first line in that alias...

Code:
  if ($prop == noop) { return $($+(%,wait:,$cid,:,$1),2) }


You are evaluating that variable... that doesn't make any sense if you're using that in a /set command. First, a /set needs a % before it, which this would never have, and second, if this variable doesn't already have data, then it will be $null.

The result of this is that anywhere there is a $nwait().noop, it will be replaced with $null or a value (not a variable).

However, that should still leave you with...

/set $null %wait:$cid:$chan $nick

(where the $cid and $chan are evaluated)

And that should not throw that error even with the $null. So that line isn't going to affect anything even though it's not valid the way it's used. From testing just the /set command with the nWait alias, it doesn't give me an error, which is what I'd expect with that being $null. Now, if both $nwait()'s had .noop, then the error would be expected. I'm not sure why you'd be having the error.


Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
The original topic was updated with what may solve your problem. You can see the original topic here.


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
I do believe I told you in the message you sent me this morning to check the original thread. That I had fixed the script HERE!

Last edited by FroggieDaFrog; 07/06/11 05:41 PM.

I am SReject
My Stuff
Joined: Jun 2011
Posts: 8
X
xelent Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
X
Joined: Jun 2011
Posts: 8
Hello,

I tested the new version. I do belive you have a change nick support right?

I tried to change nick while there was 2 in the queue. The variable did not change, and when I used next command the bot (Excess Flood).

New code:
Code:
on *:DICONNECT: unset $+(%,wait:,$cid,:*)

on @*:JOIN:#:{
  set $nwait($chan).noop $nwait($chan) $nick
  $+(.timerWait:,$cid,:,$chan) 1 5 nWaitAdminMsg $!( $chan ,0)
}

on !*:NICK:{
  var %x = 1, %c, %n = /(?<=^| )\Q $+ $replacecs($nick,\E,\E\\E\Q) $+ \E(?= |$)/
  while ($comchan($nick,%x)) {
    %c = $v1
    set $nwait(%c).noop $regsubex($nwait(%c),%n,$newnick)
    inc %x
  }
}

on @*:TEXT:!next:#:{
  var %n = $nwait(#)
  while ($gettok(%n,1,32) && $v1 !isreg #) %n = $gettok(%n,2-,32)
  if (%n) {
    mode # +v $gettok(%n,1,32)
    set $nwait(#).noop $gettok(%n,2-,32)
  }
  else unset $nwait(#).noop
}

alias nWait {
  if ($prop == noop) return $+(%,wait:,$cid,:,$1)
  return $($+(%,wait:,$cid,:,$1),2)
}

alias nWaitAdminMsg {
  if ($me !isop $1) unset $nwait($1).noop
  else {
    var %n = $nwait($1), %r, %x = 1
    while ($gettok(%n,%x,32)) {
      if ($v1 ison $1) %r = %r $v1
      inc %x
    }
    if (!%r) unset $nwait($1).noop
    else {
      set $nwait($1).noop %r
      var %x = 1, %a
      while ($ulist(*,admin,%x)) {
        var %u = $v1, %y = 1
        while ($ialchan(%u,$1,%y)) {
          %a = $addtok(%a,$v1,44)
          inc %y
        }
        inc %x 
      }
      if (%a) msg %a The following users are waiting for help: %r
    }
  }
}



The bot also excess flood when there for example is 1 in the queue and then I do !next two times. Can you add so he says no more users i queue or something, please.

Last edited by xelent; 07/06/11 09:39 PM.
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
I wasn't able to test the newnick part, but everything else works exactly as it should
Code:
on *:DICONNECT: unset $+(%,wait:,$cid,:*)

on @*:JOIN:#:{
  set $nwait($chan).noop $addtok($nwait($chan),$nick,32)
  $+(.timerWait:,$cid,:,$chan) 1 5 nWaitAdminMsg $!( $chan ,0)
}

on !*:NICK:{
  var %x = 1
  var %c
  var %n = /(?<=^| )\Q $+ $replacecs($nick,\E,\E\\E\Q) $+ \E(?= |$)/
  while ($comchan($nick,%x)) {
    %c = $v1
    if ($nWait(%c)) {
      set $nwait(%c).noop $regsubex($v1,%n,$newnick)
    }
    inc %x
  }
}

on @admin:TEXT:!Next:#:{
  var %n = $nwait(#)
  while (%n) && ($gettok(%n,1,32) !isreg #) {
    %n = $gettok(%n,2-,32)
  }
  if (%n) {
    mode # +v $gettok(%n,1,32)
    set $nwait(#).noop $gettok(%n,2-,32)
  }
  else {
    unset $nwait(#).noop
    notice $nick There is no one waiting to be helped.
  }
}

alias nWaitAdminMsg {
  if (!$1) { return }
  elseif ($me !isop $1) { 
    unset $nwait($1).noop 

  }
  else {
    var %n = $nwait($1)
    var %r
    var %x = 1
    while ($gettok(%n,%x,32)) {
      if ($v1 isreg $1) {
        %r = %r $v1
      }
      inc %x
    }
    if (!%r) {
      unset $nwait($1).noop
    }
    else {
      set $nwait($1).noop %r
      var %x = 1
      var %a
      while ($ulist(*,admin,%x)) {
        var %u = $v1
        var %y = 1
        while ($ialchan(%u,$1,%y)) {
          %a = $addtok(%a,$gettok($v1,1,33),44)
          inc %y
        }
        inc %x 
      }
      if (%a) {
        msg %a The following users are waiting for help: %r
      }
    }
  }
}

alias nWait {
  if ($prop == noop) return $+(%,wait:,$cid,:,$1)
  return $($+(%,wait:,$cid,:,$1),2)
}


I am SReject
My Stuff
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Without the intention to nit-pick, rather that you - and other reading this - won't form a habit of it:
$!( $identifier ,0) won't make the code evaluation-safe. Those $safe()-aliases exist for a reason. smile


Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Originally Posted By: Horstl
Those $safe()-aliases exist for a reason. smile
I was trying to find out the comparison between the safe and the one froggie uses nwait. Whichever should stand out and be the one to be approved of.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
The purpose of $safe() is to prevent an evaluation where it's not desired - like in /scon, /scid, /flash, and /timer of course; or in the command parts of $tip() and $findfile() for example.
The purpose of $nwait() in Froggie's code is convenience: return either the name or the value of a dynamic variable.

Joined: Jun 2011
Posts: 8
X
xelent Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
X
Joined: Jun 2011
Posts: 8
The newnick functions does not work. There's two users in queue. The user in the front queue changes name, and when the next command is done he voices the second user in the queue.

- $+(.timerWait:,$cid,:,$chan) 1 5 nWaitAdminMsg $!( $chan ,0)
i dont think the timer works aswell =)

Last edited by xelent; 08/06/11 08:35 AM.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Here's my two cents - note that I didn't really test it! The approach is just slightly different from Froggies.
Code:
; return wheter a user's mask (nick!user@host - you can use wildcards) has admin level
; YOUR ULIST HAS TO CONTAIN MASKS FOR IT TO WORK, if it's made of plain nicknames, try $nick in place of $fulladdress
alias -l isadmin { return $ulist($fulladdress,admin) }

; return hash table name
alias -l ht { return $+(helpqueue,$cid) }

; regex routine (find nickname tokens in hash table data)
alias -l nickreg { return $+(/(?<=^|\s)\Q,$replacexcs($1,\E,\E\\E\Q),\E(?=$|\s),/i) }


; queue joining non-admins and send message to all present admins 7s after last join
on @*:join:#: {
  if (!$isadmin) { 
    hadd -m $ht $chan $hget($ht,$chan) $nick
    $+(timer,$ht,$chr(1),$chan) 1 7 messageadmins
  }
}

; voice next user in channel's queue
on @admin:text:!next:#:{
  if ($hget($ht,$chan)) { mode $chan +v $gettok($v1,1,32) }
  else { notice $nick      Help queue of $chan is empty. }
}

; remove voiced users from queue
on *:voice:#: { hadd -m $ht $chan $remtok($hget($ht,$chan),$vnick,0,32) }

; remove kicked users from channel's queue; clear queue if kicked yourself
on *:kick:#: {
  if ($knick == $me) { if ($hget($ht)) hdel $v1 $chan }
  elseif (!$ulist($ial($knick),admin)) { hadd -m $ht $chan $remtok($hget($ht,$chan),$knick,0,32) }
}

; remove parting users from channel's queue; clear queue if parting yourself
on *:part:#: {
  if ($nick == $me) { if ($hget($ht)) hdel $v1 $chan }
  elseif (!$isadmin) { hadd -m $ht $chan $remtok($hget($ht,$chan),$nick,0,32) }
}

; remove quitting users from queue(s); clear queue if quitting yourself
on *:quit: {
  if ($nick == $me) { if ($hget($ht)) hfree $v1 }
  elseif (!$isadmin) { 
    while ($hfind($ht,$nickreg($nick),1,r).data) { hadd $ht $v1 $remtok($hget($ht,$v1),$nick,0,32) }
  }
}

; update queue(s) on nickchange
on !*:nick: {
  if (!$isadmin) { 
    while ($hfind($ht,$nickreg($nick),1,r).data) { hadd $ht $v1 $reptok($hget($ht,$v1),$nick,$newnick,0,32) }
  }
}

; clear queue on disconnect
on *:disconnect: { if ($hget($ht)) hfree $v1 }


; send message to all admins on that channel (max. 4 target nicks per message)
alias -l messageadmins {
  var %n = 1, %c = $gettok($ctimer,-1,1), %present
  while ($ulist(*,admin,%n)) {
    if ($ialchan($v1,%c,1).nick) { 
      var %present = $addtok(%present,$v1,44)
      if ($numtok(%present,44) == 4) { notice $v1 $queuemessage(%c) | var %present }
    }
    inc %n
  }
  if (%present) { notice $v1 $queuemessage(%c) }
}

; message layout
alias -l queuemessage {
  var %t = $numtok($hget($ht,$1),32)
  return      There $iif((%t > 1),are %t users,is $iif((%t == 1),one user,no user left)) in the help queue of $1 $+ .
}

Joined: Jun 2011
Posts: 8
X
xelent Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
X
Joined: Jun 2011
Posts: 8
Looks ok, will test it now. But can you add an !addadmin and !removeadmin ? That would be legendary!

EDIT: On kick your script does not remove them from the queue.

Last edited by xelent; 08/06/11 03:54 PM.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
I'll look into it - can you please give some samples of your "users" tab (current user levels list)?

Edit: As I won't have time tomorrow, give this a shot (It'll add admins that are present with $mask type 1: *!*user@host, but should accept plain nicknames/wildmasks as well (e.g. offline users).
Code:
; ------------ SETUP START ------------
; channels to trigger at (separate multiple channels by comma)
alias -l next.chans { return #help,#support }

; after joins of regular users, msg/notice users with level "admin" after N seconds
; note that if other user joins in the meantime, the timer restarts, so you won't flood that much
alias -l next.infodelay { return 7 }

; method to inform admins (put either "msg" or "notice")
alias -l next.info { return notice }
; ------------- SETUP END -------------

on @admin:JOIN:$($next.chans): !
on @*:JOIN:$($next.chans): {
  hadd -m $ht $chan $hget($ht,$chan) $nick
  $+(.timer,$ht,$chr(1),$chan) 1 $iif(($next.infodelay isnum 0-),$v1,5) next.informadmins
}

on me:*:PART:$($next.chans): { next.wipe }
on admin:PART:$($next.chans): !
on !*:PART:$($next.chans): { hadd -m $ht $chan $remtok($hget($ht,$chan),$nick,0,32) }

on me:*:QUIT: { next.wipe }
on admin:QUIT: !
on !*:QUIT: { while ($hfind($ht,$nickreg($nick),1,r).data) hadd $ht $v1 $remtok($hget($ht,$v1),$nick,0,32) }

on *:KICK:$($next.chans): {
  if ($knick == $me) { next.wipe }
  elseif (!$ulist($ial($knick),admin)) { hadd -m $ht $chan $remtok($hget($ht,$chan),$knick,0,32) }
}

on *:DISCONNECT: { next.wipe }

on !admin:NICK: !
on !*:NICK: { while ($hfind($ht,$nickreg($nick),1,r).data) hadd $ht $v1 $reptok($hget($ht,$v1),$nick,$newnick,0,32) }

on @admin:TEXT:!next:$($next.chans): {
  if ($hget($ht,$chan)) { mode $chan +v $gettok($v1,1,32) }
  else { $next.info $nick Help queue of $chan is empty. }
}
on admin:TEXT:!next:$($next.chans): { $next.info $nick I'm not opped! }

on admin:TEXT:!queue:$($next.chans): {
  if ($hget($ht,$chan)) { $next.info $nick $numtok($v1,32) in queue: $replace($v1,$chr(32),$+($chr(32),->,$chr(32))) }
  else { $next.info $nick Help queue of $chan is empty. }
}

on admin:TEXT:!addadmin &:$($next.chans): { 
  var %m = $iif($ial($2),$v1,$2)
  if ($ulist(%m,admin,1)) { $next.info $nick $2 is already an admin: $qt($v1) }
  elseif (%m !isnum) { 
    .auser -a admin $mask(%m,1) (admin by: $nick on $date $time $+ )
    $next.info $nick Added $2 to admins: $mask(%m,1)
  }
}

on admin:TEXT:!removeadmin &:$($next.chans): { 
  var %m = $iif($ial($2),$v1,$2), %rem
  if (!$ulist(%m,admin,1)) { $next.info $nick $2 is no admin. }
  elseif (%m !isnum) {
    while ($ulist(%m,admin,1)) { %rem = %rem $qt($v1) | .ruser admin $v1 }
    $next.info $nick Removed $2 from admins: %rem
  }
}

on *:VOICE:$($next.chans): {
  hadd -m $ht $chan $remtok($hget($ht,$chan),$vnick,0,32)
  $+(.timer,$ht,$chr(1),$chan) off
}

alias -l ht { return $+(helpqueue,$cid) }
alias -l nickreg { return $+(/(?<=^|\s)\Q,$replacexcs($1,\E,\E\\E\Q),\E(?=$|\s),/i) }
alias -l next.wipe { if ($hget($ht)) $iif($chan,hdel,hfree) $ht $chan }

alias -l next.informadmins {
  var %n = 1, %c = $gettok($ctimer,-1,1), %here
  while ($ulist(*,admin,%n)) {
    if ($ialchan($v1,%c,1).nick) { 
      %here = $addtok(%here,$v1,44)
      if ($numtok(%here,44) == 4) { $next.info $v1 $next.message(%c) | var %here }
    }
    inc %n
  }
  if (%here) { $next.info $v1 $next.message(%c) }
}

alias -l next.message {
  var %t = $numtok($hget($ht,$1),32)
  return There $iif((%t > 1),are %t users,is $iif((%t == 1),one user,no user left)) in the help queue of $1 $+ .
}

Joined: Jun 2011
Posts: 8
X
xelent Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
X
Joined: Jun 2011
Posts: 8
Bugs:
If more than 1 user in the queue it;
- the nickchange dont work - mirc freezes
- the user who gets voiced by !next wont be removed from queue if more than 1 in the queue.

(14:44:12) (@xelent) !next
(14:44:12)  -› BX-help (+v) fishbot
(14:44:13) (@xelent) !next
(14:44:18) (@xelent) !queue
(14:44:18)  -› [notice from BX-help]: 2 in queue: fishbot -> test23

Joined: Jun 2011
Posts: 8
X
xelent Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
X
Joined: Jun 2011
Posts: 8
BUMP

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Sorry for the late reply - been busy smile

The first issue may indeed occur if a user is only changing the "case" of his nickname (e.g. "xelent" -> "XeLenT").
Fix: at the line
Quote:
alias -l nickreg { return $+(/(?<=^|\s)\Q,$replacexcs($1,\E,\E\\E\Q),\E(?=$|\s),/i) }
remove that "i"-char left of the final round closing bracket.


Having run some tests with four clients, I wasn't able to reproduce the second issue though.
However, you should be able to play safe with the following modification: while invalid entries shouldn't appear in the queue at all, it will "skip" invalid nicknames in the queue (remove them from queue and continue with next nick).

Change this event:
Code:
on @admin:TEXT:!next:$($next.chans): {
  if ($hget($ht,$chan)) { mode $chan +v $gettok($v1,1,32) }
  else { $next.info $nick Help queue of $chan is empty. }
}
To:
Code:
on @admin:TEXT:!next:$($next.chans): {
  :next
  if ($hget($ht,$chan)) {
    if ($gettok($v1,1,32) ison $chan) && ($v1 !isvoice $chan) { mode $v2 +v $v1 }
    else { hadd $ht $chan $gettok($hget($ht,$chan),2-,32) | goto next }
  }
  else { $next.info $nick Help queue of $chan is empty. }
}

Last edited by Horstl; 13/06/11 12:08 AM.
Joined: Jun 2011
Posts: 8
X
xelent Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
X
Joined: Jun 2011
Posts: 8
Seems to be working perfectly. You've been very helpfull. Can you please do one final thing for me?


  • Remove that a user require admin to use the commands.
  • Can you set the help chan to a permanent channel? No multiple channel choice. And I can use !queue in another channel to view the queue in the real channel.
  • Add !on / !off cmd to turn on and off the queue system


The thing I want is to have an ADMIN channel where you can check !queue and do other commands to the permanent HELP channel.

I tried to make this based on your script, NO CHANCE. So many bugs and things dont work. Please, I beg you. MAKE THIS :P

Last edited by xelent; 14/06/11 02:01 PM.
Joined: Jun 2011
Posts: 8
X
xelent Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
X
Joined: Jun 2011
Posts: 8
Code:
;--------- ALIASES ---------
alias -l next.infodelay {
  return 7
}

alias -l next.info {
  return notice
}

alias -l ht {
  return $+(helpqueue,$cid)
}

alias -l nickreg {
  return $+(/(?<=^|\s)\Q,$replacexcs($1,\E,\E\\E\Q),\E(?=$|\s),/)
}

alias -l next.wipe {
  if ($hget($ht)) $iif(%help(chan),hdel,hfree) $ht %help(chan)
}

alias putnotice {
  if (!$isid) {
    putcmd .notice $1-
  }
}
alias putmsg {
  if (!$isid) {
    putcmd .msg $1-
  }
}
alias putaction {
  if (!$isid) {
    putcmd .describe $1-
  }
}
alias putcmd {
  var %a = putcmd. $+ $cid, %c = $1
  !tokenize 32 $2-
  if ($2 == $null) {
    if ($show) {
      !echo -ac $+ $iif($active == status window,e) info * /put $+ %c $+ : insufficient parameters
    }
    !halt
  }
  if (!$timer(%a)) {
    !hadd -m %a index -1
    !hadd -m %a current 0
    !.timer $+ %a -m 0 5000 putcmd.exec $cid
  }
  !hinc -m %a index
  !hadd -m %a $hget(%a,index) ! $+ %c $1-
  if ($calc($ticks - $hget(%a,last)) > 2000) {
    putcmd.exec $cid
  }
  !hadd -m %a last $ticks
}
alias putcmd.exec {
  var %a = putcmd. $+ $1, %c = $hget(%a,current)
  !scid -r $hget(%a,%c)
  !hdel %a %c
  !hinc %a current
  if ($hget(%a,0).item == 3) {
    !.timer $+ %a off
    !hfree -w %a
  }
}


;--------- VARIABLE AND STATUS CHECK ---------
on *:connect:{
  window @CONNECT-CHECK
  .timer 1 1 echo @CONNECT-CHECK Please wait while the bot checks if there any errors.
  if ($isdir(help)) {
    timer 1 3 echo @CONNECT-CHECK help directory excists. The bot is still searching for errors.
  }
  elseif (!$isdir(help)) {
    timer 1 4 echo @CONNECT-CHECK 4ERROR help directory dont excists. Making new directory 'help'.
    mkdir help
  }
  if ($isdir(help\data)) {
    timer 1 5 echo @CONNECT-CHECK help\data directory excists. The bot is still searching for errors.
  }
  elseif (!$isdir(help\data)) {
    timer 1 6 echo @CONNECT-CHECK 4ERROR help\data directory dont excists. Making new directory 'help\data'.
    mkdir help\data
  }
  if (%help(author) == xelent) {
    .timer 1 7 echo @CONNECT-CHECK Variables excists.
  }
  elseif (%help(author) != xelent) {
    set %help(mchan) #BX-Networks
    set %help(pchan) #BX.admin
    set %help(schan) #BX.support
    set %help(author) xelent
    set %help(version) 1.0b
    set %help(trigger) !
    set %help(global) ?
    set %help(error) 1
    .timer 1 8 echo @CONNECT-CHECK 4ERROR Variables dont excist. Creating variables '%help"''"'
  }
  if (%help(error) != 1) {
    timer 1 9 echo @CONNECT-CHECK The error check has been completed. 0 errors occured, the bot is working 100%.
    .timer 1 20 /window -c @CONNECT-CHECK
  }
  elseif (%help(error) == 1) {
    timer 1 11 echo @CONNECT-CHECK An or some error(s) occured. Due some awesome scripting these were fixed during the check/scan.
    timer 1 13 .unset %help(error)
    .timer 1 25 /window -c @CONNECT-CHECK
  }
}

;--------- Events ---------
on me:*:PART:%help(chan): {
  next.wipe
}

on !*:PART:%help(chan): {
  hadd -m $ht $chan $remtok($hget($ht,$chan),$nick,0,32)
}

on me:*:QUIT: {
  next.wipe
}

on !*:QUIT: {
  while ($hfind($ht,$nickreg($nick),1,r).data) hadd $ht $v1 $remtok($hget($ht,$v1),$nick,0,32)
}

on *:KICK:%help(chan): {
  if ($knick == $me) {
    next.wipe
  }
  else {
    hadd -m $ht $chan $remtok($hget($ht,$chan),$knick,0,32)
  }
}

on *:DISCONNECT: {
  next.wipe
}

on !*:NICK: {
  while ($hfind($ht,$nickreg($nick),1,r).data) hadd $ht $v1 $reptok($hget($ht,$v1),$nick,$newnick,0,32)
}

on *:VOICE:%help(chan): {
  hadd -m $ht $chan $remtok($hget($ht,$chan),$vnick,0,32)
}

on *:text:*:%help(pchan):{
  if ($1 == %help(trigger) $+ help) || ($1 == %help(global) $+ help) {
    if ($2 == next) {
      :next
      if ($hget($ht,%help(chan))) {
        if ($gettok($v1,1,32) ison %help(chan)) && ($v1 !isvoice %help(chan)) {
          mode $v2 +v $v1
          .msg %help(chan) You've been granted voice. State your question(s) directly in this channel. Do not highlight or PM the administrators. Please be patient.
        }
        else {
          hadd $ht %help(chan) $gettok($hget($ht,%help(chan)),2-,32) | goto next
        }
      }
      else {
        $next.info $nick Help queue of %help(chan) is empty.
      }
    }
    elseif ($2 == status) {
      if ($hget($ht,%help(chan))) {
        $next.info $nick $numtok($v1,32) in queue: $replace($v1,$chr(32),$+($chr(32),->,$chr(32)))
      }
      else {
        $next.info $nick Help queue of %help(chan) is empty.
      }
    }
    elseif ($2 == done) {
      if ($3) {
        kick %help(chan) $3 You've been helped and kicked from the channel due no idle.
        .msg $chan $3 got kicked from %help(chan) $+ .
        hadd -m $ht $chan $remtok($hget($ht,$chan),$knick,0,32)
      }
      elseif (!$3) {
        $next.info $nick Please specify a nickname.
      }
    }
    elseif ($2 == on) {
      if ($readini(help\data\status.ini,reg,status) == on) {
        .msg %help(pchan) Error: Failed to open help center, already 9open.
      }
      else {
        writeini help\data\status.ini reg status on
        msg %help(pchan) The help center is now 9open.
        .msg %help(mchan) « BX-Network help Center » is now open! Need help? Use "!help".
        .topic %help(pchan) help center 9open $+ .
      }
    }
    elseif ($2 == commands) {
      .putnotice $nick These commands is available for you 
      .putnotice $nick %help(trigger) $+ help next - Voices the next user in the queue on %help(chan) $+ . 
      .putnotice $nick %help(trigger) $+ help done <nick> - Kicks <nick> from %help(chan) due no idle done after user is helped. 
      .putnotice $nick %help(trigger) $+ help on/off - Turn on or off the help system. 
      .putnotice $nick %help(trigger) $+ help version - Shows the current script version. 
      .putnotice $nick %help(trigger) $+ help status - Display the users in the help queue. 
    }

    elseif ($2 == off) {
      if ($readini(help\data\status.ini,reg,status) == off) {
        .msg %help(pchan) Error: Failed to close help center, already 4closed.
      }
      else {
        writeini help\data\status.ini reg status off
        msg %help(pchan) The help center is now 4closed.
        .msg %help(mchan) « BX-Network help Center » is now closed! If you still need help, you can send us an email.
        .topic %help(pchan) help center 4closed $+ .
      }
    }
    elseif (!$2) {
      .notice $nick Please specify what command to execute. If your not sure, check %help(trigger) $+ help commands
    }
  }
}


on *:text:*:%help(mchan):{
  if ($1 == %help(trigger) $+ help) || ($1 == help) {
    .putmsg $nick « BX-Network help Center » Do you need any help or have any questions? You can join our queue for assistance.
    .putmsg $nick « BX-Network help Center » You can simply join our help queue by typing: /msg $me queueme
  }
}

on *:text:queueme:?:{
  if ($readini(help\data\status.ini,reg,status) == on) {
    if (%help. [ $+ [ $nick ] ] != 1) {
      .set -u300 %help. [ $+ [ $nick ] ] 1
      .putmsg %help(pchan) « BX-Network help Center » - ( $nick ) Has queued himself for online help.
      .putmsg $nick « BX-Network help Center » You have successfully joined the queue. You can now join %help(chan) $+ . Here an administrator will assist you.
      hadd -m $ht %help(chan) $hget($ht,%help(chan)) $nick
      invite $nick %help(chan)
    }
    elseif (%help. [ $+ [ $nick ] ] == 1) {
      .msg $nick « BX-Network help Center » You have already joined the queue.
      .msg %help(pchan) « BX-Network help Center » - ( $nick ) tried to queue himself again for online help.
    }
  }
  elseif ($readini(help\data\status.ini,reg,status) == off) {
    .putmsg $nick « BX-Network help Center » We're sorry but the help center is closed $+ . Please try again later..
    .msg %help(pchan) « BX-Network help Center » - ( $nick ) tried to use to use our help center. If you are an certified administrator and allowed to help others you can turn on the help center by typing: %help(trigger) $+ help on
  }
}


My test, when I do next it still reports that the user is in queue.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Well, you made lots of modifications - more than the requests in your previous post necessitate. Here and there (putmsg, %help(author) for example) it's not very clear to me what funtionality you're after. Adding extensive features won't ease debugging - it's now very hard to test your script in action - I'd have to set up both chan, pchan and mchan with various clients each. I suggest to not add additional functions till all modifications of the "core" script are working properly smile
In general, try to debug the code and make it as verbose as necessary:
- Put the -s switch at all the /hadd /hdel /hfree /set /writeini etc commands
- De-silence commands (e.g: .timer -> timer )
Then, try to narrow down what makes the script to fail (which scenario -> which alias/event -> which command in the alias/event).


However - not by testing but mere reading of your code - I noticed the following:

1) Atm no join event is left, you're adding users right after "queueme" -> invite command - but there's no check whether a user actually joins the helpchan.
Alike, the "you've been voiced"-info - this shouldn't be sent right after the voice command but rather "on voice" (and if the voiced user in queue); alike the queue-remtok at !done -> kick command - better use the on kick event.

2) At !done (which triggers on text at %help(pchan) and not at %help(chan) !), you're currently using $chan = %help(pchan) and not %help(chan) in the hadd command. You're thus manipulating the (nonexistent) queue of pchan. But, as stated above, better update the queue on kick.

3) If %help(chan) can be but a single channel, no "on quit"/"on nick"-loops with $hfind(r) are required. That (and the nickreg alias) was made to account for multiple help channels with separate queues. A "ison"-check -> $remtok should suffice in your case.

4) Why the check for %help. [ $+ [ $nick ] ] ?
You can check whether a nick is in the queue with
Quote:
if ($istok($hget($ht,%help(chan)),$nick,32)) { }
. This would also be be more accurate as the hash table updates with various events (nick,part,quit,kick...) while thes variables do not.

5) Add a basic flood protection for all the replies of "queueme". If "putcmd" does not provide a sufficient flood protection, you should add one there as well.

Good luck smile


Link Copied to Clipboard