Determine If a User Is Idented On IRC
Asked Answered
A

7

12

In my IRC Bot, there are some commands that I want to only be usable by me, and I want to check to make sure that anyone using my name is identified with nickserv (idented). I couldn't, however, find an easy way to determine this, which is why I'm here.

Freenode and Rizon are the primary target networks, if that matters.

Edit: I was actually aware of the various usermodes for idented users (although I didn't pay enough attention to realize that they differ!); sorry for not mentioning that before. The raw response that I get from a user, however, doesn't include their usermodes; it looks something like this:

:[email protected] PRIVMSG #erasmus-testing :foo

I suppose, then, that I'm trying to find a way (with various ircds, grr) to get those flags. If, as someone mentioned, Rizon returns whether or not someone is idented in a WHOIS query, then that's the sort of thing I'm looking for.

Appetite answered 5/11, 2009 at 19:19 Comment(0)
A
23

On freenode, sending a private message to nickserv with the message ACC <nickname> will return a number that indicates the user's ident status:

The answer is in the form <nickname> ACC <digit>:

 0 - account or user does not exist
 1 - account exists but user is not logged in
 2 - user is not logged in but recognized (see ACCESS)
 3 - user is logged in

The STATUS <nickname> command gives similar results on Rizon:

The response has this format:

<nickname> <digit>

 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

The advantages that this method has over a WHOIS:

  1. Information about ident status is always included. With WHOISes, you will just not get a line saying something along the lines of "identified with nickserv as such-and-such" if the user is not, in fact, idented.
  2. Consistent number of lines returned. Since I want to grab the message before passing on control to the rest of my program, I can easily read one line out of the buffer (I see synchronization issues in your future!), determine the status, and continue on like normal.
Appetite answered 14/11, 2009 at 11:18 Comment(2)
The outputs of the calls vary slightly between networks, for example, on Rizon, I get STATUS nick #, but on OFTC I get something like 1 (online, not identified). The most portable method I can think of is to try the ACC command first and scan the output for a number outside of the nick, if not try the STATUS command (on some ACC using servers STATUS is used for different purposes, so try it last), and use an exception list. The key: don't scan for a rigid format, rather build a flexible parser that scans for numbers. Also, not all networks have NickServ, so make a fallback.Choler
On certain networks the mode +r is given (as another answer mentioned). Figured it should be higher up here.Titlark
C
6

On some networks you can enable a feature called 'identify-msg'. On FreeNode you do it by sending "CAP REQ identify-msg" and "CAP END" when you first connect to the server. The server will respond with a reply confirming that feature. Afterwards, all messages (and CTCP ACTIONs) will be preceded with a "+" (user has identified with NickServ) or a "-" (user has not identified with NickServ), e.g.:

:[email protected] PRIVMSG #erasmus-testing :+foo

Czechoslovakia answered 27/4, 2011 at 23:23 Comment(0)
S
3

Nick registration is not part of the IRC standard. It is always offered by customized IRC servers and/or bots. I don't think you're going to find a truly universal solution, but NickServ is a common available implementation, which would work on many networks. Wikipedia has more info.

You may want to sidestep the problem entirely and have your user register with your bot, instead of with nickserv. Your bot would then do the password checking, and would invalidate the user's credentials when the user logs out. This would be a universal solution.

Spier answered 5/11, 2009 at 20:2 Comment(2)
I considered this for another feature, but the way I was implementing it in my head involved separate prompts for username and password, and risked delaying all functions unless I spun off another thread, which I really don't feel like doing atm. Now that it's not 2am :), the method you're suggesting is much more hopeful. While I'd rather not handle authentication, it seems likely that this will be what I end up doing.Appetite
It's a bit of a shame -- someone should create a new RFC to add these features in (just like they've updated FTP a couple of times)... Especially features that would support bots better (like standarizing ACC NickName or STATUS NickName on server with nickserv - if servers don't support user auth, they should create a "dummy" nickserv anyways, one without commands, just to keep people from using that name and scamming others with it).Risibility
B
1

As your username is registered, before your bot logs in, you do this command:

/ns ghost username password

This command will remove any user that is logged in on your user, remember that I only used this in Freenode, I don't know if it will function on another server.

Bout answered 5/11, 2009 at 19:24 Comment(1)
Both target networks support ghosting, yes, but I don't want my bot to ghost me! I'm trying to give my bot a way to recognize that I am truly who I claim I am, and avoid impersonations.Appetite
H
1

With Freenode, if a user is identified to NickServ then their user has the +e mode set. Not sure if Rizon has something similar.

Hazel answered 5/11, 2009 at 19:45 Comment(0)
G
1

UnrealIRCd and hybrd set +r to registered users, I'm not sure if all IRC servers do this though, it's pretty unstandardized. Also on Rizon you can whois and it will tell you if the user is registered.

Gomulka answered 5/11, 2009 at 20:9 Comment(0)
O
1

/NickServ INFO <username>

This will tell you whether the user is registered or not.

I discovered the command via this site: http://www.deepspace.org/nickserv.htm

Overwrought answered 31/1, 2019 at 12:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.