mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2005
Posts: 12
A
anarres Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Apr 2005
Posts: 12
I have a text file (nicks.txt) with a list of nicks that usually are on my #channel. I want that when I type !nicks mirc compare the users that are on #channel with the list, and the nicks that are on the list but not on the #channel I invite them.

Thanx a lot

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Code:
on *:input:#yourchan: {
  if ($1 == !nicks) {
    set %cnt 1
    while (%cnt <= $lines(nicks.txt)) {
      if ($read(nicks.txt,%cnt) !ison $chan) {
        invite $read(nicks.txt,%cnt) $chan
      }
      inc %cnt
    }
    unset %cnt
  }
}


Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
you might want to look at /notify and on notify to do that without making a text file

/help notify
/help on notify

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Got three small things to note:

It is quite inefficient to loop with $lines in the while condition. That's because the $lines identifier is an identifier that has to do quite some processing before it can return the result.

1. It must open the file.
2. Check how many lines there are.
3. Close the file.
4. Return the result.

That means, with each iteration, you open/close the file.

You can avoid all that by putting $lines() in a variable and comparing to that, since the value is already stored in memory (it's a value assigned to a local variable), it does not need to open/close the file.

You can use set -u %var if you want the variable to auto-unset itsself when the script finishes, thus making the unset command obsolete. Or better yet, use a local variable, which destroys itsself automatically when the script finishes.

Lastly, this is a detail, but in the invite command, you could have used $ifmatch or $v1.

I would have used /filter with -k flag, thus taking advantage of the internal loop (fast), and with a minimal amount of code. Then again, that only works from mIRC 6.15 and on. In those cases, the file handling commands are a great alternative.

These are just tips, not trying to be offensive or anything smile

Greets


Gone.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Ok. I hadn't considered that $lines thing with a loop. I'll keep that in mind for future use. Thanks. smile

I'll have to look into /filter... I've never really looked into it. I know, I know... smile

Thanks for the tips. Best way to improve is by getting tips. laugh


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard