mIRC Home    About    Download    Register    News    Help

Topic Options
#248197 - 26/09/14 08:17 PM Updating on Text Update
Exuviax Offline
Babel fish

Registered: 23/03/14
Posts: 65
Hey,

Is it possible to have the bot auto read and say whats in a text file on update? So when the file is updated the bot will automatically read it out? Or maybe have the bot go to read out the file ever 30 seconds but only if there was a change in the file?

EDIT: Second Question.

I am reading from a text file that is using Currency, so it says $25 in their, the bot won't read that out, probably because of the $, how can I fix that? I can't take it out of the Text File.


Edited by Exuviax (26/09/14 08:25 PM)
_________________________
I do things with stuff that makes other things do stuff.

Top
#248198 - 26/09/14 08:28 PM Re: Updating on Text Update [Re: Exuviax]
Belhifet Offline
Fjord artisan

Registered: 26/06/14
Posts: 248
Uh..sure several ways to do this. Maybe keep two copies of the file and have mirc update one textfile when there is a difference and have it read then.

Top
#248199 - 26/09/14 11:59 PM Re: Updating on Text Update [Re: Belhifet]
Loki12583 Offline
Hoopy frood

Registered: 22/01/04
Posts: 1244
You can use a timer and a combination of $file().mtime and $md5

Without the n switch $read will evaluate the line. That means $25 is evaluated to the 25th token in $1-. You should always use the n switch.

$read(file,n,1)


Edited by Loki12583 (27/09/14 12:00 AM)

Top
#248200 - 27/09/14 01:30 AM Re: Updating on Text Update [Re: Loki12583]
Exuviax Offline
Babel fish

Registered: 23/03/14
Posts: 65
Awesome! Thanks Loki! I got the ,n, to work, but I don't really understand the $file().mtime and $md5 as I have never used that before. Do you think you could help me write it out?
_________________________
I do things with stuff that makes other things do stuff.

Top
#248201 - 27/09/14 01:46 AM Re: Updating on Text Update [Re: Exuviax]
Loki12583 Offline
Hoopy frood

Registered: 22/01/04
Posts: 1244
$file(file).mtime will return the time the file was last modified, you can store this value and compare it later to know if it's been modified. Sometimes a program will open the file and write it again without changing it, this will alter the mtime but since the file has not changed you need to use $md5(file,2) and compare it to the last md5 to make sure the content is different.

Top
#248202 - 27/09/14 02:07 AM Re: Updating on Text Update [Re: Loki12583]
Exuviax Offline
Babel fish

Registered: 23/03/14
Posts: 65
Alright, this is what I tried (I am by no means a Coder)

Code:
on *:Text:!last:#:{
  if (check.txt != $file(C:\Users\Randy\Documents\Streamtip\tip-recent.txt)) {
    msg #  New Donation: $read(C:\Users\Randy\Documents\Streamtip\tip-recent.txt,n,1) 
    write check.txt $file(C:\Users\Randy\Documents\Streamtip\tip-recent.txt).mtime
  }
}


Is that what you meant?


Edited by Exuviax (27/09/14 02:16 AM)
_________________________
I do things with stuff that makes other things do stuff.

Top
#248203 - 27/09/14 04:07 AM Re: Updating on Text Update [Re: Exuviax]
Exuviax Offline
Babel fish

Registered: 23/03/14
Posts: 65
I got it working!!

Final Code

Code:
on *:text:*:#exuviax: {
  var %one { $read(C:\Users\Randy\Documents\Streamtip\tip-recent.txt,n,1) }
  var %two { $read(C:\Users\Randy\AppData\Roaming\mIRC\check.txt,n,1) }
  if (%two isin %one) { return }
  msg # New Donation: %one 
  write -c check.txt %one
}

_________________________
I do things with stuff that makes other things do stuff.

Top
#248204 - 27/09/14 06:32 AM Re: Updating on Text Update [Re: Exuviax]
Belhifet Offline
Fjord artisan

Registered: 26/06/14
Posts: 248
It would probably be best to run it on a timer instead of every time someone speaks. This runs it every 30 seconds..you can set that to w/e you want but there certainly isn't any reason to potentially run this script multiple times per second.
Code:
on *:CONNECT: {
  .timerdonations 0 30 donations
}
alias donations {
  var %one $read(C:\Users\Randy\Documents\Streamtip\tip-recent.txt,n,1) 
  var %two $read(C:\Users\Randy\AppData\Roaming\mIRC\check.txt,n,1) 
  if (%two isin %one) { return }
  msg #exuviax New Donation: %one 
  write -c check.txt %one
}

Top
#248207 - 27/09/14 10:20 AM Re: Updating on Text Update [Re: Belhifet]
Exuviax Offline
Babel fish

Registered: 23/03/14
Posts: 65
Oh! Thank you so much! That actually makes me so happy, I was actually thinking about a way to have more then just "When you type" messages in chat! Awesome!
_________________________
I do things with stuff that makes other things do stuff.

Top