mIRC Home    About    Download    Register    News    Help

Print Thread
#143990 04/03/06 10:14 AM
Joined: Apr 2005
Posts: 53
A
Babel fish
OP Offline
Babel fish
A
Joined: Apr 2005
Posts: 53
Hi,
I am trying to make a netsplit bot with IRCnet support. On IRCnet you join a channel &servers and there are all server notices (server joins and quits), so I made this script:
Code:
on *:notice:*:&servers:{
  if (*Received SQUIT* iswm $1-) {
    msg %split.chan Netsplit detected: $gettok($1-,3,32)
    write split.txt $gettok($1-,3,32) $ctime
  }
  elseif (*Received SERVER* iswm $1-) {
    msg %split.chan Reconnect detected: $gettok($1-,3,32)
; Now here is that script to remove the line?
  }
}  

Notice on split comes like this:
[01:08] -irc.triera.si:&SERVERS- Received SQUIT *.realroot.be from *.nl (Ping timeout)
And on reconnect:
[01:26] -irc.triera.si:&SERVERS- Received SERVER *.realroot.be from *.nl (6 RealROOT Belgium)

So, every split and split time is saved in .txt file. Now when server reconnects it should say:
Reconnect detected: irc.server.com (time in minutes server has been in split)
I don't know how to $calc the time server was splited and how to remove it from splits.txt when it gets back.

And one more question: I would like to add a public command !splits so the bot will list all current splited servers and time they are being splited.
<User> !splits
<Bot> irc1.server.com (30min)
<Bot> irc2.server.com (25min)
...

Thx a lot;)

#143991 04/03/06 03:54 PM
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
To remove a line from a text file, use the -d switch. In your case you need to look for it, so combine it with the -w switch. Example:

/write -dw *text* Test.txt


To calculate with $ctime, simply subtract the old $ctime from the current one, wrapped by $duration(). Example: $duration($calc($ctime - %ctime.old))

To recover the old $ctime written in the file, use the identifier $read, that retrieves a line from a file, along with the w switch - to look for a wildcard. Once you got the line, use $gettok to find the old $ctime =)

Now that you've got your split duration, you can /msg the channel also using $read, but this time use $puttok to replace the old $ctime for the calculation you've done.

I hope this wasn't too confusing :S

Good luck!
Zyzzy.


"All we are saying is give peace a chance" -- John Lennon

Link Copied to Clipboard