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.

Check if user is registered with NickServ

Help for those learning Tcl or writing their own scripts.
Post Reply
c
cuthbertx
Voice
Posts: 4
Joined: Sun Feb 27, 2011 10:53 pm

Check if user is registered with NickServ

Post by cuthbertx »

Hello guys,

I've seen a few topics on this, and I know it is based on the network you're on, but I just can't seem to get it to work with what I am wanting. So here is a little background. I have a script that will send an invite to users who are in a database file. However, I want the script to check if the user is registered before it sends the invite. I was hoping to do something like:
if {[isregistered $nick]} {
then do this
}

Or something similar to it. I've tried a few different ways, but just can't seem to get it to work. It doesn't have to be like it is above, but something that will check if they're registered and then continue if so, or return if not.

Here is what I've tried and has been the closest:

Code: Select all

proc nfo:usr {nick host hand text {dest ""}} {
global zop botnick is_reg
set from "NickServ"
set is_reg "0"
  if {([string match -nocase "*3*" $text]) && ([string match -nocase "NickServ" $from])} {
  log "$nick is registered. 3."
  set is_reg "1"
 } else {
  log "$nick is not registered. 0."
  set is_reg "0"
 }
 return 0
}

proc invite {nick uhost handle arg} {
    global infodb ui_entries chan_1 is_reg

   bind notc - "*"          nfo:usr
   putquick "PRIVMSG nickserv :status $nick"

   if {$is_reg == "0"} { return 0 }
I know the above is way off, but any help is greatly appreciated on this.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

You send a command to NickServ to check upon a user if is registered or not, right? What's the command? Also, could you do a check on a user and write here the result?
Once the game is over, the king and the pawn go back in the same box.
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Re: Check if user is registered with NickServ

Post by willyw »

cuthbertx wrote: ...
and I know it is based on the network you're on,
...
If possible, please post the name, etc. of the network.

It should make it a lot easier for scripters and experimenters, if they can simply log onto the network in question and play around with it for themselves, if they wish.
c
cuthbertx
Voice
Posts: 4
Joined: Sun Feb 27, 2011 10:53 pm

Post by cuthbertx »

The network that I am trying this on is: irc.what-network.net -- just to test things out.

The message that is sent to nickserv to check the status is: /msg nickserv status $nick

And the response you get back is:

11:11 -NickServ(services@what-network.net)- STATUS Cuthbertx 3

The last number represents the level that the user is. Level 3 means the nick is registered and identified which is the status I am looking for on the return. The other numbers are 2, 1 and 0 which do not matter and should all return false.

Thanks for your help guys.
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

cuthbertx wrote:The network that I am trying this on is: irc.what-network.net -- just to test things out.
...

Code: Select all

bind pub - "!getstatus" getnickstatus

bind notc - "*STATUS*" noticereply


proc getnickstatus {nick uhost handle chan text} {

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

}


proc noticereply {nick uhost handle text dest} {

   	if {"$nick"!="NickServ"} {
	   return 
	   }

	if {"[lindex [split $text] 2]" == "3"} {

        # this user is online, registered, and id'd with Nickserv
        # do whatever commands here

	} else {
       
        # this user did not return "3"
        # do whatever commands here 

     }
} 


Experiment with something like the above.

I tried very briefly , on your server, and it worked. In place of the comments, I had putserv commands to send me a simple /msg , so that has been edited after pasting it here.

This little bit of code is not meant to be a drop in. It is just meant to illustrate one way to check for that "3" that I think you are wanting to test for.

I hope this helps.
c
cuthbertx
Voice
Posts: 4
Joined: Sun Feb 27, 2011 10:53 pm

Post by cuthbertx »

Thank you for the reply. Going to work with you have provided and see if I can get it going. I'll let ya know if I get it going and share it :)
Post Reply