|
Joined: Jul 2006
Posts: 242
Fjord artisan
|
OP
Fjord artisan
Joined: Jul 2006
Posts: 242 |
Greetings all,
I would like to set a variable, and then want to be able to check if the variable was set more then a week ago to do something.
i.e if (%var more then a week old { execute }
Thanks in advance.
|
|
|
|
Joined: Aug 2004
Posts: 7,168
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,168 |
No need to use $ticks for this. Here's a quick example of how you could do this. on me:*:join:#:{
set $+(%,join,.,$network,.,$chan) $ctime
}
on *:text:*:#:{ check_join $chan }
on *:action:*:#:{ check_join $chan }
on *:notice:*:#:{ check_join $chan }
alias -l check_join {
if $calc($ctime - $($+(%,join,.,$network,.,$1),2)) >= $duration(1 week) {
.msg $1 I've now been in $1 for 1 week or more consistently.
}
}
If this is not sufficient for you to amend for your specific purposes, reply back with more details and we'll see what we can do to help.
|
|
|
|
Joined: Jul 2006
Posts: 242
Fjord artisan
|
OP
Fjord artisan
Joined: Jul 2006
Posts: 242 |
Thanks, this is very helpful. Can i also check if it was LESS then a week ago by amending the code to if $calc($ctime - $($+(%,join,.,$network,.,$1),2))<= $duration(1 week ? thanks again
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
Yes... if you include the rest of that line. 
|
|
|
|
Joined: Jul 2006
Posts: 242
Fjord artisan
|
OP
Fjord artisan
Joined: Jul 2006
Posts: 242 |
I think I am getting there, but still unsure. I want to add a value to a hash table called "test" so i.e hadd -m hashtable test $ctime I now want an alais to test if that value in the hash table is LESS then a week old, and if it is to execute a command. i.e if($hget(hashtable,test) < then a week) { command
} Sorry for being confusing earlier, I actually need less then a week not more. Thanks. p.s anyway for me to test that the code is working, as I do not know $ctime values from over a week ago? Kindest regards
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
Just put in the rest of what was shown: if($hget(hashtable,test) < $duration(1 week)) { command
} p.s anyway for me to test that the code is working, as I do not know $ctime values from over a week ago? $ctime always changes. To know if it's working, you need the current $ctime to be 604800 higher than what is stored in your hash table. Then, just check with your IF statement. This is how you'd know what the difference needs to be: //echo -a $duration(1 week)
|
|
|
|
Joined: Jul 2006
Posts: 242
Fjord artisan
|
OP
Fjord artisan
Joined: Jul 2006
Posts: 242 |
if($hget(hashtable,test) < $duration(1 week)) { command
} Do i need to use $calc for that?
|
|
|
|
Joined: Jul 2006
Posts: 242
Fjord artisan
|
OP
Fjord artisan
Joined: Jul 2006
Posts: 242 |
Hi all,
Thanks for all the replies so far.
I have tried playing with this, and have not succeeded in getting it to work.
I have pasted this in my mIRC window
//hadd hashtable test $ctime
//if $calc($ctime - $hget(hashtable,test) <= $duration(1 week)) { echo -a lol } it echoes lol
but if i also do //if $calc($ctime - $hget(hashtable,test) >= $duration(1 week)) { echo -a lol }
it still echoes lol.
?!?
|
|
|
|
Joined: Feb 2006
Posts: 180
Vogon poet
|
Vogon poet
Joined: Feb 2006
Posts: 180 |
//if $calc($ctime - $hget(hashtable,test) <= $duration(1 week)) { echo -a lol }
//if $calc($ctime - $hget(hashtable,test) >= $duration(1 week)) { echo -a lol }
//if $calc($ctime - $hget(hashtable,test) ) <= $duration(1 week) { echo -a lol } //if $calc($ctime - $hget(hashtable,test) ) >= $duration(1 week) { echo -a lol }
|
|
|
|
Joined: Jul 2006
Posts: 242
Fjord artisan
|
OP
Fjord artisan
Joined: Jul 2006
Posts: 242 |
Thanks to all replies. Working now as intended.
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
Yeah, I didn't pay attention to what you had in the table. $calc would be needed. Sorry about that.
|
|
|
|
|