Code: Select all
[14:32] -NickServ- Time registered : Thu 23-Sep-2004 01:00:59 UTC
[14:32] -NickServ- Time now : Fri 05-Oct-2007 09:31:06 UTC
Thanks
iamdeath
Code: Select all
[14:32] -NickServ- Time registered : Thu 23-Sep-2004 01:00:59 UTC
[14:32] -NickServ- Time now : Fri 05-Oct-2007 09:31:06 UTC
Code: Select all
set then [clock scan "Thu 23-Sep-2004 01:00:59 UTC"]
set now [clock scan "Fri 05-Oct-2007 09:31:06 UTC"]
set secondsInADay 86400
set daysAgo [expr {($now-$then)/$secondsInADay}]
Code: Select all
### Event
bind join - "#channel *!*@*" join-ignore
bind notc - "*is not a valid nickname*" notice-ignore
bind notc - "*Time registered*" notice-ignore
bind notc - "*Time now*" notice-ignore
### Command
proc join-ignore {nick uhost handle chan} {
putquick "PRIVMSG nickserv@services.dal.net :info $nick"
}
proc notice-ignore {nick uhost hand text dest} {
if {[string match "*is not a valid nickname*" $text]} {return}
if {[string match "*Time registered*" $text]} {
set then [split $text]
set then [lrange $text 3 end]
putlog "$then Before"
}
if {[string match "*Time now*" $text]} {
set now [split $text]
set now [lrange $text 3 end]
putlog "$now After"
}
set then [clock scan "$then"]
set now [clock scan "$now"]
set secondsInADay 86400
set daysAgo [expr {($now-$then)/$secondsInADay}]
putlog "$daysAgo Days ago"
}
Code: Select all
Thu 23-Sep-2004 01:00:59 UTC Before
Tcl error [notice-ignore]: can't read "now": no such variable
Sat 06-Oct-2007 05:16:15 UTC After
Tcl error [notice-ignore]: can't read "then": no such variable
Code: Select all
set daysAgo [expr {($now-$then)/$secondsInADay}]
Code: Select all
set then [lrange $text 3 end]
Code: Select all
Thu 23-Sep-2004 01:00:59 UTC Before
Code: Select all
set then [clock scan "Thu 23-Sep-2004 01:00:59 UTC"]
set now [clock scan "Fri 05-Oct-2007 09:31:06 UTC"]
set secondsInADay 86400
set daysAgo [expr {($now-$then)/$secondsInADay}]
Code: Select all
### Event
bind join - "#Islamabad *!*@*" join-ignore
bind notc - "*is not a valid nickname*" notice-ignore
bind notc - "*Time registered*" notice-ignore
bind notc - "*Time now*" notice-ignore
### Command
proc join-ignore {nick uhost handle chan} {
putquick "PRIVMSG nickserv@services.dal.net :info $nick"
}
proc notice-ignore {nick uhost hand text dest} {
if {[string match "*is not a valid nickname*" $text]} {return}
if {[string match "*Time registered*" $text]} {
set then [split $text]
set then [lrange $text 3 end]
set then [clock scan "$then"]
if {[string match "*Time now*" $text]} {
set now [split $text]
set now [lrange $text 3 end]
set now [clock scan "$now"]
set secondsInADay 86400
set daysAgo [expr {($now-$then)/$secondsInADay}]
putlog "$daysAgo Days ago"
}
}
}
putlog "Nickname ignore tcl Loaded!"
Code: Select all
### Event
bind join - "#Islamabad *!*@*" join-ignore
bind notc - "*is not a valid nickname*" notice-ignore
bind notc - "*Time registered*" notice-ignore
bind notc - "*Time now*" notice-ignore1
### Command
proc join-ignore {nick uhost handle chan} {
putquick "PRIVMSG nickserv@services.dal.net :info $nick"
}
proc notice-ignore {nick uhost hand text dest} {
global then
set then [split $text]
set then [lrange $text 3 end]
set then [clock scan "$then"]
putlog "$then"
}
proc notice-ignore1 {nick uhost hand text dest} {
global now then
set now [split $text]
set now [lrange $text 3 end]
set now [clock scan "$now"]
set secondsInADay 86400
set daysAgo [expr {($now-$then)/$secondsInADay}]
putlog "$daysAgo Days ago"
putlog "$now"
}
putlog "Nickname ignore tcl Loaded!"
Code: Select all
proc notice-ignore {nick uhost hand text dest} {
if {[string match "*is not a valid nickname*" $text]} {return}
if {[string match "*Time registered*" $text]} {
set then [split $text]
set then [lrange $text 3 end]
set then [clock scan "$then"]
set now [unixtime]
putlog "debug then '$then'"
putlog "debug now '$now'"
set secondsInADay 86400
set daysAgo [expr {($now-$then)/$secondsInADay}]
putlog "someone registered $daysAgo Days ago"
}
}
Thank your very very much it solved the problem actually I was trying to help this user thought I would learn something out of it too and I did learn many things, thanks alot to all of you guys for your great support and patience to stand merosc2112 wrote:Usually you can set the time for "now" using the tcl 'clock' command, or the eggdrop strftime, ctime or unixtime commands, there's a few different ways to go about it, no real need to depend on chanserv to get it (although you might have to account for the different timezones between what your shell and [unixtime] and chanserv are using.
As far as how to keep the $then var across proc's, just declare it as a global var at the top of each proc that needs it.
Anyway, the logic in your script won't set the vars properly.
The errors you're getting is because this proc is being run for each and every notice the bot is receiving, so maybe nest all further processing under the 1st test for if {[string match "*Time registered*" $text]} {
eg:One last piece of advice - INDENT YOUR CODE =)Code: Select all
proc notice-ignore {nick uhost hand text dest} { if {[string match "*is not a valid nickname*" $text]} {return} if {[string match "*Time registered*" $text]} { set then [split $text] set then [lrange $text 3 end] set then [clock scan "$then"] set now [unixtime] putlog "debug then '$then'" putlog "debug now '$now'" set secondsInADay 86400 set daysAgo [expr {($now-$then)/$secondsInADay}] putlog "someone registered $daysAgo Days ago" } }
Makes it much easier to debug..