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; }
void OnFail(NickServ::IdentifyRequest *) override { if (!source.GetUser()) return; Log(LOG_COMMAND, source, cmd) << "and failed to group to " << target->GetNick(); source.Reply(_("Password incorrect.")); source.GetUser()->BadPassword(); }
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &nick = params[0]; const Anope::string &pass = params.size() > 1 ? params[1] : ""; User *user = User::Find(nick, true); if (user && source.GetUser() == user) { source.Reply(_("You can't %s yourself!"), source.command.lower().c_str()); return; } NickServ::Nick *na = NickServ::FindNick(nick); if (!na) { source.Reply(_("\002{0}\002 isn't registered."), nick); return; } if (na->GetAccount()->HasFieldS("NS_SUSPENDED")) { source.Reply(_("\002{0}\002 is suspended."), na->GetNick()); return; } bool ok = false; if (source.GetAccount() == na->GetAccount()) ok = true; else if (!na->GetAccount()->HasFieldS("NS_SECURE") && source.GetUser() && na->GetAccount()->IsOnAccess(source.GetUser())) ok = true; if (certservice && source.GetUser() && certservice->Matches(source.GetUser(), na->GetAccount())) ok = true; if (ok == false && !pass.empty()) { NickServ::IdentifyRequest *req = NickServ::service->CreateIdentifyRequest(new NSRecoverRequestListener(source, this, na->GetNick(), pass), owner, na->GetNick(), pass); Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, source.GetUser(), req); req->Dispatch(); } else { NSRecoverRequestListener req(source, this, na->GetNick(), pass); if (ok) req.OnSuccess(nullptr); else req.OnFail(nullptr); } }
void OnFail(NickServ::IdentifyRequest *) override { if (NickServ::FindNick(user) != NULL) { source.Reply(_("Access denied.")); if (!pass.empty()) { Log(LOG_COMMAND, source, cmd) << "with an invalid password for " << user; if (source.GetUser()) source.GetUser()->BadPassword(); } } else source.Reply(_("\002{0}\002 isn't registered."), user); }
void DoDel(CommandSource &source, NickServ::Account *nc, Anope::string certfp) { std::vector<NSCertEntry *> cl = nc->GetRefs<NSCertEntry *>(certentry); if (certfp.empty()) { User *u = source.GetUser(); if (u) certfp = u->fingerprint; } if (certfp.empty()) { this->OnSyntaxError(source, "DEL"); return; } NSCertEntry *cert = FindCert(cl, certfp); if (!cert) { source.Reply(_("\002{0}\002 not found on the certificate list of \002{1}\002."), certfp, nc->GetDisplay()); return; } cert->Delete(); Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to DELETE certificate fingerprint " << certfp << " from " << nc->GetDisplay(); source.Reply(_("\002{0}\002 deleted from the access list of \002{1}\002."), certfp, nc->GetDisplay()); }
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { User *u = source.GetUser(); Oper *o = source.nc->o; if (o == NULL) { source.Reply(_("No oper block for your nick.")); return; } if (o->GetPassword().empty()) { source.Reply(_("Your oper block doesn't require logging in.")); return; } if (!u->HasExtOK("os_login")) { source.Reply(_("You are not identified.")); return; } Log(LOG_ADMIN, source, this); u->ShrinkOK<bool>("os_login"); source.Reply(_("You have been logged out.")); }
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &password = params[0]; User *u = source.GetUser(); Oper *o = source.nc->o; if (o == NULL) { source.Reply(_("No oper block for your nickname.")); return; } if (o->GetPassword().empty()) { source.Reply(_("Your oper block doesn't require logging in.")); return; } if (u->HasExtOK("os_login")) { source.Reply(_("You are already logged in.")); return; } if (o->GetPassword() != password) { source.Reply(_("Password incorrect.")); u->BadPassword(); return; } Log(LOG_ADMIN, source, this) << "and successfully identified to " << source.service->nick; u->Extend<bool>("os_login", true); source.Reply(_("Password accepted.")); }
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &chan = params[0]; User *u = source.GetUser(); Channel *c = Channel::Find(chan); if (!c) { source.Reply(_("Channel \002{0}\002 doesn't exist."), chan); return; } ChanServ::Channel *ci = c->ci; if (!ci) { source.Reply(_("Channel \002{0}\002 isn't registered."), c->name); return; } if (!source.AccessFor(ci).HasPriv("INVITE") && !source.HasCommand("chanserv/invite")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "INVITE", ci->GetName()); return; } User *u2; if (params.size() == 1) u2 = u; else u2 = User::Find(params[1], true); if (!u2) { source.Reply(_("\002{0}\002 isn't currently online."), params.size() > 1 ? params[1] : source.GetNick()); return; } if (c->FindUser(u2)) { if (u2 == u) source.Reply(_("You are already in \002{0}\002!"), c->name); else source.Reply(_("\002{0}\002 is already in \002{1}\002!"), u2->nick, c->name); return; } bool override = !source.AccessFor(ci).HasPriv("INVITE"); IRCD->SendInvite(ci->WhoSends(), c, u2); if (u2 != u) { source.Reply(_("\002{0}\002 has been invited to \002{1}\002."), u2->nick, c->name); u2->SendMessage(ci->WhoSends(), _("You have been invited to \002{0}\002 by \002{1}\002."), c->name, source.GetNick()); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << u2->nick; }
EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) override { if (command->name == "nickserv/confirm" && params.size() > 1) { if (Anope::ReadOnly) { source.Reply(_("Services are in read-only mode.")); return EVENT_STOP; } NickServ::Nick *na = NickServ::FindNick(params[0]); ResetInfo *ri = na ? reset.Get(na->GetAccount()) : NULL; if (na && ri) { NickServ::Account *nc = na->GetAccount(); const Anope::string &passcode = params[1]; if (ri->time < Anope::CurTime - 3600) { reset.Unset(nc); source.Reply(_("Your password reset request has expired.")); } else if (passcode.equals_cs(ri->code)) { reset.Unset(nc); nc->UnsetS<bool>("UNCONFIRMED"); Log(LOG_COMMAND, source, &commandnsresetpass) << "confirmed RESETPASS to forcefully identify as " << na->GetNick(); if (source.GetUser()) { source.GetUser()->Identify(na); source.Reply(_("You are now identified for \002{0}\002. Change your password now."), na->GetAccount()->GetDisplay()); } } else return EVENT_CONTINUE; return EVENT_STOP; } } return EVENT_CONTINUE; }
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &chan = params[0]; const Anope::string &nick = params[1]; if (Anope::ReadOnly) { source.Reply(_("Sorry, bot assignment is temporarily disabled.")); return; } ChanServ::Channel *ci = ChanServ::Find(chan); if (ci == NULL) { source.Reply(_("Channel \002{0}\002 isn't registered."), chan); return; } ServiceBot *bi = ServiceBot::Find(nick, true); if (!bi) { source.Reply(_("Bot \002{0}\002 does not exist."), nick); return; } ChanServ::AccessGroup access = source.AccessFor(ci); if (!access.HasPriv("ASSIGN") && !source.HasPriv("botserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "ASSIGN", ci->GetName()); return; } if (ci->HasFieldS("BS_NOBOT")) { source.Reply(_("Access denied. \002{0}\002 may not have a bot assigned to it because a Services Operator has disallowed it."), ci->GetName()); return; } if (bi->bi->GetOperOnly() && !source.HasPriv("botserv/administration")) { source.Reply(_("Access denied. Bot \002{0}\002 is for operators only."), bi->nick); return; } if (ci->GetBot() == bi) { source.Reply(_("Bot \002{0}\002 is already assigned to \002{1}\002."), ci->GetBot()->nick, ci->GetName()); return; } bool override = !access.HasPriv("ASSIGN"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << bi->nick; bi->Assign(source.GetUser(), ci); source.Reply(_("Bot \002{0}\002 has been assigned to \002{1}\002."), bi->nick, ci->GetName()); }
void DoSetSuperAdmin(CommandSource &source, const std::vector<Anope::string> ¶ms) { const Anope::string &setting = params.size() > 1 ? params[1] : ""; if (!source.GetUser()) return; if (setting.empty()) { this->OnSyntaxError(source, "SUPERADMIN"); return; } /** * Allow the user to turn super admin on/off * * Rob **/ bool super_admin = Config->GetModule(this->GetOwner())->Get<bool>("superadmin"); if (!super_admin) { source.Reply(_("Super admin can not be set because it is not enabled in the configuration.")); return; } if (setting.equals_ci("ON")) { source.GetUser()->super_admin = true; source.Reply(_("You are now a super admin.")); Log(LOG_ADMIN, source, this) << "SUPERADMIN ON"; } else if (setting.equals_ci("OFF")) { source.GetUser()->super_admin = false; source.Reply(_("You are no longer a super admin.")); Log(LOG_ADMIN, source, this) << "SUPERADMIN OFF"; } else { source.Reply(_("Setting for super admin must be \002ON\002 or \002OFF\002.")); } }
void Command::Run(CommandSource &source, const Anope::string &cmdname, const CommandInfo &info, std::vector<Anope::string> ¶ms) { if (this->RequireUser() && !source.GetUser()) return; // Command requires registered users only if (!this->AllowUnregistered() && !source.nc) { source.Reply(NICK_IDENTIFY_REQUIRED); if (source.GetUser()) Log(LOG_NORMAL, "access_denied_unreg", source.service) << "Access denied for unregistered user " << source.GetUser()->GetMask() << " with command " << cmdname; return; } source.command = cmdname; source.permission = info.permission; EventReturn MOD_RESULT; FOREACH_RESULT(OnPreCommand, MOD_RESULT, (source, this, params)); if (MOD_RESULT == EVENT_STOP) return; if (params.size() < this->min_params) { this->OnSyntaxError(source, !params.empty() ? params[params.size() - 1] : ""); return; } // If the command requires a permission, and they aren't registered or don't have the required perm, DENIED if (!info.permission.empty() && !source.HasCommand(info.permission)) { source.Reply(ACCESS_DENIED); if (source.GetUser()) Log(LOG_NORMAL, "access_denied", source.service) << "Access denied for user " << source.GetUser()->GetMask() << " with command " << cmdname; return; } this->Execute(source, params); FOREACH_MOD(OnPostCommand, (source, this, params)); }
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &nick = !params.empty() ? params[0] : ""; const Anope::string ¶m = params.size() > 1 ? params[1] : ""; if (!source.IsServicesOper() && !nick.empty()) { this->OnSyntaxError(source); return; } User *u2 = !nick.empty() ? User::Find(nick, true) : source.GetUser(); if (!u2) { source.Reply(_("\002{0}\002 isn't currently online."), !nick.empty() ? nick : source.GetNick()); return; } if (!nick.empty() && u2->IsServicesOper()) { source.Reply(_("You can't logout \002{0}\002, they are a Services Operator."), nick); return; } #warning "revalidate" #if 0 if (!nick.empty() && !param.empty() && param.equals_ci("REVALIDATE") && NickServ::service) NickServ::service->Validate(u2); #endif u2->super_admin = false; /* Dont let people logout and remain a SuperAdmin */ // XXX show account name here? logger.Command(LogType::COMMAND, source, _("{source} used {command} to logout {0}"), u2->nick); if (!nick.empty()) source.Reply(_("\002{0}\002 has been logged out."), nick); else source.Reply(_("You have been logged out.")); IRCD->Send<messages::Logout>(u2); u2->RemoveMode(source.service, "REGISTERED"); u2->Logout(); /* Send out an event */ EventManager::Get()->Dispatch(&Event::NickLogout::OnNickLogout, u2); }
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { User *u = source.GetUser(); NickServ::Nick *na = NickServ::FindNick(u->nick); if (!na || !na->HasVhost() || na->GetAccount() != source.GetAccount()) { source.Reply(_("There is no vhost assigned to this nickname.")); return; } u->vhost.clear(); IRCD->SendVhostDel(u); Log(LOG_COMMAND, source, this) << "to disable their vhost"; source.Reply(_("Your vhost was removed and the normal cloaking restored.")); }
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) 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"); }
void DoAdd(CommandSource &source, NickServ::Account *nc, Anope::string certfp) { std::vector<NSCertEntry *> cl = nc->GetRefs<NSCertEntry *>(certentry); unsigned max = Config->GetModule(this->owner)->Get<unsigned>("max", "5"); if (cl.size() >= max) { source.Reply(_("Sorry, the maximum of \002{0}\002 certificate entries has been reached."), max); return; } if (source.GetAccount() == nc) { User *u = source.GetUser(); if (!u || u->fingerprint.empty()) { source.Reply(_("You are not using a client certificate.")); return; } certfp = u->fingerprint; } if (FindCert(cl, certfp)) { source.Reply(_("Fingerprint \002{0}\002 already present on the certificate list of \002{0}\002."), certfp, nc->GetDisplay()); return; } if (certmap.find(certfp) != certmap.end()) { source.Reply(_("Fingerprint \002{0}\002 is already in use."), certfp); return; } NSCertEntry *e = certentry.Create(); e->SetAccount(nc); e->SetCert(certfp); Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to ADD certificate fingerprint " << certfp << " to " << nc->GetDisplay(); source.Reply(_("\002{0}\002 added to the certificate list of \002{1}\002."), certfp, nc->GetDisplay()); }
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { NickServ::Nick *na = NickServ::FindNick(params[0]); if (!na) { source.Reply(_("\002{0}\002 isn't registered."), params[0]); return; } if (!na->GetAccount()->GetEmail().equals_ci(params[1])) { source.Reply(_("Incorrect email address.")); return; } if (SendResetEmail(source.GetUser(), na, source.service)) { Log(LOG_COMMAND, source, this) << "for " << na->GetNick() << " (group: " << na->GetAccount()->GetDisplay() << ")"; source.Reply(_("Password reset email for \002{0}\002 has been sent."), na->GetNick()); } }
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { ChannelMode *cm = ModeManager::FindChannelModeByName("BAN"); if (!cm) return; std::vector<ChannelMode *> modes = cm->listeners; modes.push_back(cm); if (params.empty()) { if (!source.GetUser()) return; unsigned count = 0; for (ChanServ::Channel *ci : source.GetAccount()->GetRefs<ChanServ::Channel *>()) { if (!ci->c || !source.AccessFor(ci).HasPriv("UNBAN")) continue; for (unsigned j = 0; j < modes.size(); ++j) if (ci->c->Unban(source.GetUser(), modes[j]->name, true)) ++count; } Log(LOG_COMMAND, source, this, NULL) << "on all channels"; source.Reply(_("You have been unbanned from %d channels."), count); return; } const Anope::string &chan = params[0]; ChanServ::Channel *ci = ChanServ::Find(chan); if (ci == NULL) { source.Reply(_("Channel \002{0}\002 isn't registered."), chan); return; } if (ci->c == NULL) { source.Reply(_("Channel \002{0}\002 doesn't exist."), ci->GetName()); return; } if (!source.AccessFor(ci).HasPriv("UNBAN") && !source.HasPriv("chanserv/kick")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "UNBAN", ci->GetName()); return; } User *u2 = source.GetUser(); if (params.size() > 1) u2 = User::Find(params[1], true); if (!u2) { if (params.size() > 1) source.Reply(_("User \002{0}\002 isn't currently online."), params[1]); return; } bool override = !source.AccessFor(ci).HasPriv("UNBAN") && source.HasPriv("chanserv/kick"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unban " << u2->nick; for (unsigned i = 0; i < modes.size(); ++i) ci->c->Unban(u2, modes[i]->name, source.GetUser() == u2); if (u2 == source.GetUser()) source.Reply(_("You have been unbanned from \002{0}\002."), ci->c->name); else source.Reply(_("\002{0}\002 has been unbanned from \002{1}\002."), u2->nick, ci->c->name); }
void OnSuccess(NickServ::IdentifyRequest *) override { User *u = User::Find(user, true); if (!source.GetUser() || !source.service) return; NickServ::Nick *na = NickServ::FindNick(user); if (!na) return; Log(LOG_COMMAND, source, cmd) << "for " << na->GetNick(); /* Nick is being held by us, release it */ if (na->HasFieldS("HELD")) { NickServ::service->Release(na); source.Reply(_("Service's hold on \002{0}\002 has been released."), na->GetNick()); } else if (!u) { source.Reply(_("No one is using your nick, and services are not holding it.")); } // If the user being recovered is identified for the account of the nick then the user is the // same person that is executing the command, so kill them off (old GHOST command). else if (u->Account() == na->GetAccount()) { if (!source.GetAccount() && na->GetAccount()->HasFieldS("NS_SECURE")) { source.GetUser()->Login(u->Account()); Log(LOG_COMMAND, source, cmd) << "and was automatically identified to " << u->Account()->GetDisplay(); } if (Config->GetModule("ns_recover")->Get<bool>("restoreonrecover")) { if (!u->chans.empty()) { NSRecoverInfo i; for (User::ChanUserList::iterator it = u->chans.begin(), it_end = u->chans.end(); it != it_end; ++it) i[it->first->name] = it->second->status; source.GetUser()->Extend<NSRecoverInfo>("recover", i); } } u->SendMessage(*source.service, _("This nickname has been recovered by \002{0}\002. If you did not do this, then \002{0}\002 may have your password, and you should change it."), source.GetNick()); Anope::string buf = source.command.upper() + " command used by " + source.GetNick(); u->Kill(*source.service, buf); source.Reply(_("Ghost with your nick has been killed.")); if (IRCD->CanSVSNick) IRCD->SendForceNickChange(source.GetUser(), user, Anope::CurTime); } /* User is not identified or not identified to the same account as the person using this command */ else { if (!source.GetAccount() && na->GetAccount()->HasFieldS("NS_SECURE")) { source.GetUser()->Login(na->GetAccount()); // Identify the user using the command if they arent identified Log(LOG_COMMAND, source, cmd) << "and was automatically identified to " << na->GetNick() << " (" << na->GetAccount()->GetDisplay() << ")"; } u->SendMessage(*source.service, _("This nickname has been recovered by \002{0}\002."), source.GetNick()); if (NickServ::service) NickServ::service->Collide(u, na); if (IRCD->CanSVSNick) { /* If we can svsnick then release our hold and svsnick the user using the command */ if (NickServ::service) NickServ::service->Release(na); IRCD->SendForceNickChange(source.GetUser(), user, Anope::CurTime); source.Reply(_("You have regained control of \002%s\002 and are now identified as \002%s\002."), user, na->GetAccount()->GetDisplay().c_str()); } else source.Reply(_("The user with your nick has been removed. Use this command again to release services's hold on your nick.")); } }
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { User *u = source.GetUser(); Anope::string nick; if (params.empty()) { NickServ::Account* core = u->Account(); if (core) nick = core->GetDisplay(); } else nick = params[0]; if (nick.empty()) { this->SendSyntax(source); return; } const Anope::string &pass = params.size() > 1 ? params[1] : ""; if (Anope::ReadOnly) { source.Reply(_("Sorry, nickname grouping is temporarily disabled.")); return; } if (!IRCD->IsNickValid(u->nick)) { source.Reply(_("\002{0}\002 may not be registered."), u->nick); return; } if (Config->GetModule("nickserv")->Get<bool>("restrictopernicks")) for (Oper *o : Serialize::GetObjects<Oper *>()) { if (!u->HasMode("OPER") && u->nick.find_ci(o->GetName()) != Anope::string::npos) { source.Reply(_("\002{0}\002 may not be registered because it is too similar to an operator nick."), u->nick); return; } } NickServ::Nick *target, *na = NickServ::FindNick(u->nick); const Anope::string &guestnick = Config->GetModule("nickserv")->Get<Anope::string>("guestnickprefix", "Guest"); time_t reg_delay = Config->GetModule("nickserv")->Get<time_t>("regdelay"); unsigned maxaliases = Config->GetModule(this->GetOwner())->Get<unsigned>("maxaliases"); if (!(target = NickServ::FindNick(nick))) { source.Reply(_("\002{0}\002 isn't registered."), nick); return; } if (Anope::CurTime < u->lastnickreg + reg_delay) { source.Reply(_("Please wait \002{0}\002 seconds before using the \002{1}\002 command again."), (reg_delay + u->lastnickreg) - Anope::CurTime, source.command); return; } if (target->GetAccount()->HasFieldS("NS_SUSPENDED")) { Log(LOG_COMMAND, source, this) << "and tried to group to suspended nick " << target->GetNick(); source.Reply(_("\002{0}\002 is suspended."), target->GetNick()); return; } if (na && Config->GetModule(this->GetOwner())->Get<bool>("nogroupchange")) { source.Reply(_("Your nick is already registered.")); return; } if (na && target->GetAccount() == na->GetAccount()) { source.Reply(_("You are already a member of the group of \002{0}\002."), target->GetNick()); return; } if (na && na->GetAccount() != u->Account()) { source.Reply(_("\002{0}\002 is already registered."), na->GetNick()); return; } if (na && Config->GetModule(this->GetOwner())->Get<bool>("nogroupchange")) { source.Reply(_("You are already registered.")); return; } if (maxaliases && target->GetAccount()->GetRefs<NickServ::Nick *>().size() >= maxaliases && !target->GetAccount()->IsServicesOper()) { source.Reply(_("There are too many nicknames in your group.")); return; } if (u->nick.length() <= guestnick.length() + 7 && u->nick.length() >= guestnick.length() + 1 && !u->nick.find_ci(guestnick) && !u->nick.substr(guestnick.length()).find_first_not_of("1234567890")) { source.Reply(_("\002{0}\002 may not be registered."), u->nick); return; } bool ok = false; if (!na && u->Account() == target->GetAccount()) ok = true; if (certservice && certservice->Matches(u, target->GetAccount())) ok = true; if (ok == false && !pass.empty()) { NickServ::IdentifyRequest *req = NickServ::service->CreateIdentifyRequest(new NSGroupRequestListener(source, this, u->nick, target), this->GetOwner(), target->GetAccount()->GetDisplay(), pass); EventManager::Get()->Dispatch(&Event::CheckAuthentication::OnCheckAuthentication, source.GetUser(), req); req->Dispatch(); } else { NSGroupRequestListener req(source, this, u->nick, target); if (ok) req.OnSuccess(nullptr); else req.OnFail(nullptr); } }
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (Anope::ReadOnly) { source.Reply(_("Services are in read-only mode.")); return; } User *u = source.GetUser(); NickServ::Nick *na = NickServ::FindNick(source.GetNick()); if (!na || na->GetAccount() != source.GetAccount()) { source.Reply(_("Access denied.")); //XXX with nonickownership this should be allowed. return; } if (source.GetAccount()->HasFieldS("UNCONFIRMED")) { source.Reply(_("You must confirm your account before you may request a vhost.")); return; } Anope::string rawhostmask = params[0]; Anope::string user, host; size_t a = rawhostmask.find('@'); if (a == Anope::string::npos) host = rawhostmask; else { user = rawhostmask.substr(0, a); host = rawhostmask.substr(a + 1); } if (host.empty()) { this->OnSyntaxError(source, ""); return; } if (!user.empty()) { if (user.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen")) { source.Reply(_("The username \002{0}\002 is too long, please use a username shorter than %d characters."), Config->GetBlock("networkinfo")->Get<unsigned>("userlen")); return; } if (!IRCD->CanSetVIdent) { source.Reply(_("Vhosts may not contain a username.")); return; } if (!IRCD->IsIdentValid(user)) { source.Reply(_("The requested username is not valid.")); return; } } if (host.length() > Config->GetBlock("networkinfo")->Get<unsigned>("hostlen")) { source.Reply(_("The requested vhost is too long, please use a hostname no longer than {0} characters."), Config->GetBlock("networkinfo")->Get<unsigned>("hostlen")); return; } if (!IRCD->IsHostValid(host)) { source.Reply(_("The requested hostname is not valid.")); return; } time_t send_delay = Config->GetModule("memoserv")->Get<time_t>("senddelay"); if (Config->GetModule(this->GetOwner())->Get<bool>("memooper") && send_delay > 0 && u && u->lastmemosend + send_delay > Anope::CurTime) { source.Reply(_("Please wait %d seconds before requesting a new vHost."), send_delay); u->lastmemosend = Anope::CurTime; return; } HostRequest *req = Serialize::New<HostRequest *>(); req->SetNick(na); req->SetIdent(user); req->SetHost(host); req->SetTime(Anope::CurTime); source.Reply(_("Your vhost has been requested.")); this->SendMemos(source, user, host); Log(LOG_COMMAND, source, this) << "to request new vhost " << (!user.empty() ? user + "@" : "") << host; }
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &chan = params[0]; User *u = source.GetUser(); Channel *c = Channel::Find(chan); if (!c) { source.Reply(_("Channel \002{0}\002 doesn't exist."), chan); return; } ChanServ::Channel *ci = c->GetChannel(); if (!ci) { source.Reply(_("Channel \002{0}\002 isn't registered."), c->name); return; } if (!source.AccessFor(ci).HasPriv("INVITE") && !source.HasOverrideCommand("chanserv/invite")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "INVITE", ci->GetName()); return; } User *u2; if (params.size() == 1) u2 = u; else u2 = User::Find(params[1], true); if (!u2) { source.Reply(_("\002{0}\002 isn't currently online."), params.size() > 1 ? params[1] : source.GetNick()); return; } if (c->FindUser(u2)) { if (u2 == u) source.Reply(_("You are already in \002{0}\002!"), c->name); else source.Reply(_("\002{0}\002 is already in \002{1}\002!"), u2->nick, c->name); return; } IRCD->Send<messages::Invite>(ci->WhoSends(), c, u2); if (u2 != u) { source.Reply(_("\002{0}\002 has been invited to \002{1}\002."), u2->nick, c->name); u2->SendMessage(ci->WhoSends(), _("You have been invited to \002{0}\002 by \002{1}\002."), c->name, source.GetNick()); logger.Command(source, ci, _("{source} used {command} on {channel} to invite {0}"), u2->nick); } else { u2->SendMessage(ci->WhoSends(), _("You have been invited to \002{0}\002."), c->name); logger.Command(source, ci, _("{source} used {command} on {channel}")); } }