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.

Catching nickserv response

Help for those learning Tcl or writing their own scripts.
Post Reply
H
Hoden
Voice
Posts: 2
Joined: Mon Sep 21, 2015 4:25 pm

Catching nickserv response

Post by Hoden »

I'm developing an script and I need to catch Nickserv response (user mode, specifically). The server's nickserv says this:
Returns whether the user(s) using the given nickname is recognized as the owner of the nickname. The response has this format:

nickname status-code

where nickname is the nickname sent with the command, and status-code is one of the following:

0 - no such user online or nickname not registered
1 - user not recognized as nickname's owner
2 - user recognized as owner via access list only
3 - user recognized as owner via password identification
What I need is an tcl code to send through /msg something like "/msg nickserv status JohnDoe", and the Nickserv answer needs to be stored on some variable (Nickserv always answer like "JohnDoe 3"). Then I can would use this number (0, 1, 2 or 3) after.

Thanks in advance.
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Re: Catching nickserv response

Post by willyw »

Hoden wrote:I'm developing an script ....
So you know some TCL , and just need a rough example?
... and the Nickserv answer needs to be stored on some variable ...
Then I can would use this number (0, 1, 2 or 3) after.
...
Play around with this:

Code: Select all


# Septermber 21, 2015

# http://forum.egghelp.org/viewtopic.php?t=20044

# What I need is an tcl code to send through /msg something like "/msg nickserv status JohnDoe", and the Nickserv answer needs to be
# stored on some variable (Nickserv always answer like "JohnDoe 3"). Then I can would use this number (0, 1, 2 or 3) after.


# Usage:
# !nickstatus <nick>
#



bind pub - "!nickstatus" do_nick_status

bind notc - "*status*" status_notice



proc do_nick_status {nick uhost handle chan text} {

        if {![llength [split $text]]} {
                putserv "privmsg $chan :Syntax: !nickstatus <nick> "
                return 0
         }

        putserv "privmsg Nickserv :status [lindex [split $text] 0]"

}


proc status_notice {nick uhost handle text dest} {

        # Bot will output on this channel.  Just needed somewhere to have
        # it put the values, so you can see them.
        set chan "#testchan1"


        if {[string tolower $nick] ne "nickserv"} {
                return 0
        }

        if {[string tolower [lindex [split $text] 0]] ne "status"} {
                return 0
        }


        set status_nick [lindex [split $text] 1]
        set status_value [lindex [split $text] 2]

        putserv "privmsg $chan : "
        putserv "privmsg $chan :status_nick is: $status_nick"
        putserv "privmsg $chan :status_value is: $status_value"

}

With a couple brief tests on an irc network that has what seems to be the same Status command, it worked.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
H
Hoden
Voice
Posts: 2
Joined: Mon Sep 21, 2015 4:25 pm

Post by Hoden »

This script works very nice, thank you!
Post Reply