There isn't a section for just mIRC snippets/addons so i'll post this here.
This snippet will monitor files for changes and tell you when they're changed or deleted.
Note: this snippet will only work on mIRC 6.16, if you want to use it in older versions of mIRC then you can simply change '$v1' to '$ifmatch' on line 52.
/*
What does /monitorfile do?
/monitorfile will watch a file and tell you when the file is modified or deleted, it will send a 'monitorfile' signal with either
'FILE_DELETE' or 'FILE_CHANGE' as the first parameter followed by the file that was being watched.
If you don't use a . with the /monitorfile command (/.monitorfile) then you will also see some information in the active window when files
are changed or deleted.
All error/information messages should replicate mIRCs own messages.
/monitorfile uses a 5 second interval to check for changes in files.
How do I use /monitorfile?
The syntax is: /monitorfile [off] <file>
If you specify [off] then the specified file will no longer be monitored.
Otherwise, the specified file will start being monitored.
How does /monitorfile work? (For scripters)
/monitorfile will store the crc value of a file when you start monitoring a file and check the current crc value against the stored one
every 5 seconds.
If the value doesn't match then the FILE_CHANGE signal will be sent and the new crc value will be stored.
If the file no longer exists when /monitorfile goes to check the current crc value then the FIlE_DELETE signal will be sent and the timer
will be stopped.
Can you give me an example of using this?
on *:start:{ .monitorfile $mircini }
on *:signal:monitorfile:{
if ($1 == FILE_CHANGE) && ($2- == $mircini) { echo $color(info) -afilr Hi $+($me,!) mIRC will just revert all changes to mirc.ini so $&
there's no point in changing it unless you used the options dialog. :) }
}
How can I contact you?
You can email me at [email protected] or [email protected]
You can also find me in #mIRC or #mirc.net on IRC at irc.undernet.org but I am not always there.
*/
alias checkfile {
if (!$isfile($1-)) {
.signal -n monitorfile FILE_DELETE $1-
hdel monitorfile $replace($1-,$chr(32),\s)
if (!$hget(monitorfile,0).item) { hfree monitorfile }
$+(.timermonitorfile,$replace($1-,$chr(32),\s)) off
echo $color(info) -afilqr * /monitorfile: No longer monitoring $+(',$1-') for changes (File was deleted).
linesep -a
return
}
if ($crc($1-) != $hget(monitorfile,$replace($1-,$chr(32),\s))) {
hadd -m monitorfile $replace($1-,$chr(32),\s) $v1
.signal -n monitorfile FILE_CHANGE $1-
echo $color(info) -afilqr * /monitorfile: File $+(',$1-') has changed.
linesep -a
}
}
alias monitorfile {
if ($1 == off) && ($hget(monitorfile,$replace($2-,$chr(32),\s))) {
hdel monitorfile $replace($2-,$chr(32),\s)
if (!$hget(monitorfile,0).item) { hfree monitorfile }
$+(.timermonitorfile,$replace($2-,$chr(32),\s)) off
echo $color(info) -afilqr * /monitorfile: No longer monitoring $+(',$1-') for changes (Stopped by user).
linesep -a
return
}
if (!$isfile($1-)) {
if (!$line($active,0)) { linesep -a }
echo $color(info) -abfilr * /monitorfile: No such file $+(',$1-')
linesep -a
return
}
hadd -m monitorfile $replace($1-,$chr(32),\s) $crc($1-)
$+(.timermonitorfile,$replace($1-,$chr(32),\s)) 0 5 $+($iif(!$show,.),checkfile) $1-
echo $color(info) -afilqr * /monitorfile: Now monitoring $+(',$1-') for changes.
}