This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

help please

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
B
BhasIRC
Voice
Posts: 27
Joined: Sat Jan 02, 2010 7:05 am
Location: south africa
Contact:

help please

Post by BhasIRC »

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: Select all

# 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 
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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: Select all

...
} 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
B
BhasIRC
Voice
Posts: 27
Joined: Sat Jan 02, 2010 7:05 am
Location: south africa
Contact:

Post by BhasIRC »

thanks
Post Reply