diff options
| author | Adam <Adam@anope.org> | 2013-07-01 22:17:52 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2013-07-01 22:17:52 -0400 |
| commit | 1a3d9a016d3adc49788bbff73aac9b3b5ea85b17 (patch) | |
| tree | c0ecf92ed768473bc82ff64a7fce827245f37ba9 /modules/pseudoclients | |
| parent | 518182ac9204f815258b0de91b3f884d8efa1502 (diff) | |
Change extensible keys to require explicitly having a type defined for it. Completely modularize more features like bs_kick, entrymsg, log, mode, etc. Move fantasy to its own module. Move greet to its own module.
Diffstat (limited to 'modules/pseudoclients')
| -rw-r--r-- | modules/pseudoclients/botserv.cpp | 138 | ||||
| -rw-r--r-- | modules/pseudoclients/chanserv.cpp | 104 | ||||
| -rw-r--r-- | modules/pseudoclients/nickserv.cpp | 126 |
3 files changed, 96 insertions, 272 deletions
diff --git a/modules/pseudoclients/botserv.cpp b/modules/pseudoclients/botserv.cpp index 8322ad3c3..e8452de13 100644 --- a/modules/pseudoclients/botserv.cpp +++ b/modules/pseudoclients/botserv.cpp @@ -14,9 +14,11 @@ class BotServCore : public Module { Reference<BotInfo> BotServ; + ExtensibleRef<bool> persist, inhabit; public: - BotServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) + BotServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR), + persist("persist"), inhabit("inhabit") { } @@ -54,121 +56,6 @@ class BotServCore : public Module } } - void OnPrivmsg(User *u, Channel *c, Anope::string &msg) anope_override - { - if (!u || !c || !c->ci || !c->ci->bi || msg.empty()) - return; - - /* Answer to ping if needed */ - if (msg.substr(0, 6).equals_ci("\1PING ") && msg[msg.length() - 1] == '\1') - { - Anope::string ctcp = msg; - ctcp.erase(ctcp.begin()); - ctcp.erase(ctcp.length() - 1); - IRCD->SendCTCP(c->ci->bi, u->nick, "%s", ctcp.c_str()); - } - - Anope::string realbuf = msg; - - if (realbuf.substr(0, 8).equals_ci("\1ACTION ") && realbuf[realbuf.length() - 1] == '\1') - { - realbuf.erase(0, 8); - realbuf.erase(realbuf.length() - 1); - return; - } - - if (realbuf.empty() || !c->ci->HasExt("BS_FANTASY")) - return; - - std::vector<Anope::string> params; - spacesepstream(realbuf).GetTokens(params); - - if (!realbuf.find(c->ci->bi->nick)) - params.erase(params.begin()); - else if (!realbuf.find_first_of(Config->GetModule(this)->Get<const Anope::string>("fantasycharacter", "!"))) - params[0].erase(params[0].begin()); - else - return; - - if (params.empty()) - return; - - CommandInfo::map::const_iterator it = Config->Fantasy.end(); - unsigned count = 0; - for (unsigned max = params.size(); it == Config->Fantasy.end() && max > 0; --max) - { - Anope::string full_command; - for (unsigned i = 0; i < max; ++i) - full_command += " " + params[i]; - full_command.erase(full_command.begin()); - - ++count; - it = Config->Fantasy.find(full_command); - } - - if (it == Config->Fantasy.end()) - return; - - const CommandInfo &info = it->second; - ServiceReference<Command> cmd("Command", info.name); - if (!cmd) - { - Log(LOG_DEBUG) << "Fantasy command " << it->first << " exists for nonexistant service " << info.name << "!"; - return; - } - - for (unsigned i = 0, j = params.size() - (count - 1); i < j; ++i) - params.erase(params.begin()); - - /* Some commands take the channel as a first parameter */ - if (info.prepend_channel) - params.insert(params.begin(), c->name); - - while (cmd->max_params > 0 && params.size() > cmd->max_params) - { - params[cmd->max_params - 1] += " " + params[cmd->max_params]; - params.erase(params.begin() + cmd->max_params); - } - - // Command requires registered users only - if (!cmd->AllowUnregistered() && !u->Account()) - return; - - if (params.size() < cmd->min_params) - return; - - CommandSource source(u->nick, u, u->Account(), u, c->ci->bi); - source.c = c; - source.command = it->first; - source.permission = info.permission; - - EventReturn MOD_RESULT; - if (c->ci->AccessFor(u).HasPriv("FANTASIA")) - { - FOREACH_RESULT(OnBotFantasy, MOD_RESULT, (source, cmd, c->ci, params)); - } - else - { - FOREACH_RESULT(OnBotNoFantasyAccess, MOD_RESULT, (source, cmd, c->ci, params)); - } - - if (MOD_RESULT == EVENT_STOP || !c->ci->AccessFor(u).HasPriv("FANTASIA")) - return; - - if (MOD_RESULT != EVENT_ALLOW && !info.permission.empty() && !source.HasCommand(info.permission)) - return; - - FOREACH_RESULT(OnPreCommand, MOD_RESULT, (source, cmd, params)); - if (MOD_RESULT == EVENT_STOP) - return; - - Reference<NickCore> nc_reference(u->Account()); - cmd->Execute(source, params); - if (!nc_reference) - source.nc = NULL; - FOREACH_MOD(OnPostCommand, (source, cmd, params)); - } - void OnJoinChannel(User *user, Channel *c) anope_override { if (!Config || !IRCD) @@ -221,22 +108,13 @@ class BotServCore : public Module ChannelStatus status(Config->GetModule(this)->Get<const Anope::string>("botmodes")); c->ci->bi->Join(c, &status); } - /* Only display the greet if the main uplink we're connected - * to has synced, or we'll get greet-floods when the net - * recovers from a netsplit. -GD - */ - if (c->FindUser(c->ci->bi) && c->ci->HasExt("BS_GREET") && user->Account() && !user->Account()->greet.empty() && c->ci->AccessFor(user).HasPriv("GREET") && user->server->IsSynced()) - { - IRCD->SendPrivmsg(c->ci->bi, c->name, "[%s] %s", user->Account()->display.c_str(), user->Account()->greet.c_str()); - c->ci->bi->lastmsg = Anope::CurTime; - } } } void OnLeaveChannel(User *u, Channel *c) anope_override { /* Channel is persistent, it shouldn't be deleted and the service bot should stay */ - if (c->ci && c->ci->HasExt("PERSIST")) + if (c->ci && persist && persist->Get(c->ci)) return; /* Channel is syncing from a netburst, don't destroy it as more users are probably wanting to join immediatly @@ -246,7 +124,7 @@ class BotServCore : public Module return; /* Additionally, do not delete this channel if ChanServ/a BotServ bot is inhabiting it */ - if (c->HasExt("INHABIT")) + if (inhabit && inhabit->Get(c)) return; /* This is called prior to removing the user from the channnel, so c->users.size() - 1 should be safe */ @@ -304,9 +182,9 @@ class BotServCore : public Module "one of the following characters: %s"), fantasycharacters.c_str()); } - EventReturn OnChannelModeSet(Channel *c, MessageSource &, const Anope::string &mname, const Anope::string ¶m) anope_override + EventReturn OnChannelModeSet(Channel *c, MessageSource &, ChannelMode *mode, const Anope::string ¶m) anope_override { - if (Config->GetModule(this)->Get<bool>("smartjoin") && mname == "BAN" && c->ci && c->ci->bi && c->FindUser(c->ci->bi)) + if (Config->GetModule(this)->Get<bool>("smartjoin") && mode->name == "BAN" && c->ci && c->ci->bi && c->FindUser(c->ci->bi)) { BotInfo *bi = c->ci->bi; @@ -323,7 +201,7 @@ class BotServCore : public Module /* Set default bot flags */ spacesepstream sep(Config->GetModule(this)->Get<const Anope::string>("defaults", "greet fantasy")); for (Anope::string token; sep.GetToken(token);) - ci->ExtendMetadata("BS_" + token.upper()); + ci->Extend<bool>("BS_" + token.upper()); } void OnUserKicked(MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) anope_override diff --git a/modules/pseudoclients/chanserv.cpp b/modules/pseudoclients/chanserv.cpp index a6871189c..2f7147cc6 100644 --- a/modules/pseudoclients/chanserv.cpp +++ b/modules/pseudoclients/chanserv.cpp @@ -10,15 +10,18 @@ */ #include "module.h" +#include "modules/cs_mode.h" class ChanServCore : public Module, public ChanServService { Reference<BotInfo> ChanServ; std::vector<Anope::string> defaults; + ExtensibleItem<bool> inhabit; + ExtensibleRef<bool> persist; public: ChanServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR), - ChanServService(this) + ChanServService(this), inhabit(this, "inhabit"), persist("PERSIST") { } @@ -30,17 +33,18 @@ class ChanServCore : public Module, public ChanServService class ChanServTimer : public Timer { Reference<BotInfo> &ChanServ; + ExtensibleItem<bool> &inhabit; Reference<Channel> c; public: /** Constructor * @param chan The channel */ - ChanServTimer(Reference<BotInfo> &cs, Module *m, Channel *chan) : Timer(m, Config->GetModule(m)->Get<time_t>("inhabit", "15s")), ChanServ(cs), c(chan) + ChanServTimer(Reference<BotInfo> &cs, ExtensibleItem<bool> &i, Module *m, Channel *chan) : Timer(m, Config->GetModule(m)->Get<time_t>("inhabit", "15s")), ChanServ(cs), inhabit(i), c(chan) { if (!ChanServ || !c) return; - c->Extend("INHABIT"); + inhabit.Set(c, true); if (!c->ci || !c->ci->bi) ChanServ->Join(c); else if (!c->FindUser(c->ci->bi)) @@ -61,7 +65,7 @@ class ChanServCore : public Module, public ChanServService if (!c) return; - c->Shrink("INHABIT"); + inhabit.Unset(c); if (!c->ci || !c->ci->bi) { @@ -73,10 +77,10 @@ class ChanServCore : public Module, public ChanServService } }; - if (c->HasExt("INHABIT")) + if (inhabit.HasExt(c)) return; - new ChanServTimer(ChanServ, this->owner, c); + new ChanServTimer(ChanServ, inhabit, this->owner, c); } void OnReload(Configuration::Conf *conf) anope_override @@ -96,7 +100,7 @@ class ChanServCore : public Module, public ChanServService if (defaults.empty()) { defaults.push_back("KEEPTOPIC"); - defaults.push_back("SECURE"); + defaults.push_back("CS_SECURE"); defaults.push_back("SECUREFOUNDER"); defaults.push_back("SIGNKICK"); } @@ -243,34 +247,9 @@ class ChanServCore : public Module, public ChanServService void OnCreateChan(ChannelInfo *ci) anope_override { - ci->bantype = Config->GetModule(this)->Get<int>("defbantype", "2"); - /* Set default chan flags */ for (unsigned i = 0; i < defaults.size(); ++i) - ci->ExtendMetadata(defaults[i].upper()); - - { - Anope::string modes; - spacesepstream sep(Config->GetModule(this)->Get<const Anope::string>("mlock", "+nrt")); - if (sep.GetToken(modes)) - { - bool add = true; - for (unsigned i = 0; i < modes.length(); ++i) - { - if (modes[i] == '+') - add = true; - else if (modes[i] == '-') - add = false; - else - { - ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[i]); - Anope::string param; - if (cm && (cm->type == MODE_REGULAR || sep.GetToken(param))) - ci->SetMLock(cm, add, param); - } - } - } - } + ci->Extend<bool>(defaults[i].upper()); } EventReturn OnCanSet(User *u, const ChannelMode *cm) anope_override @@ -283,21 +262,13 @@ class ChanServCore : public Module, public ChanServService void OnChannelSync(Channel *c) anope_override { - bool perm = c->HasMode("PERM") || (c->ci && c->ci->HasExt("PERSIST")); - if (!perm && !c->HasExt("BOTCHANNEL") && (c->users.empty() || (c->users.size() == 1 && c->users.begin()->second->user->server == Me))) + bool perm = c->HasMode("PERM") || (c->ci && persist && persist->Get(c->ci)); + if (!perm && !c->botchannel && (c->users.empty() || (c->users.size() == 1 && c->users.begin()->second->user->server == Me))) { this->Hold(c); } c->CheckModes(); - if (Me && Me->IsSynced() && c->ci) - { - /* Update channel topic */ - if ((c->ci->HasExt("KEEPTOPIC") || c->ci->HasExt("TOPICLOCK")) && c->ci->last_topic != c->topic) - { - c->ChangeTopic(!c->ci->last_topic_setter.empty() ? c->ci->last_topic_setter : c->ci->WhoSends()->nick, c->ci->last_topic, c->ci->last_topic_time ? c->ci->last_topic_time : Anope::CurTime); - } - } } EventReturn OnBotKick(BotInfo *bi, Channel *c, User *u, const Anope::string &reason) @@ -307,7 +278,7 @@ class ChanServCore : public Module, public ChanServService * ChanServ always enforces channels like this to keep people from deleting bots etc * that are holding channels. */ - if (c->ci && c->users.size() == (c->ci->bi && c->FindUser(c->ci->bi) ? 2 : 1) && !c->HasExt("INHABIT") && !c->syncing) + if (c->ci && c->users.size() == (c->ci->bi && c->FindUser(c->ci->bi) ? 2 : 1) && !inhabit.HasExt(c) && !c->syncing) { /* Join ChanServ and set a timer for this channel to part ChanServ later */ this->Hold(c); @@ -349,18 +320,11 @@ class ChanServCore : public Module, public ChanServService expire = true; } - if (ci->HasExt("NO_EXPIRE")) - expire = false; - FOREACH_MOD(OnPreChanExpire, (ci, expire)); if (expire) { - Anope::string extra; - if (ci->HasExt("SUSPENDED")) - extra = "suspended "; - - Log(LOG_NORMAL, "chanserv/expire") << "Expiring " << extra << "channel " << ci->name << " (founder: " << (ci->GetFounder() ? ci->GetFounder()->display : "(none)") << ")"; + Log(LOG_NORMAL, "chanserv/expire") << "Expiring channel " << ci->name << " (founder: " << (ci->GetFounder() ? ci->GetFounder()->display : "(none)") << ")"; FOREACH_MOD(OnChanExpire, (ci)); delete ci; } @@ -370,11 +334,11 @@ class ChanServCore : public Module, public ChanServService EventReturn OnCheckDelete(Channel *c) anope_override { /* Do not delete this channel if ChanServ/a BotServ bot is inhabiting it */ - if (c->HasExt("INHABIT")) + if (inhabit.HasExt(c)) return EVENT_STOP; /* Channel is persistent, it shouldn't be deleted and the service bot should stay */ - if (c->ci && c->ci->HasExt("PERSIST")) + if (c->ci && persist && persist->Get(c->ci)) return EVENT_STOP; return EVENT_CONTINUE; @@ -382,11 +346,13 @@ class ChanServCore : public Module, public ChanServService void OnPreUplinkSync(Server *serv) anope_override { + if (!persist) + return; /* Find all persistent channels and create them, as we are about to finish burst to our uplink */ for (registered_channel_map::iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it) { ChannelInfo *ci = it->second; - if (ci->HasExt("PERSIST")) + if (persist->Get(ci)) { bool created; ci->c = Channel::FindOrCreate(ci->name, created, ci->time_registered); @@ -414,35 +380,15 @@ class ChanServCore : public Module, public ChanServService void OnChanRegistered(ChannelInfo *ci) anope_override { + if (!persist) + return; /* Mark the channel as persistent */ if (ci->c->HasMode("PERM")) - ci->ExtendMetadata("PERSIST"); + persist->Unset(ci); /* Persist may be in def cflags, set it here */ - else if (ci->HasExt("PERSIST")) + else if (persist->Get(ci)) ci->c->SetMode(NULL, "PERM"); } - - void OnTopicUpdated(Channel *c, const Anope::string &user, const Anope::string &topic) anope_override - { - if (!c->ci) - return; - - /* We only compare the topics here, not the time or setter. This is because some (old) IRCds do not - * allow us to set the topic as someone else, meaning we have to bump the TS and change the setter to us. - * This desyncs what is really set with what we have stored, and we end up resetting the topic often when - * it is not required - */ - if (c->ci->HasExt("TOPICLOCK") && c->ci->last_topic != c->topic) - { - c->ChangeTopic(c->ci->last_topic_setter, c->ci->last_topic, c->ci->last_topic_time); - } - else - { - c->ci->last_topic = c->topic; - c->ci->last_topic_setter = c->topic_setter; - c->ci->last_topic_time = c->topic_ts; - } - } }; MODULE_INIT(ChanServCore) diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp index f306b1b51..6730e91b9 100644 --- a/modules/pseudoclients/nickserv.cpp +++ b/modules/pseudoclients/nickserv.cpp @@ -46,12 +46,13 @@ class NickServHeld : public Timer public: NickServHeld(NickAlias *n, long l) : Timer(l), na(n), nick(na->nick) { + n->Extend<bool>("HELD"); } void Tick(time_t) { if (na) - na->Shrink("HELD"); + na->Shrink<bool>("HELD"); } }; @@ -95,13 +96,13 @@ class NickServCore : public Module, public NickServService { Reference<BotInfo> NickServ; std::vector<Anope::string> defaults; + ExtensibleItem<bool> held, collided; void OnCancel(User *u, NickAlias *na) { - if (na->HasExt("COLLIDED")) + if (collided.HasExt(na)) { - na->Extend("HELD"); - na->Shrink("COLLIDED"); + collided.Unset(na); new NickServHeld(na, Config->GetBlock("options")->Get<time_t>("releasetimeout")); @@ -113,36 +114,48 @@ class NickServCore : public Module, public NickServService } public: - NickServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR), NickServService(this) + NickServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR), + NickServService(this), held(this, "HELD"), collided(this, "COLLIDED") { } + ~NickServCore() + { + OnShutdown(); + } + + void OnShutdown() anope_override + { + /* On shutdown, restart, or mod unload, remove all of our holds for nicks (svshold or qlines) + * because some IRCds do not allow us to have these automatically expire + */ + for (nickalias_map::const_iterator it = NickAliasList->begin(); it != NickAliasList->end(); ++it) + this->Release(it->second); + } + + void OnRestart() anope_override + { + OnShutdown(); + } + void Validate(User *u) anope_override { NickAlias *na = NickAlias::Find(u->nick); if (!na) return; - if (na->nc->HasExt("SUSPENDED")) + EventReturn MOD_RESULT; + FOREACH_RESULT(OnNickValidate, MOD_RESULT, (u, na)); + if (MOD_RESULT == EVENT_STOP) { - u->SendMessage(NickServ, NICK_X_SUSPENDED, u->nick.c_str()); this->Collide(u, na); return; } - if (!(u->Account() == na->nc) && !u->fingerprint.empty() && na->nc->FindCert(u->fingerprint)) - { - u->SendMessage(NickServ, _("SSL Fingerprint accepted, you are now identified.")); - Log(u) << "automatically identified for account " << na->nc->display << " using a valid SSL fingerprint."; - u->Identify(na); - return; - } - - if (!na->nc->HasExt("SECURE") && u->IsRecognized()) + if (!na->nc->HasExt("NS_SECURE") && u->IsRecognized()) { na->last_seen = Anope::CurTime; - Anope::string last_usermask = u->GetIdent() + "@" + u->GetDisplayedHost(); - na->last_usermask = last_usermask; + na->last_usermask = u->GetIdent() + "@" + u->GetDisplayedHost(); na->last_realname = u->realname; return; } @@ -150,15 +163,16 @@ class NickServCore : public Module, public NickServService if (Config->GetBlock("options")->Get<bool>("nonicknameownership")) return; - if (u->IsRecognized(false) || !na->nc->HasExt("KILL_IMMED")) + bool on_access = u->IsRecognized(false); + + if (on_access || !na->nc->HasExt("KILL_IMMED")) { - if (na->nc->HasExt("SECURE")) + if (na->nc->HasExt("NS_SECURE")) u->SendMessage(NickServ, NICK_IS_SECURE, Config->StrictPrivmsg.c_str(), NickServ->nick.c_str()); else u->SendMessage(NickServ, NICK_IS_REGISTERED, Config->StrictPrivmsg.c_str(), NickServ->nick.c_str()); } - - if (na->nc->HasExt("KILLPROTECT") && !u->IsRecognized(false)) + if (na->nc->HasExt("KILLPROTECT") && !on_access) { if (na->nc->HasExt("KILL_IMMED")) { @@ -184,14 +198,14 @@ class NickServCore : public Module, public NickServService void OnUserLogin(User *u) anope_override { NickAlias *na = NickAlias::Find(u->nick); - if (na && *na->nc == u->Account() && !Config->GetBlock("options")->Get<bool>("nonicknameownership") && na->nc->HasExt("UNCONFIRMED") == false) + if (na && *na->nc == u->Account() && !Config->GetBlock("options")->Get<bool>("nonicknameownership") && !na->nc->HasExt("UNCONFIRMED")) u->SetMode(NickServ, "REGISTERED"); } void Collide(User *u, NickAlias *na) anope_override { if (na) - na->Extend("COLLIDED"); + collided.Set(na); if (IRCD->CanSVSNick) { @@ -221,7 +235,7 @@ class NickServCore : public Module, public NickServService void Release(NickAlias *na) anope_override { - if (na->HasExt("HELD")) + if (held.HasExt(na)) { if (IRCD->CanSVSHold) IRCD->SendSVSHoldDel(na->nick); @@ -234,7 +248,7 @@ class NickServCore : public Module, public NickServService } } - na->Shrink("HELD"); + held.Unset(na); } } @@ -251,10 +265,10 @@ class NickServCore : public Module, public NickServService NickServ = bi; - spacesepstream(conf->GetModule(this)->Get<const Anope::string>("defaults", "secure memo_signon memo_receive")).GetTokens(defaults); + spacesepstream(conf->GetModule(this)->Get<const Anope::string>("defaults", "ns_secure memo_signon memo_receive")).GetTokens(defaults); if (defaults.empty()) { - defaults.push_back("SECURE"); + defaults.push_back("NS_SECURE"); defaults.push_back("MEMO_SIGNON"); defaults.push_back("MEMO_RECEIVE"); } @@ -296,14 +310,8 @@ class NickServCore : public Module, public NickServService { Configuration::Block *block = Config->GetModule(this); - if (!Config->GetBlock("options")->Get<bool>("nonicknameownership")) - { - const NickAlias *this_na = NickAlias::Find(u->nick); - if (this_na && this_na->nc == u->Account() && u->Account()->HasExt("UNCONFIRMED") == false) - u->SetMode(NickServ, "REGISTERED"); - } - if (block->Get<bool>("modeonid", "yes")) + for (User::ChanUserList::iterator it = u->chans.begin(), it_end = u->chans.end(); it != it_end; ++it) { ChanUserContainer *cc = it->second; @@ -325,25 +333,11 @@ class NickServCore : public Module, public NickServService "Your privacy is respected; this e-mail won't be given to\n" "any third-party person."), Config->StrictPrivmsg.c_str(), NickServ->nick.c_str()); } - - if (u->Account()->HasExt("UNCONFIRMED")) - { - const Anope::string &nsregister = Config->GetModule("ns_register")->Get<const Anope::string>("registration"); - if (nsregister.equals_ci("admin"))
- u->SendMessage(NickServ, _("All new accounts must be validated by an administrator. Please wait for your registration to be confirmed."));
- else - u->SendMessage(NickServ, _("Your email address is not confirmed. To confirm it, follow the instructions that were emailed to you when you registered.")); - const NickAlias *this_na = NickAlias::Find(u->Account()->display); - time_t time_registered = Anope::CurTime - this_na->time_registered; - time_t unconfirmed_expire = Config->GetModule(this)->Get<time_t>("unconfirmedexpire", "1d"); - if (unconfirmed_expire > time_registered) - u->SendMessage(NickServ, _("Your account will expire, if not confirmed, in %s"), Anope::Duration(unconfirmed_expire - time_registered).c_str()); - } } void OnNickGroup(User *u, NickAlias *target) anope_override { - if (target->nc->HasExt("UNCONFIRMED") == false) + if (!target->nc->HasExt("UNCONFIRMED")) u->SetMode(NickServ, "REGISTERED"); } @@ -404,7 +398,7 @@ class NickServCore : public Module, public NickServService { /* Reset +r and re-send account (even though it really should be set at this point) */ IRCD->SendLogin(u); - if (!Config->GetBlock("options")->Get<bool>("nonicknameownership") && na->nc == u->Account() && na->nc->HasExt("UNCONFIRMED") == false) + if (!Config->GetBlock("options")->Get<bool>("nonicknameownership") && na->nc == u->Account() && !na->nc->HasExt("UNCONFIRMED")) u->SetMode(NickServ, "REGISTERED"); Log(NickServ) << u->GetMask() << " automatically identified for group " << u->Account()->display; } @@ -467,7 +461,7 @@ class NickServCore : public Module, public NickServService { /* Set default flags */ for (unsigned i = 0; i < defaults.size(); ++i) - nc->ExtendMetadata(defaults[i].upper()); + nc->Extend<bool>(defaults[i].upper()); } void OnUserQuit(User *u, const Anope::string &msg) @@ -489,7 +483,6 @@ class NickServCore : public Module, public NickServService if (Anope::NoExpire || Anope::ReadOnly) return; - time_t unconfirmed_expire = Config->GetModule(this)->Get<time_t>("unconfirmedexpire", "1d"); time_t nickserv_expire = Config->GetModule(this)->Get<time_t>("expire"); for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ) @@ -498,32 +491,39 @@ class NickServCore : public Module, public NickServService ++it; User *u = User::Find(na->nick); - if (u && (na->nc->HasExt("SECURE") ? u->IsIdentified(true) : u->IsRecognized())) + if (u && (na->nc->HasExt("NS_SECURE") ? u->IsIdentified(true) : u->IsRecognized())) na->last_seen = Anope::CurTime; bool expire = false; - if (na->nc->HasExt("UNCONFIRMED")) - if (unconfirmed_expire && Anope::CurTime - na->time_registered >= unconfirmed_expire) - expire = true; if (nickserv_expire && Anope::CurTime - na->last_seen >= nickserv_expire) expire = true; - if (na->HasExt("NO_EXPIRE")) - expire = false; FOREACH_MOD(OnPreNickExpire, (na, expire)); if (expire) { - Anope::string extra; - if (na->nc->HasExt("SUSPENDED")) - extra = "suspended "; - Log(LOG_NORMAL, "expire") << "Expiring " << extra << "nickname " << na->nick << " (group: " << na->nc->display << ") (e-mail: " << (na->nc->email.empty() ? "none" : na->nc->email) << ")"; + Log(LOG_NORMAL, "expire") << "Expiring nickname " << na->nick << " (group: " << na->nc->display << ") (e-mail: " << (na->nc->email.empty() ? "none" : na->nc->email) << ")"; FOREACH_MOD(OnNickExpire, (na)); delete na; } } } + + void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) anope_override + { + if (!na->nc->HasExt("UNCONFIRMED")) + { + time_t nickserv_expire = Config->GetModule(this)->Get<time_t>("expire"); + if (!na->HasExt("NS_NO_EXPIRE") && nickserv_expire && !Anope::NoExpire) + info[_("Expires")] = Anope::strftime(na->last_seen + nickserv_expire); + } + else + { + time_t unconfirmed_expire = Config->GetModule(this)->Get<time_t>("unconfirmedexpire", "1d"); + info[_("Expires")] = Anope::strftime(na->time_registered + unconfirmed_expire); + } + } }; MODULE_INIT(NickServCore) |
