| View previous topic :: View next topic |
| Author |
Message |
BhasIRC Voice
Joined: 02 Jan 2010 Posts: 27 Location: south africa
|
Posted: Mon Feb 08, 2010 8:13 am Post subject: help please |
|
|
hi ok i got this code out this forum now it works great just i need the script to also say how long the nick is registered eg. 3 months not jus the time reistered how do i do this , here is the code
| Code: | # nsinfo.tcl
set vNsinfoServices "nickserv@services.dal.net"
set vNsinfoChannel #eggtcl
bind PUB - !nsinfo pNsinfoSend
bind NOTC - * pNsinfoReceive
proc pNsinfoSend {nick uhost hand chan text} {
global vNsinfoChannel vNsinfoServices
if {[string equal -nocase $chan $vNsinfoChannel]} {
set target [string tolower [regsub -all -- {[\s]{2,}} [string trim $text] { }]]
if {[llength [split $target]] == 1} {
if {[regexp -- {^[\x41-\x7D][-\d\x41-\x7D]*$} $target]} {
putserv "PRIVMSG $vNsinfoServices :INFO $target"
} else {putserv "PRIVMSG $vNsinfoChannel :$target is not a valid nick"}
} else {putserv "PRIVMSG $vNsinfoChannel :correct usage !nsinfo <nick>"}
}
return 0
}
proc pNsinfoReceive {nick uhost hand text dest} {
global vNsinfoChannel vNsinfoServices
if {([isbotnick $dest]) && ([string match -nocase ${nick}* $vNsinfoServices])} {
set msg [stripcodes bcruag [string trim $text]]
if {[string match -nocase "*info for*" $msg]} {
putserv "PRIVMSG $vNsinfoChannel :$msg"
} elseif {[string match -nocase "*currently on irc*" $msg]} {
putserv "PRIVMSG $vNsinfoChannel :$msg"
} elseif {[string match -nocase "*last seen address*" $msg]} {
putserv "PRIVMSG $vNsinfoChannel :$msg"
} elseif {[string match -nocase "*last seen time*" $msg]} {
putserv "PRIVMSG $vNsinfoChannel :$msg"
} elseif {[string match -nocase "*time registered*" $msg]} {
putserv "PRIVMSG $vNsinfoChannel :$msg"
} elseif {[string match -nocase "*time now*" $msg]} {
putserv "PRIVMSG $vNsinfoChannel :$msg"
} elseif {[string match -nocase "*options: *" $msg]} {
putserv "PRIVMSG $vNsinfoChannel :$msg"
} elseif {[string match -nocase "*end of info*" $msg]} {
putserv "PRIVMSG $vNsinfoChannel :$msg"
} elseif {[string match -nocase "*is not registered*" $msg]} {
putserv "PRIVMSG $vNsinfoChannel :$msg"
} elseif {[string match -nocase "*is frozen*" $msg]} {
putserv "PRIVMSG $vNsinfoChannel :$msg"
} elseif {[string match -nocase "*cannot be registered*" $msg]} {
putserv "PRIVMSG $vNsinfoChannel :$msg"
}
}
return 0
}
putlog "nsinfo.tcl loaded"
# eof
|
|
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon Feb 08, 2010 3:04 pm Post subject: |
|
|
I'd do it something like this:
Use scan to extract the date part from the "time registered" message recieved from chanserv, and then use clock scan to convert this into a "unixtime timestamp". The exact pattern to use with scan might wary, but atleast the following one should work with the example output from dalnet (using curly brackets to avoid command substitution):
{Time registered : %[a-zA-Z0-9/: ]}
Next, get the difference between "then" and "now" (clock seconds) by subtracting then from now. This gets you the number of seconds the nick has been registered. Now to convert this into something more read-friendly - use eggdrop's duration command and send the result to the desired channel...
All in all, something like this:
| Code: | ...
} elseif {[string match -nocase "*time registered*" $msg]} {
putserv "PRIVMSG $vNsinfoChannel :$msg"
putserv "PRIVMSG $vNsinfoChannel :Registered for [duration [expr [clock seconds] - [clock scan [lindex [scan $msg {Time registered : %[a-zA-Z0-9/: ]}] 0]]]]."
} ... |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
BhasIRC Voice
Joined: 02 Jan 2010 Posts: 27 Location: south africa
|
Posted: Wed Feb 10, 2010 1:10 am Post subject: |
|
|
| thanks |
|
| Back to top |
|
 |
|