mIRC Home    About    Download    Register    News    Help

Print Thread
Page 2 of 2 1 2
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
I didn't test it but I think this is what you wanted(I added multinet/channel support aswell):
Code:
on *:DICONNECT:{ 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
      }
    }
  }
}


I am SReject
My Stuff
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Riamus2, thanks for breaking his explanation down into a thorough and understandable one.

I suppose we can also use $regsubex to achieve the same outcome:

Code:
on !*:join:#yourchannel:{
  msg $left($regsubex($str($chr(44),$ulist(*,admin,0)),//g,$ulist(*,admin,\n)),-1) Your Message Here.
}

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
//g will match before and after each characters, you probably typoed the dot /./g


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I can't test it right now, but I don't see anywhere where you are removing the nicks from the list once they are done. From my experience with help channel scripts, !next should do the following:

* Devoice the user who was voiced.
* Remove that user from the wait queue.
* Voice the next user in the wait queue if there is one.
* Usually there is also an automatic message to the channel stating something along the lines of "Nick, what is your question?"

Just from a quick scan of your script, it appears that you are voicing the next user, but leaving the nicks in the list and not devoicing the previous user. The biggest issue with leaving the nick in the list is that the list will get too large for a variable to handle as you continue to add more and more nicks to the wait queue.

Rather than changing the token you start at, you can just deltok the first nick when !next is used and then always voice the first nick. If you have any questions about that, feel free to ask. But I think you will understand what I mean and how to do that.

As an additional note, I think I'd check $ulevel to see if the user is an admin in the on join event. If so, don't add them to the wait queue at all. Then, I might leave it so that !next will "help" the next person regardless of their current channel mode. You're skipping anyone !isreg, which may be okay or may not depending on how the channel is run. That part is optional and depends entirely on what the OP wants to happen. It may be that they want to "help" the next person even if they are voiced or opped by someone for some other reason. Just a thought. Either way, I would skip adding the nick to the list if they are in the admin list.


Oh, and one more thing if you want to add in an extra feature that some help channels make use of. This one handles one user at a time (assuming you add the devoice in the !next part of the script). Some channels allow for multiple admins/staff to handle multiple questions at the same time. For example, I type !next and it voices nick1. I then start working on helping that nick. You type !next and it voices nick2, who you start helping. You are able to help nick2 before I finish helping nick1. You type !next -- nick2 is devoiced and nick3 is voiced. I then finish and type !next -- nick1 is devoiced and nick4 is voiced. Basically, it tracks which nick is being helped by which admin and devoices the correct nick depending which admin uses the !next command. It's not a big change to the script, but will need a little work to set up. You may want to wait and see if the OP needs that kind of functionality or not. Or you might just want to do it for the "challenge" it offers (not much of one, but hey... anything builds on experience).

Last edited by Riamus2; 18/04/11 07:12 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Wims, I tested it just now, and it should be left empty if we opt for $chr(44) in the $str()

By putting the dot in regex match area, it cuts off a letter in a nickname stored in the user list.

If I opted for the dot symbol in $str(., I'd indeed have to place it between the delimiters of the regex as you suggested.

Edit - you realize I have the $left() identifier used...

Last edited by Tomao; 18/04/11 07:09 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I added a little to my post above just in case you missed it.


Invision Support
#Invision on irc.irchighway.net
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
What I'm saying is that you want to make a loop with $regsubex, //g match before and after each character, which means: for N characters, you have N + 1 matches.
So you are always making a extra match, an extra evaluation of $ulist() with a N parameter that is invalid: it returns $null and you don't see the problem, but since //g doesn't match characters but position, you have one useless comma left, which is why you did $left().
I guess it's ok, but having that extra evaluation could be a problem, using a while loop would be, anyways, good practice, probably faster and it would make the code readable


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I'd also recommend the WHILE loop instead of using regex. It's great that you can do that with regex, but I think that it's usually more helpful to show commands a newer scripter (as I'm guessing the OP is) is familiar with rather than giving them something that they won't understand at all. Also, regex is not always a faster solution. Unless it's faster, it may not be the best choice. Smaller code doesn't necessarily mean better code except in contests. laugh

I always prefer readability over code length and speed over both. The one thing about speed, however... if the speed difference isn't significant, then readability is more important to me.

Last edited by Riamus2; 18/04/11 08:40 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
cool Thanks for your input. It's nice to hear from different people about what they think regarding a subject.

Joined: Apr 2011
Posts: 8
D
DukeHH Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Apr 2011
Posts: 8
Originally Posted By: Riamus2
Quote:
When some1 joins the channel i need to send a message to all users with acess Admin or if possible to all users in a ini so i can manage the staff in the channel.


I believe this script is for a #help type of channel, where the first user to arrive gets help first, and then down the list. If someone gets added to the waiting list, all admins are notified in case it's been quiet and no one is actively monitoring the channel. Admins then help the first person in the waiting list. Once done, they can use the !next command to then help the next person if there is one. Typically, these will voice the person being helped so they can talk in a moderated channel.

You do bring up a good point about the maximum number of people the network lets you send a message to at one time. It may be necessary to modify the script if the level is lower than the number of admins. That's an easy change, but I'd need some idea from the OP as to how many can be messaged at one time on that network.

I also edited my script above so that it's in the join event to prevent any confusion. Originally, I was just explaining what needs done, but in hindsight, I think showing it in the event will be less confusing.


Ye dude its something like that, not for a help channel but for a recrut channel. And its all like you said.

I was thinking and i remember that some of admins may not be online at that time, so it would be great if the bot cud send a message to the joining nick with the number of admins Online.

The checks if the admins in User list are on, and then it send a message to the user saying something like... ''the number of online admins are 2(example).''

Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
I found a few bugs in my 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
    }
  }
}


Bugs/Fixes:
1) $nWait() should have evaluated the variable
2) $nWait().noop should not have evaluated the variable
3) Am now searching $IALChan() for admins
4) Strange channel name exploit

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

I am SReject
My Stuff
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
That code is exploitable, you are double evaluating $chan in the timer while $chan is unknown and could be something like #$q..


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
Fixed laugh


I am SReject
My Stuff
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Would you please explain what's the difference between the common safe alias and this so-called nwait alias?

Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
If you look. $nWait() returns a variable[or it's value]
I used it instead of having $+(%,wait:,$cid,:,$1) and $($+(%,wait:,$cid,:,$1),2) all over the script


I am SReject
My Stuff
Page 2 of 2 1 2

Link Copied to Clipboard