mIRC Home    About    Download    Register    News    Help

Page 1 of 2 1 2 >
Topic Options
#246999 - 18/07/14 12:32 AM Check .txt file for updates?
Bramzee Offline
Vogon poet

Registered: 22/04/14
Posts: 170
Is there a way to have mIRC constantly (or maybe on a small delay) checking a certain file for if it updated or not? And if it DID update to display a certain message?

Top
#247000 - 18/07/14 12:59 AM Re: Check .txt file for updates? [Re: Bramzee]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3438
Loc: France
Code:
alias monitor {
  var %1 $1-
  if ($1 == list) {
    var %a 1
    echo -a * /monitor's list: 
    while ($timer(%a)) {
      if (monitor* iswm $v1) {
        echo -a $longfn($mid($v2,8))
      }
      inc %a
    }
  }
  elseif ($1 == off) {
    :del
    if ($hget(monitor,$shortfn($2-))) {
      if ($show) echo -a * /monitor: $2- has been removed from the watched list
      hdel monitor $shortfn($2-)
    }
    .timermonitor $+ $shortfn($2-) off 
  }
  elseif ($exists(%1)) {
    if ($isid) {
      tokenize 32 $hget(monitor,$shortfn(%1))
      ;to add the check on $md5 too, use "if ($file(%1).mtime > $2) && ($md5(%1,2) != $1) {"
      if ($file(%1).mtime > $2) {
        echo -st %1 has changed (old md5: $1 - new md5: $md5(%1,2) $+ )
      }
    }
    elseif ($show) echo -a * /monitor: $1- has been added from the watched list
    hadd -m monitor $shortfn(%1) $md5(%1,2) $file(%1).mtime
    .timermonitor $+ $shortfn(%1) -m 0 100 noop $!monitor( %1 )
  }
  else .timer -h 1 0 monitor off %1
}
This will echo in the status window when a file is changing, usage:
/monitor <filename> - Adds a filename to the watch list, do not quote the filename.
/monitor list - Lists all the filename you are currently watching
/monitor off <filename> - Removes the filename from the watch list
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#247001 - 18/07/14 01:49 AM Re: Check .txt file for updates? [Re: Wims]
Bramzee Offline
Vogon poet

Registered: 22/04/14
Posts: 170
EDIT: Alright, so I got this working. Semi. It works fine, but it repeats the message every 30 seconds (roughly) and I don't want it to do that. I want it to just display ONCE when the file has changed. After that, I want it to stop.


Edited by Bramzee (18/07/14 03:07 AM)

Top
#247009 - 18/07/14 01:48 PM Re: Check .txt file for updates? [Re: Bramzee]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3438
Loc: France
If the file is changing every 30 seconds, it's expected to see a message every 30 seconds.
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#247013 - 18/07/14 08:16 PM Re: Check .txt file for updates? [Re: Wims]
Bramzee Offline
Vogon poet

Registered: 22/04/14
Posts: 170
It shouldn't be changing unless I get a new follower if I'm correct. The file is basically just updated from a program called TeeBoard every time I get a new twitch follower. It's possible that it updates every 30 seconds to check for a new follower but I'm not sure since I can't really see what's going on inside the program itself to tell it to update or not. Perhaps there's a way to check if the current file matches another file (that doesn't update unless it doesn't match) and have the message pop up only when the new file has changed? I'm not sure. I tend to over think things a lot. Thank you for your help though smile

Top
#247016 - 18/07/14 09:31 PM Re: Check .txt file for updates? [Re: Bramzee]
Loki12583 Online
Hoopy frood

Registered: 22/01/04
Posts: 1244
It should be printing the file md5 when it changes. If they're different, then the file is different.

Top
#247017 - 18/07/14 09:40 PM Re: Check .txt file for updates? [Re: Loki12583]
Bramzee Offline
Vogon poet

Registered: 22/04/14
Posts: 170
It claim's it's changing every 30 seconds. Well, at first. After turning the monitor off, and then starting it back up it started going crazy and it was "changing" like 3 times a second.

Top
#247018 - 18/07/14 09:47 PM Re: Check .txt file for updates? [Re: Bramzee]
Loki12583 Online
Hoopy frood

Registered: 22/01/04
Posts: 1244
What about the md5?

Top
#247019 - 18/07/14 10:00 PM Re: Check .txt file for updates? [Re: Loki12583]
Bramzee Offline
Vogon poet

Registered: 22/04/14
Posts: 170
It says it is... But it's just changing it to the same md5...


Top
#247020 - 18/07/14 10:11 PM Re: Check .txt file for updates? [Re: Bramzee]
Loki12583 Online
Hoopy frood

Registered: 22/01/04
Posts: 1244
Well then include the md5 in the decision, the script contains a comment that includes the line to use. You might also want to increase the interval of the timer if something is changing the modified time so often.

Top
#247021 - 18/07/14 10:50 PM Re: Check .txt file for updates? [Re: Bramzee]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3438
Loc: France
Eh eh, that's my bad, I thought the code had the md5 check already
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#247078 - 20/07/14 07:48 PM Re: Check .txt file for updates? [Re: Wims]
Bramzee Offline
Vogon poet

