summaryrefslogtreecommitdiff
path: root/modules/nickserv/status.cpp
blob: d31622d3d944ddaedfb9f4c6a78d0bfffeb8a60e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
 * Anope IRC Services
 *
 * Copyright (C) 2003-2016 Anope Team <team@anope.org>
 *
 * This file is part of Anope. Anope is free software; you can
 * redistribute it and/or modify it under the terms of the GNU
 * General Public License as published by the Free Software
 * Foundation, version 2.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see see <http://www.gnu.org/licenses/>.
 */

#include "module.h"

class CommandNSStatus : public Command
{
 public:
	CommandNSStatus(Module *creator) : Command(creator, "nickserv/status", 0, 16)
	{
		this->SetDesc(_("Returns the owner status of the given nickname"));
		this->SetSyntax(_("[\037nickname\037]"));
		this->AllowUnregistered(true);
	}

	void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
	{
		const Anope::string &nick = !params.empty() ? params[0] : source.GetNick();
		const NickServ::Nick *na = NickServ::FindNick(nick);
		spacesepstream sep(nick);
		Anope::string nickbuf;

#warning "this is all disabled"
		while (sep.GetToken(nickbuf))
		{
			#if 0
			User *u2 = User::Find(nickbuf, true);
			if (!u2) /* Nick is not online */
				source.Reply("STATUS %s %d %s", nickbuf.c_str(), 0, "");
			else if (u2->IsIdentified() && na && na->GetAccount() == u2->Account()) /* Nick is identified */
				source.Reply("STATUS %s %d %s", nickbuf.c_str(), 3, u2->Account()->GetDisplay().c_str());
			else if (u2->IsRecognized()) /* Nick is recognised, but NOT identified */
				source.Reply("STATUS %s %d %s", nickbuf.c_str(), 2, u2->Account() ? u2->Account()->GetDisplay().c_str() : "");
			else if (!na) /* Nick is online, but NOT a registered */
				source.Reply("STATUS %s %d %s", nickbuf.c_str(), 0, "");
			else
				/* Nick is not identified for the nick, but they could be logged into an account,
				 * so we tell the user about it
				 */
				source.Reply("STATUS %s %d %s", nickbuf.c_str(), 1, u2->Account() ? u2->Account()->GetDisplay().c_str() : "");
			#endif
		}
	}

	bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
	{
		this->SendSyntax(source);
		source.Reply(" ");
		source.Reply(_("Returns whether the user using the given nickname is\n"
				"recognized as the owner of the nickname. The response has\n"
				"this format:\n"
				" \n"
				"    \037nickname\037 \037status-code\037 \037account\037\n"
				" \n"
				"where \037nickname\037 is the nickname sent with the command,\n"
				"\037status-code\037 is one of the following, and \037account\037\n"
				"is the account they are logged in as.\n"
				" \n"
				"    0 - no such user online \002or\002 nickname not registered\n"
				"    1 - user not recognized as nickname's owner\n"
				"    2 - user recognized as owner via access list only\n"
				"    3 - user recognized as owner via password identification\n"
				" \n"
				"If no nickname is given, your status will be returned."));
		return true;
	}
};

class NSStatus : public Module
{
	CommandNSStatus commandnsstatus;

 public:
	NSStatus(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
		, commandnsstatus(this)
	{
	}
};

MODULE_INIT(NSStatus)