egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

help please

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
BhasIRC
Voice


Joined: 02 Jan 2010
Posts: 27
Location: south africa

PostPosted: Mon Feb 08, 2010 8:13 am    Post subject: help please Reply with quote

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
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon Feb 08, 2010 3:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
BhasIRC
Voice


Joined: 02 Jan 2010
Posts: 27
Location: south africa

PostPosted: Wed Feb 10, 2010 1:10 am    Post subject: Reply with quote

thanks
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber