by Omen » Wed Jan 18, 2006 4:58 pm
have this running at moment and works.... now i'd like to have the notice sent 10 times at intervals of 60minutes..?
/notice #works New log detected $read($mircdir\logs\log.txt,$lines($mircdir\logs\log.txt))
****** start script bellow ******
var %BEVlog $mircdir\logs\log.txt
on 1:TEXT:$log:*:/notice $chan Latest log $read($mircdir\logs\log.txt,$lines($mircdir\logs\log.txt))
on *:start:{ .monitorfile $mircdir\logs\log.txt }
on *:signal:monitorfile:{
if ($1 == FILE_CHANGE) && ($2- == $mircdir\logs\log.txt) {
/notice #works New log detected $read($mircdir\logs\log.txt,$lines($mircdir\logs\log.txt))
}
}
alias checkfile {
if (!$isfile($1-)) {
.signal -n monitorfile FILE_DELETE $1-
if ($hget(monitorfile)) {
hdel monitorfile $replace($1-,$chr(32),<)
if (!$hget(monitorfile,0).item) { hfree monitorfile }
}
$+(.timermonitorfile,$replace($1-,$chr(32),<)) off
if (!$line($active,0)) { linesep -a }
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),<))) {
hadd -m monitorfile $replace($1-,$chr(32),<) $crc($1-)
.signal -n monitorfile FILE_CHANGE $1-
if (!$line($active,0)) { linesep -a }
echo $color(info) -afilqr * /monitorfile: File $+(',$1-') has changed.
linesep -a
}
}
alias monitorfile {
if (!$isid) {
if ($istok(-l -s,$1,32)) {
if ($hget(monitorfile)) {
var %i = 1
tokenize 32 $1 $replace($2,$chr(32),<)
if ($1 == -s) {
while ($hfind(monitorfile,$2,1,w)) {
echo $color(info) -afilqr * /monitorfile: No longer monitoring $+(',$replace($hfind(monitorfile,$2,1,w),<,$chr(32)),') $&
for changes (Stopped by user).
linesep -a
$+(.timermonitorfile,$hfind(monitorfile,$2,1,w)) off
hdel monitorfile $hfind(monitorfile,$2,1,w)
}
}
else {
if ($2 == $null) { tokenize 32 -l * }
if (!$line($active,0)) { linesep -a }
echo $color(info) -afilr * Monitoring files:
var %i = 1
while ($hfind(monitorfile,$2,%i,w)) {
echo $color(info2) -afilr $hfind(monitorfile,$2,%i,w)
inc %i
}
}
if (!$hget(monitorfile,0).item) { hfree monitorfile }
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),<) $crc($1-)
$+(.timermonitorfile,$replace($1-,$chr(32),<)) 0 5 $+($iif(!$show,.),checkfile) $1-
if (!$line($active,0)) { linesep -a }
echo $color(info) -afilqr * /monitorfile: Now monitoring $+(',$1-') for changes.
linesep -a
}
else { return $hfind(monitorfile,$1,$iif($2 != $null,$v1,1),w) }
}