mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
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?

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
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


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
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.

Last edited by Bramzee; 18/07/14 02:07 AM.
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
If the file is changing every 30 seconds, it's expected to see a message every 30 seconds.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
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

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
It should be printing the file md5 when it changes. If they're different, then the file is different.

Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
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.

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
What about the md5?

Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
Posts: 170
It says it is... But it's just changing it to the same md5...


Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
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.

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Eh eh, that's my bad, I thought the code had the md5 check already


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
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.

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
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
Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
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.

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
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
Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
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
}



Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Code:
if (%1 == file1) msg #chan ...
elseif (%1 == file2) msg #chan ...

Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
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

Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
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.

Last edited by Bramzee; 23/10/14 11:22 PM.
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Your new username has a space in it?

Page 1 of 2 1 2

Link Copied to Clipboard