mIRC Homepage

Script to read off a .txt file?

Posted By: Dunsparth

Script to read off a .txt file? - 22/04/14 06:20 AM

So i have this script, that i use for my twitch bot to read off a .txt file, basically what i want to do is everytime this txt file creates a new text i want that text to be displayed in my chat, is this possible?

on *:TEXT:followed:#:{
msg # $!read(C:\Users\Blahh\Desktop\streamstuff\TwitchAlerts V0.56.9\Log\LastFollower.txt)
}
}
Posted By: blessing

Re: Script to read off a .txt file? - 22/04/14 08:26 AM

It is not possible to do such thing with on text event.
on text event will be triggered when someone say something in the channel.

Your code will be triggered when someone say "followed" in the channel.

I'm not sure but i guess /timer command will do.
Posted By: sparta

Re: Script to read off a .txt file? - 22/04/14 03:46 PM

Im not shure, but i think you can use the information of the size of the file, or the date it was last edited, and then make use of that.
Posted By: Dunsparth

Re: Script to read off a .txt file? - 22/04/14 08:11 PM

and how would i go about doing that?
Posted By: blessing

Re: Script to read off a .txt file? - 23/04/14 03:02 AM

What comes to mind is use timer to check the file.
If file has text, msg to the channel, clean the file or remove file
Wait for another new text write into the file.

Posted By: Dunsparth

Re: Script to read off a .txt file? - 23/04/14 05:07 AM

what i want to do is have a script that looks at a file and looks to see if it changed. should go kinda like this i think:

if var1 = var2 return
else
var1 != var2
replace var1 with var2
$!read (C:\users\user\desktop\streamstuff\twitchalerts\log\lastfollower.txt)
return

where var2 is the current name in the above file, and var one is a previous copy of that name in that file.

if this makes any sense.

so the flow would go like this:
the script first checks that the stored contents of variable 1 is the same as the name currently in the log file,
if it is the same then return to the top and check again.
if it is not equal to the first variable as in the contents of the log file changed, then update variable one with the new name and then post the name found in the file into the chat. after that is done, then return to the top of the if else statement.

this script will be activating by someone typing in to the chat "Followed"

if you need more information let me know
Posted By: blessing

Re: Script to read off a .txt file? - 24/04/14 02:21 AM

This is untested and based on your posting. Idk if you want it like that or not, but hope you can 'read' and understand the flow of script so you can expand from there.

Code:
on *:TEXT:followed:#:{
  ; if user say followed, fill var %last with value of $read(file.txt,1) 
  var %last $read(C:\Users\Blahh\Desktop\streamstuff\TwitchAlerts V0.56.9\Log\LastFollower.txt,1)
  
  ; check if var %previous.follower has value, fill it to %prev, otherwise %prev will be fill by %last value
  var %prev $iif(%previous.follower,$v1,%last)
  
  if %last != %prev { 
  
   ; %last != %prev, msg %last to channel, replace %previous.follower with %last     
    msg # %last
    set %previous.follower %last
  } 
  ; script done, waits for user say followed again.  
}


Posted By: Dunsparth

Re: Script to read off a .txt file? - 25/04/14 05:56 AM

Thank you !
i'm going to play with this and try to get it to work.
appreciate it.
© 2022 mIRC Discussion Forums