// Anope IRC Services <https://www.anope.org/>
//
// Copyright (C) 2003-2026 Anope Contributors
//
// Anope is free software. You can use, modify, and/or distribute it under the
// terms of version 2 of the GNU General Public License. See docs/LICENSE.txt
// for the complete terms of this license and docs/AUTHORS.txt for a list of
// contributors.
//
// Based on the original code of Epona by Lara
// Based on the original code of Services by Andy Church
//
// SPDX-License-Identifier: GPL-2.0-only

#include "module.h"

class CommandNSUpdate final
	: public Command
{
public:
	CommandNSUpdate(Module *creator) : Command(creator, "nickserv/update", 0, 0)
	{
		this->SetDesc(_("Updates your current status, i.e. it checks for new memos"));
		this->RequireUser(true);
	}

	void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
	{
		User *u = source.GetUser();
		NickAlias *na = NickAlias::Find(u->nick);

		if (na && na->nc == source.GetAccount())
			na->last_seen = Anope::CurTime;

		FOREACH_MOD(OnNickUpdate, (u));

		source.Reply(_("Status updated (memos, vhost, chmodes, flags)."));
	}

	bool OnHelp(CommandSource &source, const Anope::string &) override
	{
		this->SendSyntax(source);
		source.Reply(" ");
		source.Reply(_(
			"Updates your current status, i.e. it checks for new memos, "
			"sets needed channel modes and updates your vhost and "
			"your userflags (lastseentime, etc)."
		));
		return true;
	}
};

class NSUpdate final
	: public Module
{
	CommandNSUpdate commandnsupdate;

public:
	NSUpdate(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
		commandnsupdate(this)
	{

	}
};

MODULE_INIT(NSUpdate)