Registered: 22/04/14
Posts: 170
Alright, I got the new follower one working. But, when I try monitoring the donations-latest.txt file and the follower-last.txt file, it's only set to send a certain message. Is there anyway to have it ALWAYS set to check just those files and not to monitor files based on input (since I have to do the /monitor input everytime I restart mIRC anyway) I only have the two files that I want checked. And I have certain messages I want to be in my chat when someone follows and when someone donates.

Top
#247084 - 20/07/14 09:42 PM Re: Check .txt file for updates? [Re: Bramzee]
Nillen Offline
Hoopy frood

Registered: 24/12/13
Posts: 779
Loc: Sweden
The script is really good on it's own. Just trigger the script yourself instead, like on start you can script it to monitor both files right away without having to input it yourself.
_________________________
Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net

Top
#247091 - 21/07/14 12:21 AM Re: Check .txt file for updates? [Re: Nillen]
Bramzee Offline
Vogon poet

Registered: 22/04/14
Posts: 170
This isn't going to help with the message to chat. Basically I want it something like this (I know this isn't exactly it I'm just showing it in a better way)

if $read(...follower-last.txt) updates
msg # New Follower! Welcome <newfollower>

if $read(...donation-last.txt) updates
msg # <user> has just donated <amount>

With the current script, it'll send the message (or both) if one or the other happens because it's only searching for updates to the files and isn't sorting which is which. I'm not asking for a script to be written. I just want to know what I change/add to make it sort them out so I can have it pop up in the chat.

Top
#247102 - 21/07/14 07:26 AM Re: Check .txt file for updates? [Re: Bramzee]
Nillen Offline
Hoopy frood

Registered: 24/12/13
Posts: 779
Loc: Sweden
Change the original script from echoing to your window to messaging a channel. Instead of messaging that the md5 has been changed you obviously want to read the new value. If your files will add the latest donator to the end of the file then you want to check for how many $lines the text file has and msg the channel the last line.
_________________________
Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net

Top
#247105 - 21/07/14 08:53 AM Re: Check .txt file for updates? [Re: Nillen]
Bramzee Offline
Vogon poet

Registered: 22/04/14
Posts: 170
I've done all that. I just can't get it to filter which is which. I obviously don't want it to message my channel saying "new follower" when it's a donation and not a follow.

This is what I have right now:

Code:
alias monitor {
  var %1 $1-
  if ($1 == list) {
    var %a 1
    echo -a * /monitor's list: 
    while ($timer(%a)) {
      if (monitor* iswm $v1) {
        echo -a $longfn($mid($v2,8))
      }
      inc %a
    }
  }
  elseif ($1 == off) {
    :del
    if ($hget(monitor,$shortfn($2-))) {
      if ($show) echo -a * /monitor: $2- has been removed from the watched list
      hdel monitor $shortfn($2-)
    }
    .timermonitor $+ $shortfn($2-) off 
  }
  elseif ($exists(%1)) {
    if ($isid) {
      tokenize 32 $hget(monitor,$shortfn(%1))
      ;to add the check on $md5 too, use "if ($file(%1).mtime > $2) && ($md5(%1,2) != $1) {"
      if ($file(%1).mtime > $2) && ($md5(%1,2) != $1) {
        msg # /me New follower! Welcome, $read(C:\Users\braze_000\Documents\TeeBoard\widgets\notifications\follower-last.txt) $+ !!!
      }
    }
    elseif ($show) echo -a * /monitor: $1- has been added to the watched list
    hadd -m monitor $shortfn(%1) $md5(%1,2) $file(%1).mtime
    .timermonitor $+ $shortfn(%1) -m 0 100 noop $!monitor( %1 )
  }
  else .timer -h 1 0 monitor off %1
}



Top
#247110 - 21/07/14 12:35 PM Re: Check .txt file for updates? [Re: Bramzee]
Loki12583 Online
Hoopy frood

Registered: 22/01/04
Posts: 1244
Code:
if (%1 == file1) msg #chan ...
elseif (%1 == file2) msg #chan ...

Top
#247112 - 21/07/14 03:45 PM Re: Check .txt file for updates? [Re: Loki12583]
Bramzee Offline
Vogon poet

Registered: 22/04/14
Posts: 170
Thanks Loki smile For some reason the last time I tried this, it wouldn't work. But, I was tired and more than likely had $1 rather than %1... Either way, thanks a lot for all your help guys!! laugh

Top
#248776 - 24/10/14 12:04 AM Re: Check .txt file for updates? [Re: Bramzee]
Bramzee Offline
Vogon poet

Registered: 22/04/14
Posts: 170
Hate to dig this up, but I recently got a new computer. Everything else works fine but this. Same bit I posted before (with the addition of the suggestion from loki) everytime I try enabling a monitor it returns:

Quote:

* /timermonitorc:\users\...: invalid parameters (line 19, monitors.ini)



this is the exact script I was using before but for some reason won't work now... the only thing that's changed is my username on my computer but I've changed all that over as well... Any clues?




EDIT:

ignore this... sorry. Had it under a (1) folder and it was messing it up.


Edited by Bramzee (24/10/14 12:22 AM)

Top
#248777 - 24/10/14 12:21 AM Re: Check .txt file for updates? [Re: Bramzee]
Loki12583 Online
Hoopy frood

Registered: 22/01/04
Posts: 1244
Your new username has a space in it?

Top
Page 1 of 2 1 2 >