mIRC Home    About    Download    Register    News    Help

Print Thread
Updating on Text Update #248197 26/09/14 07:17 PM
Joined: Mar 2014
Posts: 65
E
Exuviax Offline OP
Babel fish
OP Offline
Babel fish
E
Joined: Mar 2014
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.

Last edited by Exuviax; 26/09/14 07:25 PM.

I do things with stuff that makes other things do stuff.
Re: Updating on Text Update [Re: Exuviax] #248198 26/09/14 07:28 PM
Joined: Jun 2014
Posts: 248
B
Belhifet Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
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.

Re: Updating on Text Update [Re: Belhifet] #248199 26/09/14 10:59 PM
Joined: Jan 2004
Posts: 1,282
L
Loki12583 Online
Hoopy frood
Online
Hoopy frood
L
Joined: Jan 2004
Posts: 1,282
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)

Last edited by Loki12583; 26/09/14 11:00 PM.
Re: Updating on Text Update [Re: Loki12583] #248200 27/09/14 12:30 AM
Joined: Mar 2014
Posts: 65
E
Exuviax Offline OP
Babel fish
OP Offline
Babel fish
E
Joined: Mar 2014
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.
Re: Updating on Text Update [Re: Exuviax] #248201 27/09/14 12:46 AM
Joined: Jan 2004
Posts: 1,282
L
Loki12583 Online
Hoopy frood
Online
Hoopy frood
L
Joined: Jan 2004
Posts: 1,282
$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.

Re: Updating on Text Update [Re: Loki12583] #248202 27/09/14 01:07 AM
Joined: Mar 2014
Posts: 65
E
Exuviax Offline OP
Babel fish
OP Offline
Babel fish
E
Joined: Mar 2014
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?

Last edited by Exuviax; 27/09/14 01:16 AM.

I do things with stuff that makes other things do stuff.
Re: Updating on Text Update [Re: Exuviax] #248203 27/09/14 03:07 AM
Joined: Mar 2014
Posts: 65
E
Exuviax Offline OP
Babel fish
OP Offline
Babel fish
E
Joined: Mar 2014
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.
Re: Updating on Text Update [Re: Exuviax] #248204 27/09/14 05:32 AM
Joined: Jun 2014
Posts: 248
B
Belhifet Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
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
}

Re: Updating on Text Update [Re: Belhifet] #248207 27/09/14 09:20 AM
Joined: Mar 2014
Posts: 65
E
Exuviax Offline OP
Babel fish
OP Offline
Babel fish
E
Joined: Mar 2014
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.