mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
Joined: Apr 2011
Posts: 8
D
DukeHH Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Apr 2011
Posts: 8
Code:
on *:join:#:{
  writeini recuta.ini Recrutas $nick Waiting
}
on *:text:!next*:*:{ 
  chanserv voice $chan $readini(recruta.ini.....)
}


Hi guys, i need help in this code... I want to make a waiting code.

I want to do <!next> and the bot will give voice to the first person that joined the channel. Like..

John1 - Joins
John2 - Joins
john3 - Joins

So, the bot ill put them in order of arrive, and when i do !next it ill give voice to John1 because he was the first to arrive at the #.

I started by trying to work with the $ini but i don't know how to make it read the first line only. Like $line(recruta.ini,1) Something like that idk =|
And after he gives voice, he eliminates the $nick from the list, getting John2 to the top of the list.

Last edited by DukeHH; 18/04/11 01:45 PM.
Joined: Jul 2006
Posts: 3,972
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,972
Here is a version with a global variable:
Code:
;note: the ! mean if ($nick != $me), we just store each nick in %wait
on !*:join:#:set %wait %wait $nick
;we check if $gettok(%wait,1,32) (which represent the first person in the list (so the first person who joined)) is on the channel
;if so, voice him, but in any case we delete him from the list so $gettok(%wait,1,32) will represent the next person next time
on *:text:!next:#:if ($gettok(%wait,1,32) ison $chan) cs voice $chan $v1 | set %wait $remtok(%wait,$v1,32)
It doesn't seem necessary to use a ini/text file or any other storage method than variable just for that, but here is a text file version:
Code:
on !*:join:#:write wait.txt $nick
on *:text:!next:#:if ($read(wait.txt,n,1)) ison $chan) cs voice $chan $v1 | write -dl1 wait.txt


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Apr 2011
Posts: 8
D
DukeHH Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Apr 2011
Posts: 8
Tnk you very much dude!

Ye i dindt want the .txt or .ini version i actually prefer the other on. Explain me just someting what 32 means in here -> ($gettok(%wait,1,32) ?

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Your token-string of nicknames in %wait is separated by spaces. "32" is the ascii value for "space". See "/help token identifiers". smile

And I suggest the following addition (that makes further use of them token identifiers):
Code:
; if a user on the wait-list changes his nickname, put the new nickname in place of the old one
on *:nick: if ($findtok(%wait,$nick,32)) set %wait $puttok(%wait,$newnick,$v1,32)

Joined: Apr 2011
Posts: 8
D
DukeHH Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Apr 2011
Posts: 8
ye nice tip!

thank you.

How can i make th ebot identify a nick level?

Like i want that when some 1 joins the channel the bot alert the admins so they know that some 1 is waiting.

Like..

Code:
on !*:join:#:set %wait %wait $nick | msg <idk what to put here>($level == Admin) Some 1 has joined the #!


something like this.

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
If you already have the users added as admins in mIRC's users list, you can simply use:
Code:
on admin:join:#:{
This will trigger and match with the ones added in the users list.

Joined: Apr 2011
Posts: 8
D
DukeHH Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Apr 2011
Posts: 8
?

That's nothing like that dude..
Code:
on !*:join:#:set %wait %wait $nick | msg [b]<idk what to put here>[/b]($level == Admin) Some 1 has joined the #!


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.

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Did you use mIRC's inbuilt users list? The $level() identifier is used to reference the users added in it.

I'm not sure if that's a custom identifier you have. There's no such identifier as $level but $level() and $ulevel == something

Last edited by Tomao; 18/04/11 04:03 PM.
Joined: Apr 2011
Posts: 8
D
DukeHH Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Apr 2011
Posts: 8
yes i do.

i was trying something like this
Code:
.... | msg $(something)($level == Admin) <message>



i don't know what is the idenitifier for some1 in the user list

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
What is the format you've added in the users list? What does it look like?

Joined: Apr 2011
Posts: 8
D
DukeHH Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Apr 2011
Posts: 8
omg...

You use level numbers like 5, 10 to get level to some1.

I use words. Admin, Regular.

Its the same. I just need an identifier to the nicks in the user list.

like
Code:
on *:text:!Users*:#: msg $nick The Users With Acess Are: (and where stand the identifier, lets suposse that is $userlist)
: So it will be:

on *:text:!Users*:#: msg $nick The Users With Acess Are: $userlist

:And the bot says:

The Users With Acess Are: John Paul etc etc...


Got it? i need an identifier but i think that there is none for what i want, so im asking if some1 knows how to get all users for what i need.

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Quote:
omg
does not apply to my understanding of what you try to do based on the example provided.
Quote:
Got it?
That is a no, your description is sort of vague.

I was just trying to find out what you have done to add the user level in the user list.

Some people add them as

/auser -a 100 Nick
or
/auser -a 1,3,5 nick

or /auser -a Admin user

if you're gonna find out all the users added in the user list, you may need to user a while loop in conjunction with the $ulist() identifier.

Joined: Apr 2011
Posts: 8
D
DukeHH Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Apr 2011
Posts: 8
/auser admin nick

like i said normal way...

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Thank you. You can do it like this:
Code:
on !*:join:#:{
  var %u = 1
  while ($ulist(*,admin,%u)) {
    if ($nick == $v1) {
      msg $chan Admin $v1 has joined $chan $+ !
    }
    inc %u
  }
}
This will send a message to any user added with "admin" access in the user list.

