mIRC Home    About    Download    Register    News    Help

Print Thread
#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.
Joined: Jun 2014
Posts: 248
B
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.

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

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.
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.
Joined: Jun 2014
Posts: 248
B
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
}

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.

Link Copied to Clipboard