mIRC Home    About    Download    Register    News    Help

Print Thread
#248197 26/09/14 07:17 PM
E
Exuviax
Exuviax
E
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.
B
Belhifet
Belhifet
B
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.

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

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

E
Exuviax
Exuviax
E
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.
E
Exuviax
Exuviax
E
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
}


B
Belhifet
Belhifet
B
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
}

E
Exuviax
Exuviax
E
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!


Link Copied to Clipboard