If you're gonna match with other accesses you've added, the code will need to be modified. Currently it will match the admin only.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
As stated, you will have to loop through your user list. A faster method if the admins rarely change is to just put them directly into the msg command...

/msg nick1,nick2,nick3 This is the message.

If they do change regularly, then you'll want to loop through the user list by using a while loop and checking $ulist(*,admin,N), where N is the number that you are checking. You'll want to loop from N=1 to N=0 (0 being the total). You can add those to a variable in the format of nick1,nick2,nick3 within your loop so that you can then message them all with a single /msg command.

Code:
on !*:join:#yourchannel: {
  var %c = 1, %t = $ulist(*,admin,0)
  while (%c <= %t) {
    var %admins = $addtok(%admins,$ulist(*,admin,%c),44)
    inc %c
  }
  msg %admins Your message here.
}


Btw, unless you are completely positive that your number of waiting users will never grow to be really large, you may want to consider something other than a variable. A variable is fine for "small" numbers of nicks (you have about 4000 characters to work with in mIRC 7.x). But if you think it might grow beyond that, you're better off just using a text file and deleting row 1 each time you are done with that user. It's very easy to manage that way and is only limited in size by your hard drive.

** Note that I did not put in a check to make sure that you actually have users with the level of "admin". You could add something like that, but it's unlikely you'll ever need it as long as you make sure you always have someone with that user level.

Last edited by Riamus2; 18/04/11 05:37 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Originally Posted By: Tomao
This will send a message to any user added with "admin" access in the user list.


He wants it to notify all admins with someone gets added to the waiting list. So you're not notifying the channel that an Admin arrived. smile


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
It seems to me he wants a code to identify the users added with the admin user level upon joining.

My example compares one nick with the user list at a time when he or she joins a channel where the code is run.

Riamus2's example works well for a text event based operation, where it will message multiple nicknames at the same time, depending on how many nicknames your network supports for multiple targets.

Then again, I could have misunderstood his main intent for a desired code.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.

Last edited by Riamus2; 18/04/11 05:38 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
Yes Riamus2, I may have been befuddled by his explanation somewhat. Now the quote you've shown me, again, appears to be a bit confusing per se, whereas "send a message to all users with acess Admin or if possible to all users in a ini" ; to me, that's where the misunderstanding takes place. lol

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Well, if you break it into two parts (reworded slightly)...

1) Send to all users with admin access
- So send the message to everyone with the admin access level.

2) Or if possible to all users in an ini
- Or the OP can make an INI file (or other type of file) and then send to everyone listed in that file. Basically, if it can't be done using the access levels (which it can), then this is an alternative.

I hope that helps clear it up. I know the thread has gotten a bit confusing and mixed up with trying to sort out what was needed. Maybe I'm wrong, but going off what's been said, it really sounds to me like a help channel script and that's how those function. smile


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2010
Posts: 966
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 966
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: 3,972
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,972
//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: 3,972
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,972
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: 966
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 966
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: 3,972
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,972
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: 966
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 966
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: 966
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 966
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 1 of 2 1 2

Link Copied to Clipboard