file monitor to anounce on a specific file change

An area for those working on addons and mods for Invision and/or mIRC.

Moderators: L|B, cryoa, Riamus, XMog

file monitor to anounce on a specific file change

Postby Omen » Wed Jan 18, 2006 9:32 am

Hi looking to add script that will send /notice to #channel of a specific file...
e.g filewanted

on 1:TEXT:$trigger:*:/notice $chan $read($mircdir\testdirectory\filewanted.txt,$lines($mircdir\testdirectory\filewanted.txt))


now i need to figure how to have this filewanted.txt sent /notice when file has been changed (filemonitor).

tks

Omen
Omen
Member
Member
 
Posts: 5
Joined: Wed Jan 18, 2006 9:19 am

Postby Riamus » Wed Jan 18, 2006 2:58 pm

First of all, your $read is only going to display the last line in the file. Is that what you wanted?

Also, what is changing the file? A script? Or is it being changed manually? Or something else?
You can find me at #Invision on irc.irchighway.net or #OldGames on irc.undernet.org if you need me for anything.
User avatar
Riamus
Global Moderator
Global Moderator
 
Posts: 1783
Joined: Fri May 03, 2002 9:01 pm
Location: Massachusetts, USA

Postby 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) }
}
Omen
Member
Member
 
Posts: 5
Joined: Wed Jan 18, 2006 9:19 am

Postby Riamus » Thu Jan 19, 2006 9:32 am

You can find me at #Invision on irc.irchighway.net or #OldGames on irc.undernet.org if you need me for anything.
User avatar
Riamus
Global Moderator
Global Moderator
 
Posts: 1783
Joined: Fri May 03, 2002 9:01 pm
Location: Massachusetts, USA


Return to Developers Corner

Who is online

Users browsing this forum: No registered users and 12 guests

cron