mIRC Home    About    Download    Register    News    Help

Print Thread
#262777 04/04/18 12:31 AM
Joined: Dec 2016
Posts: 18
A
apoio82 Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Dec 2016
Posts: 18
good evening
I was able to make the bot write to a file everyone who enters the channel showing the user's channel name date time that he entered
I would like to know how to make a $ (read) and $ (write) for when the user who was already ready was again seen entering the channel was replaced by the newer slot

The command I did was this
On*:JOIN:#:{
/write c:\mirc\see.txt $nick $chan $date $time
}

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
since this is using only the nick, there would be false positives and false negatives.

$read(see.txt,nts,$nick)

The 's' switch scans the file for a line beginning with the $nick value followed by a space, and returns the remainder of the line excluding the match text. So if they entered under a different nick, it won't see them, and if someone else enters with the same nick, it matches. If it finds a match, then $readn is set to that line number, otherwise $readn is set to 0. You can then use write -dl $+ $readn see.txt to delete the line before you write the new info to the end. Since a delete involves rewriting the entire file also, you can replace that old line with the new info: /write -l $+ $readn see.txt $nick $chan $date $time

Joined: Dec 2016
Posts: 18
A
apoio82 Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Dec 2016
Posts: 18
Thnx Maroon:

On *:JOIN:#:{
if ($nick isin $read(see.txt, 1)) { write -l $+ $readn see.txt $nick $chan $date $time }
else { write see.txt $nick $chan $date $time
}
}
On *:text:!seen*:?:{
msg $chan $2 last seen $read(see.txt, nts,$2)
}


THNX laugh

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
a few issues.
1. when you post code, it's a lot easier to read if you've clicked on the hashtag icon to surround that with the code tags. You can click preview to see what it would look like.
2. You should get in the habit of always using the 'nt' switches unless you specifically don't want them. If you use 't' and the 1st line is a number, it uses that as the count for the number when reading a random line, and won't return a line after it. Also, if the 1st line is a number, not using 't' can return an unexpected line. If your test.txt file has 3 lines:

999
888
777

$read(test.txt,n ,2) returns 777
$read(test.txt,nt,2) returns 888

'n' prevents a word beginning with $ or % from being evaluated as an identifier or variable. If your script displays the last thing someone 'said' in channel, and it contained a $word or %word, you can display some undesirable info or take dangerous actions. I know this script won't have line1 being entirely numeric, and you're not writing %word or $word, but the next script might.
3. In your ontext event, you're assuming that $2 has been seen, but if they haven't, your message will have the $read returning $null. You should put the result of $read into a local var instead, then tailor your message into 2 alternatives, depending whether the read returned $null or not.


Link Copied to Clipboard