summaryrefslogtreecommitdiff
path: root/modules/pseudoclients
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-11-22 00:50:33 -0500
committerAdam <Adam@anope.org>2012-11-22 00:50:33 -0500
commitd33a0f75a5c0c584fbb7cc0076da36d494f39494 (patch)
tree7b2274cc833c793c0f5595660cbd4d715de52ffd /modules/pseudoclients
parent368d469631763e9c8bf399980d0ac7c5b5664d39 (diff)
Pretty large coding style cleanup, in source doc
cleanup, and allow protocol mods to depend on each other
Diffstat (limited to 'modules/pseudoclients')
-rw-r--r--modules/pseudoclients/botserv.cpp27
-rw-r--r--modules/pseudoclients/botserv.h6
-rw-r--r--modules/pseudoclients/chanserv.cpp18
-rw-r--r--modules/pseudoclients/chanserv.h6
-rw-r--r--modules/pseudoclients/global.cpp10
-rw-r--r--modules/pseudoclients/global.h3
-rw-r--r--modules/pseudoclients/hostserv.cpp23
-rw-r--r--modules/pseudoclients/hostserv.h6
-rw-r--r--modules/pseudoclients/memoserv.cpp38
-rw-r--r--modules/pseudoclients/memoserv.h3
-rw-r--r--modules/pseudoclients/nickserv.cpp76
-rw-r--r--modules/pseudoclients/nickserv.h3
-rw-r--r--modules/pseudoclients/operserv.cpp43
-rw-r--r--modules/pseudoclients/operserv.h6
14 files changed, 143 insertions, 125 deletions
diff --git a/modules/pseudoclients/botserv.cpp b/modules/pseudoclients/botserv.cpp
index e653e7d3e..f78d0a6de 100644
--- a/modules/pseudoclients/botserv.cpp
+++ b/modules/pseudoclients/botserv.cpp
@@ -20,8 +20,8 @@ class BotServCore : public Module
{
this->SetAuthor("Anope");
- const BotInfo *BotServ = findbot(Config->BotServ);
- if (BotServ == NULL)
+ BotServ = BotInfo::Find(Config->BotServ);
+ if (!BotServ)
throw ModuleException("No bot named " + Config->BotServ);
Implementation i[] = { I_OnPrivmsg, I_OnJoinChannel, I_OnLeaveChannel,
@@ -41,7 +41,7 @@ class BotServCore : public Module
Anope::string ctcp = msg;
ctcp.erase(ctcp.begin());
ctcp.erase(ctcp.length() - 1);
- ircdproto->SendCTCP(c->ci->bi, u->nick, "%s", ctcp.c_str());
+ IRCD->SendCTCP(c->ci->bi, u->nick, "%s", ctcp.c_str());
}
Anope::string realbuf = msg;
@@ -56,7 +56,8 @@ class BotServCore : public Module
if (realbuf.empty() || !c->ci->botflags.HasFlag(BS_FANTASY))
return;
- std::vector<Anope::string> params = BuildStringVector(realbuf);
+ std::vector<Anope::string> params;
+ spacesepstream(realbuf).GetTokens(params);
if (!realbuf.find(c->ci->bi->nick))
params.erase(params.begin());
@@ -87,7 +88,7 @@ class BotServCore : public Module
return;
const CommandInfo &info = it->second;
- service_reference<Command> cmd("Command", info.name);
+ ServiceReference<Command> cmd("Command", info.name);
if (!cmd)
{
Log(LOG_DEBUG) << "Fantasy command " << it->first << " exists for nonexistant service " << info.name << "!";
@@ -97,10 +98,10 @@ class BotServCore : public Module
for (unsigned i = 0, j = params.size() - (count - 1); i < j; ++i)
params.erase(params.begin());
- while (cmd->MaxParams > 0 && params.size() > cmd->MaxParams)
+ while (cmd->max_params > 0 && params.size() > cmd->max_params)
{
- params[cmd->MaxParams - 1] += " " + params[cmd->MaxParams];
- params.erase(params.begin() + cmd->MaxParams);
+ params[cmd->max_params - 1] += " " + params[cmd->max_params];
+ params.erase(params.begin() + cmd->max_params);
}
/* All ChanServ commands take the channel as a first parameter */
@@ -111,7 +112,7 @@ class BotServCore : public Module
if (!cmd->HasFlag(CFLAG_ALLOW_UNREGISTERED) && !u->Account())
return;
- if (params.size() < cmd->MinParams)
+ if (params.size() < cmd->min_params)
return;
CommandSource source(u->nick, u, u->Account(), u, c->ci->bi);
@@ -139,8 +140,8 @@ class BotServCore : public Module
if (MOD_RESULT == EVENT_STOP)
return;
- dynamic_reference<User> user_reference(u);
- dynamic_reference<NickCore> nc_reference(u->Account());
+ Reference<User> user_reference(u);
+ Reference<NickCore> nc_reference(u->Account());
cmd->Execute(source, params);
if (user_reference && nc_reference)
@@ -160,14 +161,14 @@ class BotServCore : public Module
* legit users - Rob
**/
if (c->users.size() >= Config->BSMinUsers && !c->FindUser(c->ci->bi))
- c->ci->bi->Join(c, &Config->BotModeList);
+ c->ci->bi->Join(c, &ModeManager::DefaultBotModes);
/* 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->botflags.HasFlag(BS_GREET) && user->Account() && !user->Account()->greet.empty() && c->ci->AccessFor(user).HasPriv("GREET") && user->server->IsSynced())
{
- ircdproto->SendPrivmsg(c->ci->bi, c->name, "[%s] %s", user->Account()->display.c_str(), user->Account()->greet.c_str());
+ 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;
}
}
diff --git a/modules/pseudoclients/botserv.h b/modules/pseudoclients/botserv.h
new file mode 100644
index 000000000..9757e5d4e
--- /dev/null
+++ b/modules/pseudoclients/botserv.h
@@ -0,0 +1,6 @@
+#ifndef BOTSERV_H
+#define BOTSERV_H
+
+static Reference<BotInfo> BotServ;
+
+#endif // BOTSERV_H
diff --git a/modules/pseudoclients/chanserv.cpp b/modules/pseudoclients/chanserv.cpp
index c3a6e6479..7a5b482bb 100644
--- a/modules/pseudoclients/chanserv.cpp
+++ b/modules/pseudoclients/chanserv.cpp
@@ -20,7 +20,7 @@ class ExpireCallback : public CallBack
void Tick(time_t) anope_override
{
- if (!Config->CSExpire || noexpire || readonly)
+ if (!Config->CSExpire || Anope::NoExpire || Anope::ReadOnly)
return;
for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; )
@@ -30,7 +30,7 @@ class ExpireCallback : public CallBack
bool expire = false;
- if (!ci->c && Config->CSExpire && Anope::CurTime - ci->last_used >= Config->CSExpire)
+ if (!ci->c && Anope::CurTime - ci->last_used >= Config->CSExpire)
expire = true;
if (ci->HasFlag(CI_NO_EXPIRE))
@@ -46,7 +46,7 @@ class ExpireCallback : public CallBack
Log(LOG_NORMAL, "chanserv/expire") << "Expiring " << extra << "channel " << ci->name << " (founder: " << (ci->GetFounder() ? ci->GetFounder()->display : "(none)") << ")";
FOREACH_MOD(I_OnChanExpire, OnChanExpire(ci));
- ci->destroy();
+ ci->Destroy();
}
}
}
@@ -61,8 +61,8 @@ class ChanServCore : public Module
{
this->SetAuthor("Anope");
- const BotInfo *ChanServ = findbot(Config->ChanServ);
- if (ChanServ == NULL)
+ ChanServ = BotInfo::Find(Config->ChanServ);
+ if (!ChanServ)
throw ModuleException("No bot named " + Config->ChanServ);
Implementation i[] = { I_OnBotPrivmsg, I_OnDelCore, I_OnPreHelp, I_OnPostHelp, I_OnCheckModes };
@@ -99,7 +99,7 @@ class ChanServCore : public Module
for (unsigned j = 0; j < ci->GetAccessCount(); ++j)
{
const ChanAccess *ca = ci->GetAccess(j);
- const NickCore *anc = findcore(ca->mask);
+ const NickCore *anc = NickCore::Find(ca->mask);
if (!anc || (!anc->IsServicesOper() && Config->CSMaxReg && anc->channelcount >= Config->CSMaxReg) || (anc == nc))
continue;
@@ -107,7 +107,7 @@ class ChanServCore : public Module
highest = ca;
}
if (highest)
- newowner = findcore(highest->mask);
+ newowner = NickCore::Find(highest->mask);
}
if (newowner)
@@ -120,7 +120,7 @@ class ChanServCore : public Module
{
Log(LOG_NORMAL, "chanserv/expire") << "Deleting channel " << ci->name << " owned by deleted nick " << nc->display;
- ci->destroy();
+ ci->Destroy();
continue;
}
}
@@ -131,7 +131,7 @@ class ChanServCore : public Module
for (unsigned j = 0; j < ci->GetAccessCount(); ++j)
{
const ChanAccess *ca = ci->GetAccess(j);
- const NickCore *anc = findcore(ca->mask);
+ const NickCore *anc = NickCore::Find(ca->mask);
if (anc && anc == nc)
{
diff --git a/modules/pseudoclients/chanserv.h b/modules/pseudoclients/chanserv.h
new file mode 100644
index 000000000..6c9ccd6c6
--- /dev/null
+++ b/modules/pseudoclients/chanserv.h
@@ -0,0 +1,6 @@
+#ifndef CHANSERV_H
+#define CHANSERV_H
+
+static Reference<BotInfo> ChanServ;
+
+#endif // CHANSERV_H
diff --git a/modules/pseudoclients/global.cpp b/modules/pseudoclients/global.cpp
index 13e7570ce..a5e1eb573 100644
--- a/modules/pseudoclients/global.cpp
+++ b/modules/pseudoclients/global.cpp
@@ -53,8 +53,8 @@ class GlobalCore : public Module
{
this->SetAuthor("Anope");
- const BotInfo *Global = findbot(Config->Global);
- if (Global == NULL)
+ Global = BotInfo::Find(Config->Global);
+ if (!Global)
throw ModuleException("No bot named " + Config->Global);
Implementation i[] = { I_OnRestart, I_OnShutdown, I_OnNewServer, I_OnPreHelp };
@@ -64,19 +64,19 @@ class GlobalCore : public Module
void OnRestart() anope_override
{
if (Config->GlobalOnCycle)
- global->SendGlobal(findbot(Config->Global), "", Config->GlobalOnCycleMessage);
+ GlobalService->SendGlobal(Global, "", Config->GlobalOnCycleMessage);
}
void OnShutdown() anope_override
{
if (Config->GlobalOnCycle)
- global->SendGlobal(findbot(Config->Global), "", Config->GlobalOnCycleMessage);
+ GlobalService->SendGlobal(Global, "", Config->GlobalOnCycleMessage);
}
void OnNewServer(Server *s) anope_override
{
if (Config->GlobalOnCycle && !Config->GlobalOnCycleUP.empty())
- s->Notice(findbot(Config->Global), Config->GlobalOnCycleUP);
+ s->Notice(Global, Config->GlobalOnCycleUP);
}
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
diff --git a/modules/pseudoclients/global.h b/modules/pseudoclients/global.h
index 75d783399..46bccef6d 100644
--- a/modules/pseudoclients/global.h
+++ b/modules/pseudoclients/global.h
@@ -14,7 +14,8 @@ class GlobalService : public Service
virtual void SendGlobal(const BotInfo *sender, const Anope::string &source, const Anope::string &message) = 0;
};
-static service_reference<GlobalService> global("GlobalService", "Global");
+static ServiceReference<GlobalService> GlobalService("GlobalService", "Global");
+static Reference<BotInfo> Global;
#endif // GLOBAL_H
diff --git a/modules/pseudoclients/hostserv.cpp b/modules/pseudoclients/hostserv.cpp
index d0d078a79..47c4250c0 100644
--- a/modules/pseudoclients/hostserv.cpp
+++ b/modules/pseudoclients/hostserv.cpp
@@ -20,11 +20,11 @@ class HostServCore : public Module
{
this->SetAuthor("Anope");
- if (!ircdproto || !ircdproto->CanSetVHost)
+ if (!IRCD || !IRCD->CanSetVHost)
throw ModuleException("Your IRCd does not support vhosts");
- const BotInfo *HostServ = findbot(Config->HostServ);
- if (HostServ == NULL)
+ HostServ = BotInfo::Find(Config->HostServ);
+ if (!HostServ)
throw ModuleException("No bot named " + Config->HostServ);
Implementation i[] = { I_OnNickIdentify, I_OnNickUpdate, I_OnPreHelp };
@@ -33,29 +33,28 @@ class HostServCore : public Module
void OnNickIdentify(User *u) anope_override
{
- const NickAlias *na = findnick(u->nick);
+ const NickAlias *na = NickAlias::Find(u->nick);
if (!na || !na->HasVhost())
- na = findnick(u->Account()->display);
- if (!ircdproto->CanSetVHost || !na || !na->HasVhost())
+ na = NickAlias::Find(u->Account()->display);
+ if (!IRCD->CanSetVHost || !na || !na->HasVhost())
return;
if (u->vhost.empty() || !u->vhost.equals_cs(na->GetVhostHost()) || (!na->GetVhostIdent().empty() && !u->GetVIdent().equals_cs(na->GetVhostIdent())))
{
- ircdproto->SendVhost(u, na->GetVhostIdent(), na->GetVhostHost());
+ IRCD->SendVhost(u, na->GetVhostIdent(), na->GetVhostHost());
u->vhost = na->GetVhostHost();
u->UpdateHost();
- if (ircdproto->CanSetVIdent && !na->GetVhostIdent().empty())
+ if (IRCD->CanSetVIdent && !na->GetVhostIdent().empty())
u->SetVIdent(na->GetVhostIdent());
- const BotInfo *bi = findbot(Config->HostServ);
- if (bi)
+ if (HostServ)
{
if (!na->GetVhostIdent().empty())
- u->SendMessage(bi, _("Your vhost of \002%s\002@\002%s\002 is now activated."), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str());
+ u->SendMessage(HostServ, _("Your vhost of \002%s\002@\002%s\002 is now activated."), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str());
else
- u->SendMessage(bi, _("Your vhost of \002%s\002 is now activated."), na->GetVhostHost().c_str());
+ u->SendMessage(HostServ, _("Your vhost of \002%s\002 is now activated."), na->GetVhostHost().c_str());
}
}
}
diff --git a/modules/pseudoclients/hostserv.h b/modules/pseudoclients/hostserv.h
new file mode 100644
index 000000000..039e711c3
--- /dev/null
+++ b/modules/pseudoclients/hostserv.h
@@ -0,0 +1,6 @@
+#ifndef HOSTSERV_H
+#define HOSTSERV_H
+
+static Reference<BotInfo> HostServ;
+
+#endif // HOSTSERV_H
diff --git a/modules/pseudoclients/memoserv.cpp b/modules/pseudoclients/memoserv.cpp
index 9cfca1af3..ee9c127f9 100644
--- a/modules/pseudoclients/memoserv.cpp
+++ b/modules/pseudoclients/memoserv.cpp
@@ -16,8 +16,8 @@
static bool SendMemoMail(NickCore *nc, MemoInfo *mi, Memo *m)
{
- Anope::string subject = translate(nc, Config->MailMemoSubject.c_str());
- Anope::string message = translate(nc, Config->MailMemoMessage.c_str());
+ Anope::string subject = Language::Translate(nc, Config->MailMemoSubject.c_str());
+ Anope::string message = Language::Translate(nc, Config->MailMemoMessage.c_str());
subject = subject.replace_all_cs("%n", nc->display);
subject = subject.replace_all_cs("%s", m->sender);
@@ -29,7 +29,7 @@ static bool SendMemoMail(NickCore *nc, MemoInfo *mi, Memo *m)
message = message.replace_all_cs("%d", mi->GetIndex(m));
message = message.replace_all_cs("%t", m->text);
- return Mail(nc, subject, message);
+ return Mail::Send(nc, subject, message);
}
class MyMemoServService : public MemoServService
@@ -42,14 +42,14 @@ class MyMemoServService : public MemoServService
if (!target.empty() && target[0] == '#')
{
ischan = true;
- ChannelInfo *ci = cs_findchan(target);
+ ChannelInfo *ci = ChannelInfo::Find(target);
if (ci != NULL)
return &ci->memos;
}
else
{
ischan = false;
- NickAlias *na = findnick(target);
+ NickAlias *na = NickAlias::Find(target);
if (na != NULL)
return &na->nc->memos;
}
@@ -65,7 +65,7 @@ class MyMemoServService : public MemoServService
if (mi == NULL)
return MEMO_INVALID_TARGET;
- User *sender = finduser(source);
+ User *sender = User::Find(source);
if (sender != NULL && !sender->HasPriv("memoserv/no-limit") && !force)
{
if (Config->MSSendDelay > 0 && sender->lastmemosend + Config->MSSendDelay > Anope::CurTime)
@@ -93,7 +93,7 @@ class MyMemoServService : public MemoServService
if (ischan)
{
- ChannelInfo *ci = cs_findchan(target);
+ ChannelInfo *ci = ChannelInfo::Find(target);
if (ci->c)
{
@@ -104,25 +104,25 @@ class MyMemoServService : public MemoServService
if (ci->AccessFor(cu->user).HasPriv("MEMO"))
{
if (cu->user->Account() && cu->user->Account()->HasFlag(NI_MEMO_RECEIVE))
- cu->user->SendMessage(findbot(Config->MemoServ), MEMO_NEW_X_MEMO_ARRIVED, ci->name.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->MemoServ.c_str(), ci->name.c_str(), mi->memos->size());
+ cu->user->SendMessage(MemoServ, MEMO_NEW_X_MEMO_ARRIVED, ci->name.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->MemoServ.c_str(), ci->name.c_str(), mi->memos->size());
}
}
}
}
else
{
- NickCore *nc = findnick(target)->nc;
+ NickCore *nc = NickAlias::Find(target)->nc;
if (nc->HasFlag(NI_MEMO_RECEIVE))
{
- for (std::list<serialize_obj<NickAlias> >::const_iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end;)
+ for (std::list<Serialize::Reference<NickAlias> >::const_iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end;)
{
const NickAlias *na = *it++;
if (!na)
continue;
- User *user = finduser(na->nick);
+ User *user = User::Find(na->nick);
if (user && user->IsIdentified())
- user->SendMessage(findbot(Config->MemoServ), MEMO_NEW_MEMO_ARRIVED, source.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->MemoServ.c_str(), mi->memos->size());
+ user->SendMessage(MemoServ, MEMO_NEW_MEMO_ARRIVED, source.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->MemoServ.c_str(), mi->memos->size());
}
}
@@ -139,20 +139,19 @@ class MyMemoServService : public MemoServService
const NickCore *nc = u->Account();
if (!nc)
return;
- const BotInfo *ms = findbot(Config->MemoServ);
unsigned i = 0, end = nc->memos.memos->size(), newcnt = 0;
for (; i < end; ++i)
if (nc->memos.GetMemo(i)->HasFlag(MF_UNREAD))
++newcnt;
if (newcnt > 0)
- u->SendMessage(ms, newcnt == 1 ? _("You have 1 new memo.") : _("You have %d new memos."), newcnt);
+ u->SendMessage(MemoServ, newcnt == 1 ? _("You have 1 new memo.") : _("You have %d new memos."), newcnt);
if (nc->memos.memomax > 0 && nc->memos.memos->size() >= static_cast<unsigned>(nc->memos.memomax))
{
if (nc->memos.memos->size() > static_cast<unsigned>(nc->memos.memomax))
- u->SendMessage(ms, _("You are over your maximum number of memos (%d). You will be unable to receive any new memos until you delete some of your current ones."), nc->memos.memomax);
+ u->SendMessage(MemoServ, _("You are over your maximum number of memos (%d). You will be unable to receive any new memos until you delete some of your current ones."), nc->memos.memomax);
else
- u->SendMessage(ms, _("You have reached your maximum number of memos (%d). You will be unable to receive any new memos until you delete some of your current ones."), nc->memos.memomax);
+ u->SendMessage(MemoServ, _("You have reached your maximum number of memos (%d). You will be unable to receive any new memos until you delete some of your current ones."), nc->memos.memomax);
}
}
};
@@ -166,7 +165,8 @@ class MemoServCore : public Module
{
this->SetAuthor("Anope");
- if (!findbot(Config->MemoServ))
+ MemoServ = BotInfo::Find(Config->MemoServ);
+ if (!MemoServ)
throw ModuleException("No bot named " + Config->MemoServ);
Implementation i[] = { I_OnNickIdentify, I_OnJoinChannel, I_OnUserAway, I_OnNickUpdate, I_OnPreHelp, I_OnPostHelp };
@@ -183,9 +183,9 @@ class MemoServCore : public Module
if (c->ci && c->ci->AccessFor(u).HasPriv("MEMO") && c->ci->memos.memos->size() > 0)
{
if (c->ci->memos.memos->size() == 1)
- u->SendMessage(findbot(Config->MemoServ), _("There is \002%d\002 memo on channel %s."), c->ci->memos.memos->size(), c->ci->name.c_str());
+ u->SendMessage(MemoServ, _("There is \002%d\002 memo on channel %s."), c->ci->memos.memos->size(), c->ci->name.c_str());
else
- u->SendMessage(findbot(Config->MemoServ), _("There are \002%d\002 memos on channel %s."), c->ci->memos.memos->size(), c->ci->name.c_str());
+ u->SendMessage(MemoServ, _("There are \002%d\002 memos on channel %s."), c->ci->memos.memos->size(), c->ci->name.c_str());
}
}
diff --git a/modules/pseudoclients/memoserv.h b/modules/pseudoclients/memoserv.h
index aae7d26b5..25d453ab0 100644
--- a/modules/pseudoclients/memoserv.h
+++ b/modules/pseudoclients/memoserv.h
@@ -35,7 +35,8 @@ class MemoServService : public Service
virtual void Check(User *u) = 0;
};
-static service_reference<MemoServService> memoserv("MemoServService", "MemoServ");
+static ServiceReference<MemoServService> MemoServService("MemoServService", "MemoServ");
+static Reference<BotInfo> MemoServ;
#endif // MEMOSERV_H
diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp
index 637003682..95044f610 100644
--- a/modules/pseudoclients/nickserv.cpp
+++ b/modules/pseudoclients/nickserv.cpp
@@ -15,23 +15,20 @@
#include "nickserv.h"
class NickServCollide;
-class NickServRelease;
typedef std::map<Anope::string, NickServCollide *> nickservcollides_map;
-typedef std::map<Anope::string, NickServRelease *> nickservreleases_map;
static nickservcollides_map NickServCollides;
-static nickservreleases_map NickServReleases;
/** Timer for colliding nicks to force people off of nicknames
*/
class NickServCollide : public Timer
{
- dynamic_reference<User> u;
+ Reference<User> u;
Anope::string nick;
public:
- /** Default constructor
+ /** Constructor
* @param nick The nick we're colliding
* @param delay How long to delay before kicking the user off the nick
*/
@@ -45,8 +42,6 @@ class NickServCollide : public Timer
NickServCollides.insert(std::make_pair(nick, this));
}
- /** Default destructor
- */
virtual ~NickServCollide()
{
NickServCollides.erase(this->nick);
@@ -60,7 +55,7 @@ class NickServCollide : public Timer
if (!u)
return;
/* If they identified or don't exist anymore, don't kill them. */
- NickAlias *na = findnick(u->nick);
+ NickAlias *na = NickAlias::Find(u->nick);
if (!na || u->Account() == na->nc || u->timestamp > this->GetSetTime())
return;
@@ -75,10 +70,9 @@ class MyNickServService : public NickServService
void Validate(User *u) anope_override
{
- NickAlias *na = findnick(u->nick);
+ NickAlias *na = NickAlias::Find(u->nick);
if (!na)
return;
- const BotInfo *NickServ = findbot(Config->NickServ);
if (na->nc->HasFlag(NI_SUSPENDED))
{
@@ -124,12 +118,12 @@ class MyNickServService : public NickServService
}
else if (na->nc->HasFlag(NI_KILL_QUICK))
{
- u->SendMessage(NickServ, _("If you do not change within %s, I will change your nick."), duration(Config->NSKillQuick, u->Account()).c_str());
+ u->SendMessage(NickServ, _("If you do not change within %s, I will change your nick."), Anope::Duration(Config->NSKillQuick, u->Account()).c_str());
new NickServCollide(u, Config->NSKillQuick);
}
else
{
- u->SendMessage(NickServ, _("If you do not change within %s, I will change your nick."), duration(Config->NSKill, u->Account()).c_str());
+ u->SendMessage(NickServ, _("If you do not change within %s, I will change your nick."), Anope::Duration(Config->NSKill, u->Account()).c_str());
new NickServCollide(u, Config->NSKill);
}
}
@@ -144,7 +138,7 @@ class ExpireCallback : public CallBack
void Tick(time_t) anope_override
{
- if (noexpire || readonly)
+ if (Anope::NoExpire || Anope::ReadOnly)
return;
for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; )
@@ -152,7 +146,7 @@ class ExpireCallback : public CallBack
NickAlias *na = it->second;
++it;
- User *u = finduser(na->nick);
+ User *u = User::Find(na->nick);
if (u && (na->nc->HasFlag(NI_SECURE) ? u->IsIdentified(true) : u->IsRecognized()))
na->last_seen = Anope::CurTime;
@@ -175,7 +169,7 @@ class ExpireCallback : public CallBack
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) << ")";
FOREACH_MOD(I_OnNickExpire, OnNickExpire(na));
- na->destroy();
+ na->Destroy();
}
}
}
@@ -191,7 +185,8 @@ class NickServCore : public Module
{
this->SetAuthor("Anope");
- if (!findbot(Config->NickServ))
+ NickServ = BotInfo::Find(Config->NickServ);
+ if (!NickServ)
throw ModuleException("No bot named " + Config->NickServ);
Implementation i[] = { I_OnDelNick, I_OnDelCore, I_OnChangeCoreDisplay, I_OnNickIdentify, I_OnNickGroup,
@@ -201,45 +196,41 @@ class NickServCore : public Module
void OnDelNick(NickAlias *na) anope_override
{
- User *u = finduser(na->nick);
+ User *u = User::Find(na->nick);
if (u && u->Account() == na->nc)
{
- ircdproto->SendLogout(u);
- u->RemoveMode(findbot(Config->NickServ), UMODE_REGISTERED);
+ IRCD->SendLogout(u);
+ u->RemoveMode(NickServ, UMODE_REGISTERED);
u->Logout();
}
}
void OnDelCore(NickCore *nc) anope_override
{
- Log(findbot(Config->NickServ), "nick") << "deleting nickname group " << nc->display;
+ Log(NickServ, "nick") << "deleting nickname group " << nc->display;
- /* Clean up this nick core from any users online using it
- * (ones that /nick but remain unidentified)
- */
- for (std::list<User *>::iterator it = nc->Users.begin(); it != nc->Users.end();)
+ /* Clean up this nick core from any users online */
+ for (std::list<User *>::iterator it = nc->users.begin(); it != nc->users.end();)
{
User *user = *it++;
- ircdproto->SendLogout(user);
- user->RemoveMode(findbot(Config->NickServ), UMODE_REGISTERED);
+ IRCD->SendLogout(user);
+ user->RemoveMode(NickServ, UMODE_REGISTERED);
user->Logout();
FOREACH_MOD(I_OnNickLogout, OnNickLogout(user));
}
- nc->Users.clear();
+ nc->users.clear();
}
void OnChangeCoreDisplay(NickCore *nc, const Anope::string &newdisplay) anope_override
{
- Log(LOG_NORMAL, "nick", findbot(Config->NickServ)) << "Changing " << nc->display << " nickname group display to " << newdisplay;
+ Log(LOG_NORMAL, "nick", NickServ) << "Changing " << nc->display << " nickname group display to " << newdisplay;
}
void OnNickIdentify(User *u) anope_override
{
- const BotInfo *NickServ = findbot(Config->NickServ);
-
if (!Config->NoNicknameOwnership)
{
- const NickAlias *this_na = findnick(u->nick);
+ const NickAlias *this_na = NickAlias::Find(u->nick);
if (this_na && this_na->nc == u->Account() && u->Account()->HasFlag(NI_UNCONFIRMED) == false)
u->SetMode(NickServ, UMODE_REGISTERED);
}
@@ -250,7 +241,7 @@ class NickServCore : public Module
ChannelContainer *cc = *it;
Channel *c = cc->chan;
if (c)
- chan_set_correct_modes(u, c, 1, true);
+ c->SetCorrectModes(u, true, true);
}
if (!Config->NSModesOnID.empty())
@@ -269,17 +260,17 @@ class NickServCore : public Module
if (u->Account()->HasFlag(NI_UNCONFIRMED))
{
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 = findnick(u->Account()->display);
+ const NickAlias *this_na = NickAlias::Find(u->Account()->display);
time_t time_registered = Anope::CurTime - this_na->time_registered;
if (Config->NSUnconfirmedExpire > time_registered)
- u->SendMessage(NickServ, _("Your account will expire, if not confirmed, in %s"), duration(Config->NSUnconfirmedExpire - time_registered).c_str());
+ u->SendMessage(NickServ, _("Your account will expire, if not confirmed, in %s"), Anope::Duration(Config->NSUnconfirmedExpire - time_registered).c_str());
}
}
void OnNickGroup(User *u, NickAlias *target) anope_override
{
if (target->nc->HasFlag(NI_UNCONFIRMED) == false)
- u->SetMode(findbot(Config->NickServ), UMODE_REGISTERED);
+ u->SetMode(NickServ, UMODE_REGISTERED);
}
void OnNickUpdate(User *u) anope_override
@@ -289,14 +280,13 @@ class NickServCore : public Module
ChannelContainer *cc = *it;
Channel *c = cc->chan;
if (c)
- chan_set_correct_modes(u, c, 1, false);
+ c->SetCorrectModes(u, true, true);
}
}
void OnUserNickChange(User *u, const Anope::string &oldnick) anope_override
{
- const NickAlias *na = findnick(u->nick);
- const BotInfo *NickServ = findbot(Config->NickServ);
+ const NickAlias *na = NickAlias::Find(u->nick);
/* If the new nick isnt registerd or its registerd and not yours */
if (!na || na->nc != u->Account())
{
@@ -308,7 +298,7 @@ class NickServCore : public Module
else
{
/* Reset +r and re-send account (even though it really should be set at this point) */
- ircdproto->SendLogin(u);
+ IRCD->SendLogin(u);
if (!Config->NoNicknameOwnership && na->nc == u->Account() && na->nc->HasFlag(NI_UNCONFIRMED) == false)
u->SetMode(NickServ, UMODE_REGISTERED);
Log(NickServ) << u->GetMask() << " automatically identified for group " << u->Account()->display;
@@ -318,7 +308,7 @@ class NickServCore : public Module
void OnUserModeSet(User *u, UserModeName Name) anope_override
{
if (Name == UMODE_REGISTERED && !u->IsIdentified())
- u->RemoveMode(findbot(Config->NickServ), Name);
+ u->RemoveMode(NickServ, Name);
}
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
@@ -357,10 +347,10 @@ class NickServCore : public Module
"nickname(s)."), Config->NickServ.c_str());
}
- void OnUserConnect(dynamic_reference<User> &u, bool &exempt) anope_override
+ void OnUserConnect(Reference<User> &u, bool &exempt) anope_override
{
- if (!Config->NoNicknameOwnership && !Config->NSUnregisteredNotice.empty() && u && !findnick(u->nick))
- u->SendMessage(findbot(Config->NickServ), Config->NSUnregisteredNotice);
+ if (!Config->NoNicknameOwnership && !Config->NSUnregisteredNotice.empty() && u && !NickAlias::Find(u->nick))
+ u->SendMessage(NickServ, Config->NSUnregisteredNotice);
}
};
diff --git a/modules/pseudoclients/nickserv.h b/modules/pseudoclients/nickserv.h
index 750b77784..52934fe96 100644
--- a/modules/pseudoclients/nickserv.h
+++ b/modules/pseudoclients/nickserv.h
@@ -9,7 +9,8 @@ class NickServService : public Service
virtual void Validate(User *u) = 0;
};
-static service_reference<NickServService> nickserv("NickServService", "NickServ");
+static ServiceReference<NickServService> NickServService("NickServService", "NickServ");
+static Reference<BotInfo> NickServ;
#endif // NICKSERV_H
diff --git a/modules/pseudoclients/operserv.cpp b/modules/pseudoclients/operserv.cpp
index cc051d685..8ee8c211b 100644
--- a/modules/pseudoclients/operserv.cpp
+++ b/modules/pseudoclients/operserv.cpp
@@ -25,28 +25,28 @@ class SGLineManager : public XLineManager
void OnExpire(const XLine *x) anope_override
{
- Log(findbot(Config->OperServ), "expire/akill") << "AKILL on \2" << x->Mask << "\2 has expired";
+ Log(OperServ, "expire/akill") << "AKILL on \2" << x->mask << "\2 has expired";
}
void Send(User *u, XLine *x) anope_override
{
- ircdproto->SendAkill(u, x);
+ IRCD->SendAkill(u, x);
}
void SendDel(XLine *x) anope_override
{
try
{
- if (!ircdproto->CanSZLine)
+ if (!IRCD->CanSZLine)
throw SocketException("SZLine is not supported");
else if (x->GetUser() != "*")
throw SocketException("Can not ZLine a username");
sockaddrs(x->GetHost());
- ircdproto->SendSZLineDel(x);
+ IRCD->SendSZLineDel(x);
}
catch (const SocketException &)
{
- ircdproto->SendAkillDel(x);
+ IRCD->SendAkillDel(x);
}
}
@@ -101,30 +101,30 @@ class SQLineManager : public XLineManager
void OnExpire(const XLine *x) anope_override
{
- Log(findbot(Config->OperServ), "expire/sqline") << "SQLINE on \2" << x->Mask << "\2 has expired";
+ Log(OperServ, "expire/sqline") << "SQLINE on \2" << x->mask << "\2 has expired";
}
void Send(User *u, XLine *x) anope_override
{
- ircdproto->SendSQLine(u, x);
+ IRCD->SendSQLine(u, x);
}
void SendDel(XLine *x) anope_override
{
- ircdproto->SendSQLineDel(x);
+ IRCD->SendSQLineDel(x);
}
bool Check(User *u, const XLine *x) anope_override
{
if (x->regex)
return x->regex->Matches(u->nick);
- return Anope::Match(u->nick, x->Mask);
+ return Anope::Match(u->nick, x->mask);
}
bool CheckChannel(Channel *c)
{
for (std::vector<XLine *>::const_iterator it = this->GetList().begin(), it_end = this->GetList().end(); it != it_end; ++it)
- if (Anope::Match(c->name, (*it)->Mask, false, true))
+ if (Anope::Match(c->name, (*it)->mask, false, true))
return true;
return false;
}
@@ -142,24 +142,24 @@ class SNLineManager : public XLineManager
void OnExpire(const XLine *x) anope_override
{
- Log(findbot(Con