예제 #1
0
파일: group.cpp 프로젝트: SaberUK/anope
	void OnSuccess(NickServ::IdentifyRequest *) override
	{
		if (!source.GetUser() || source.GetUser()->nick != nick || !target)
			return;

		User *u = source.GetUser();
		NickServ::Nick *na = NickServ::FindNick(nick);
		/* If the nick is already registered, drop it. */
		if (na)
		{
			EventManager::Get()->Dispatch(&Event::ChangeCoreDisplay::OnChangeCoreDisplay, na->GetAccount(), u->nick);
			delete na;
		}

		na = Serialize::New<NickServ::Nick *>();
		na->SetNick(nick);
		na->SetAccount(target->GetAccount());
		na->SetLastUsermask(u->GetIdent() + "@" + u->GetDisplayedHost());
		na->SetLastRealname(u->realname);
		na->SetLastSeen(Anope::CurTime);
		na->SetTimeRegistered(Anope::CurTime);

		u->Login(target->GetAccount());
		EventManager::Get()->Dispatch(&Event::NickGroup::OnNickGroup, u, target);

		Log(LOG_COMMAND, source, cmd) << "to make " << nick << " join group of " << target->GetNick() << " (" << target->GetAccount()->GetDisplay() << ") (email: " << (!target->GetAccount()->GetEmail().empty() ? target->GetAccount()->GetEmail() : "none") << ")";
		source.Reply(_("You are now in the group of \002{0}\002."), target->GetNick());

		u->lastnickreg = Anope::CurTime;

	}
예제 #2
0
파일: group.cpp 프로젝트: SaberUK/anope
	void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
	{
		User *u = source.GetUser();
		Anope::string nick = !params.empty() ? params[0] : "";
		NickServ::Nick *na = NickServ::FindNick(!nick.empty() ? nick : u->nick);

		if (u->Account()->GetRefs<NickServ::Nick *>().size() == 1)
		{
			source.Reply(_("Your nickname is not grouped to anything, so you can't ungroup it."));
			return;
		}

		if (!na)
		{
			source.Reply(_("\002{0}\002 isn't registered."), !nick.empty() ? nick : u->nick);
			return;
		}

		if (na->GetAccount() != u->Account())
		{
			source.Reply(_("\002{0}\002 is not in your group."), na->GetNick());
			return;
		}


		NickServ::Account *oldcore = na->GetAccount();

		if (na->GetNick().equals_ci(oldcore->GetDisplay()))
			oldcore->SetDisplay(oldcore->GetRef<NickServ::Nick *>());

		NickServ::Account *nc = Serialize::New<NickServ::Account *>();
		nc->SetDisplay(na->GetNick());
		na->SetAccount(nc);

		nc->SetPassword(oldcore->GetPassword());
		if (!oldcore->GetEmail().empty())
			nc->SetEmail(oldcore->GetEmail());
		nc->SetLanguage(oldcore->GetLanguage());

		source.Reply(_("\002{0}\002 has been ungrouped from \002{1}\002."), na->GetNick(), oldcore->GetDisplay());

		User *user = User::Find(na->GetNick());
		if (user)
			/* The user on the nick who was ungrouped may be identified to the old group, set -r */
			user->RemoveMode(source.service, "REGISTERED");
	}