|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
i have this value: 05:27:59 yes its a time set.. how can i calc the time between that value and the curent time? :tongue: or is it any easyer way to do it? i working on a seen script, and need to get the time when the nick was last seen quitting.. :tongue: never dont this befor so all help is welcome, i have been writing all the parts it needs, only this part left..
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Dec 2002
Posts: 127
Vogon poet
|
Vogon poet
Joined: Dec 2002
Posts: 127 |
while i'm sure it is possible to calculate the time difference given your data, it would be much easier to use $ctime and then subtract that from the current $ctime. use $duration($calc(%var - $ctime))
------ deep down, i'm really superficial.
|
|
|
|
Joined: Aug 2003
Posts: 314
Fjord artisan
|
Fjord artisan
Joined: Aug 2003
Posts: 314 |
Since a time is being handled I'd go with $duration here: $duration($abs($calc($duration($time(HH:nn:ss)) - $duration(05:27:59))))
You can alter the format of $time() to measure the time until or the time since the specific time
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
No i haver this value stored in a text file:
nick (ident@host) was last seen changing nick on to newnick 1099593370
but how would i go about to calc the right numbers? $read cant filter out the part where it says '1099593370' ?
echo $read(info.txt, s, mirc) wont do me any good.. cos 1: i never know what the line beggins with.. 2: the address can contain a number..
and that would screw everything up :tongue:
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Apr 2003
Posts: 414
Fjord artisan
|
Fjord artisan
Joined: Apr 2003
Posts: 414 |
You can use regex to get 1099593370 from "nick (ident@host) was last seen changing nick on to newnick 1099593370"
var %reg = /.*(\d{10})/
var %str = nick (ident@host) was last seen changing nick on to newnick 1099593371
echo zz $regex(%str,%reg)
echo zazibu $regml(1)
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
the red line:
var %reg = /.*(\d{10})/
var %str = nick (ident@host) [color:red] was last seen changing nick on to newnick[/color] 1099593371
echo zz $regex(%str,%reg)
echo zazibu $regml(1)
changes, so its not shure it looks like that, how ever the 1099593371will be at the end of all the line, the 1099593371 changes tho.. so im not shure how that line would work? :tongue:
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Apr 2003
Posts: 414
Fjord artisan
|
Fjord artisan
Joined: Apr 2003
Posts: 414 |
For that regular expresion have matter only the last 10 digitals from end of the line.. So it must work fine with..
var %str = nick (ident@host) 1099593371 var %str = nick (ident@host) blalvla 1099593371 or just var %str = 1099593371
Hope that help..
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
nope.. i guess i just have to give up this.. been trying everything i can think about now, also the codes provided by you..
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
couldent edit my old post so here we go..
on *:text:*:#:{
if ($1 == $seentrigger) {
var %x $read(" $+ $mircdirmap/seen.text $+ ", w,* $+ $2 $+ *)
set %tmp.seen $readn
;if (%tmp.seen == 1) { goto next } <<-- will be working later if nick not seen..
var %reg = /.*(\d{10})/
var %str = $2 (ident@host) was last seen changing nick on to newnick 1099593371
}
}
i cant get it to give the time in days/houers/minutes/seconds .. it only send it as '1099593371' , and i have been trying to calc that diffrent ways, still same result.. it gives the wrong value.. so im totaly stuck here.. somone that ether can point me to the right way.. or maybe even show me how its done? :tongue:
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Feb 2004
Posts: 206
Fjord artisan
|
Fjord artisan
Joined: Feb 2004
Posts: 206 |
To get the last token, just use $0 to find the number of space delimited tokens (in $1- ).
Thus, the time figure will be [ $ $+ $0 ], e.g. /var %timeString = [ $ $+ $0 ]
Because this works with "$1-", the way to make it work efficiently is:
alias GetLastToken { return [ $ $+ $0 ] }
and in your main script:
var %timeTicksString = $GetLastToken($read(<whatever your read command is>))
Cheers,
DK
p.s. untested.
Darwin_Koala
Junior Brat, In-no-cent(r)(tm) and original source of DK-itis!
|
|
|
|
Joined: Apr 2003
Posts: 414
Fjord artisan
|
Fjord artisan
Joined: Apr 2003
Posts: 414 |
on *:text:*:#:{
if ($1 == $seentrigger) {
var %x $read(" $+ $mircdirmap/seen.text $+ ", w,* $+ $2 $+ *)
set %tmp.seen $readn
;if (%tmp.seen == 1) { goto next } <<-- will be working later if nick not seen..
var %reg = /.*(\d{10})/
var %str = $2 (ident@host) was last seen changing nick on to newnick 1099593371
if ($regex(%str,%reg)) {
var %stime = $regml(1)
var %difference = $duration($calc($ctime - %stime))
msg $chan Last seen: %difference ago
}
else {
echo ERROR.. Can't find last seen time..
}
}
}
Try that ? Untested..
|
|
|
|
Joined: Aug 2003
Posts: 314
Fjord artisan
|
Fjord artisan
Joined: Aug 2003
Posts: 314 |
You're on the right track here but the actual syntax would be $ [ $+ [ $0 ] ] since [ $ $+ $0 ] simply joins $ and $0 to yield $$0 and evaluates that. However, when using $0 within a custom alias called as an identifier, it returns the number of parameters, so when using $myalias(words here) $0 would return 1 with $1 returning "words here"
I'd just use $gettok for this particular script:
on *:text:$($seentrigger *):#:{ if ($gettok($read($mircdirmap/seen.txt,s,$2),-1,32)) msg # $2 was last seen $duration($calc($ctime -$ifmatch)) ago else msg # I have not seen $2 }
|
|
|
|
|