I am trying to make a script for twitch, for when a viewer would like to know something like when they joined the stream, and how long that have spent watching the stream.

I am at a loss for what direction to take with this task, and have spent time going through forums looking for anything that mite lead me in the right direction, I have come up with a few ideas on how to get this to work, but I am a total noob at this kind of thing, if anyone has some suggestions I would greatly appreciate it.

this is what I have come up with, I know its not in proper code format, its just what i've jotted down while I've been scouring the forums.

On join #
write $nick & $ctime ddmmyyyy to .txt file

on txt !joined
read .txt /msg $chan $nick joined $ctime ddmmyyyy

on txt !viewtime
read .txt $duration
/msg $chan has watched XX hours XX minutes XX seconds


thank you in advance for any great suggestions that may arise from this mess of a task lol cheers