summaryrefslogtreecommitdiff
path: root/src/messages.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/messages.cpp')
-rw-r--r--src/messages.cpp72
1 files changed, 31 insertions, 41 deletions
diff --git a/src/messages.cpp b/src/messages.cpp
index 567a24b6a..ed601a206 100644
--- a/src/messages.cpp
+++ b/src/messages.cpp
@@ -49,6 +49,17 @@ void Error::Run(MessageSource &source, const std::vector<Anope::string> &params)
Anope::Quitting = true;
}
+void Invite::Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
+{
+ User *targ = User::Find(params[0]);
+ Channel *c = Channel::Find(params[1]);
+
+ if (!targ || targ->server != Me || !c || c->FindUser(targ))
+ return;
+
+ FOREACH_MOD(I_OnInvite, OnInvite(source.GetUser(), c, targ));
+}
+
void Join::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
User *user = source.GetUser();
@@ -64,7 +75,7 @@ void Join::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
for (User::ChanUserList::iterator it = user->chans.begin(), it_end = user->chans.end(); it != it_end; )
{
- ChanUserContainer *cc = *it++;
+ ChanUserContainer *cc = it->second++;
Anope::string channame = cc->chan->name;
FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, cc->chan));
@@ -84,14 +95,12 @@ void Join::Run(MessageSource &source, const std::vector<Anope::string> &params)
void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, const Anope::string &modes, const std::list<SJoinUser> &users)
{
- Channel *c = Channel::Find(chan);
+ bool created;
+ Channel *c = Channel::FindOrCreate(chan, created, ts ? ts : Anope::CurTime);
bool keep_their_modes = true;
- if (!c)
- {
- c = new Channel(chan, ts ? ts : Anope::CurTime);
+ if (created)
c->Extend("SYNCING");
- }
/* Some IRCds do not include a TS */
else if (!ts)
;
@@ -117,28 +126,20 @@ void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, co
const ChannelStatus &status = it->first;
User *u = it->second;
- EventReturn MOD_RESULT;
- FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c));
-
/* Add the user to the channel */
ChanUserContainer *cc = c->JoinUser(u);
/* Update their status internally on the channel */
- cc->status = status;
+ if (keep_their_modes)
+ cc->status = status;
/* Set whatever modes the user should have, and remove any that
* they aren't allowed to have (secureops etc).
*/
c->SetCorrectModes(u, true, true);
- /* Check to see if modules want the user to join, if they do
- * check to see if they are allowed to join (CheckKick will kick/ban them
- * if they aren't).
- */
- if (MOD_RESULT != EVENT_STOP && c->ci && c->ci->CheckKick(u))
- continue;
-
- FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c));
+ if (c->ci)
+ c->ci->CheckKick(u);
}
/* Channel is done syncing */
@@ -193,7 +194,7 @@ void Kill::Run(MessageSource &source, const std::vector<Anope::string> &params)
bi->introduced = true;
for (User::ChanUserList::const_iterator cit = bi->chans.begin(), cit_end = bi->chans.end(); cit != cit_end; ++cit)
- IRCD->SendJoin(bi, (*cit)->chan, &(*cit)->status);
+ IRCD->SendJoin(bi, cit->second->chan, &cit->second->status);
}
else
u->KillInternal(source.GetSource(), params[1]);
@@ -224,10 +225,10 @@ void MOTD::Run(MessageSource &source, const std::vector<Anope::string> &params)
if (s != Me)
return;
- FILE *f = fopen(Config->MOTDFilename.c_str(), "r");
+ FILE *f = fopen(Config->GetBlock("serverinfo")->Get<const Anope::string>("motd").c_str(), "r");
if (f)
{
- IRCD->SendNumeric(375, source.GetSource(), ":- %s Message of the Day", Config->ServerName.c_str());
+ IRCD->SendNumeric(375, source.GetSource(), ":- %s Message of the Day", s->GetName().c_str());
char buf[BUFSIZE];
while (fgets(buf, sizeof(buf), f))
{
@@ -294,16 +295,16 @@ void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> &param
{
Anope::string servername(receiver.begin() + s + 1, receiver.end());
botname = botname.substr(0, s);
- if (!servername.equals_ci(Config->ServerName))
+ if (!servername.equals_ci(Me->GetName()))
return;
}
- else if (Config->UseStrictPrivMsg)
+ else if (Config->GetBlock("options")->Get<bool>("usestrictprivmsg"))
{
const BotInfo *bi = BotInfo::Find(receiver);
if (!bi)
return;
Log(LOG_DEBUG) << "Ignored PRIVMSG without @ from " << u->nick;
- u->SendMessage(bi, _("\"/msg %s\" is no longer supported. Use \"/msg %s@%s\" or \"/%s\" instead."), bi->nick.c_str(), bi->nick.c_str(), Config->ServerName.c_str(), bi->nick.c_str());
+ u->SendMessage(bi, _("\"/msg %s\" is no longer supported. Use \"/msg %s@%s\" or \"/%s\" instead."), bi->nick.c_str(), bi->nick.c_str(), Me->GetName().c_str(), bi->nick.c_str());
return;
}
@@ -328,7 +329,7 @@ void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> &param
else if (message.substr(0, 9).equals_ci("\1VERSION\1"))
{
Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
- IRCD->SendCTCP(bi, u->nick, "VERSION Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "(none)", Anope::VersionBuildString().c_str());
+ IRCD->SendCTCP(bi, u->nick, "VERSION Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Me->GetName().c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "(none)", Anope::VersionBuildString().c_str());
}
return;
}
@@ -347,16 +348,7 @@ void Quit::Run(MessageSource &source, const std::vector<Anope::string> &params)
Log(user, "quit") << "quit (Reason: " << (!reason.empty() ? reason : "no reason") << ")";
- NickAlias *na = NickAlias::Find(user->nick);
- if (na && !na->nc->HasExt("SUSPENDED") && (user->IsRecognized() || user->IsIdentified(true)))
- {
- na->last_seen = Anope::CurTime;
- na->last_quit = reason;
- }
- FOREACH_MOD(I_OnUserQuit, OnUserQuit(user, reason));
user->Quit(reason);
-
- return;
}
void SQuit::Run(MessageSource &source, const std::vector<Anope::string> &params)
@@ -372,8 +364,6 @@ void SQuit::Run(MessageSource &source, const std::vector<Anope::string> &params)
FOREACH_MOD(I_OnServerQuit, OnServerQuit(s));
s->Delete(s->GetName() + " " + s->GetUplink()->GetName());
-
- return;
}
void Stats::Run(MessageSource &source, const std::vector<Anope::string> &params)
@@ -386,7 +376,7 @@ void Stats::Run(MessageSource &source, const std::vector<Anope::string> &params)
if (u->HasMode("OPER"))
{
IRCD->SendNumeric(211, source.GetSource(), "Server SendBuf SentBytes SentMsgs RecvBuf RecvBytes RecvMsgs ConnTime");
- IRCD->SendNumeric(211, source.GetSource(), "%s %d %d %d %d %d %d %ld", Config->Uplinks[Anope::CurrentUplink]->host.c_str(), UplinkSock->WriteBufferLen(), TotalWritten, -1, UplinkSock->ReadBufferLen(), TotalRead, -1, static_cast<long>(Anope::CurTime - Anope::StartTime));
+ IRCD->SendNumeric(211, source.GetSource(), "%s %d %d %d %d %d %d %ld", Config->Uplinks[Anope::CurrentUplink].host.c_str(), UplinkSock->WriteBufferLen(), TotalWritten, -1, UplinkSock->ReadBufferLen(), TotalRead, -1, static_cast<long>(Anope::CurTime - Anope::StartTime));
}
IRCD->SendNumeric(219, source.GetSource(), "%c :End of /STATS report.", params[0][0]);
@@ -394,7 +384,7 @@ void Stats::Run(MessageSource &source, const std::vector<Anope::string> &params)
case 'o':
case 'O':
/* Check whether the user is an operator */
- if (!u->HasMode("OPER") && Config->HideStatsO)
+ if (!u->HasMode("OPER") && Config->GetBlock("options")->Get<bool>("hidestatso"))
IRCD->SendNumeric(219, source.GetSource(), "%c :End of /STATS report.", params[0][0]);
else
{
@@ -434,7 +424,7 @@ void Time::Run(MessageSource &source, const std::vector<Anope::string> &params)
struct tm *tm = localtime(&t);
char buf[64];
strftime(buf, sizeof(buf), "%a %b %d %H:%M:%S %Y %Z", tm);
- IRCD->SendNumeric(391, source.GetSource(), "%s :%s", Config->ServerName.c_str(), buf);
+ IRCD->SendNumeric(391, source.GetSource(), "%s :%s", Me->GetName().c_str(), buf);
return;
}
@@ -450,7 +440,7 @@ void Topic::Run(MessageSource &source, const std::vector<Anope::string> &params)
void Version::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
- IRCD->SendNumeric(351, source.GetSource(), "Anope-%s %s :%s -(%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "(none)", Anope::VersionBuildString().c_str());
+ IRCD->SendNumeric(351, source.GetSource(), "Anope-%s %s :%s -(%s) -- %s", Anope::Version().c_str(), Me->GetName().c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "(none)", Anope::VersionBuildString().c_str());
return;
}
@@ -464,7 +454,7 @@ void Whois::Run(MessageSource &source, const std::vector<Anope::string> &params)
IRCD->SendNumeric(311, source.GetSource(), "%s %s %s * :%s", u->nick.c_str(), u->GetIdent().c_str(), u->host.c_str(), u->realname.c_str());
if (bi)
IRCD->SendNumeric(307, source.GetSource(), "%s :is a registered nick", bi->nick.c_str());
- IRCD->SendNumeric(312, source.GetSource(), "%s %s :%s", u->nick.c_str(), Config->ServerName.c_str(), Config->ServerDesc.c_str());
+ IRCD->SendNumeric(312, source.GetSource(), "%s %s :%s", u->nick.c_str(), Me->GetName().c_str(), Config->GetBlock("serverinfo")->Get<const Anope::string>("description").c_str());
if (bi)
IRCD->SendNumeric(317, source.GetSource(), "%s %ld %ld :seconds idle, signon time", bi->nick.c_str(), static_cast<long>(Anope::CurTime - bi->lastmsg), static_cast<long>(bi->signon));
IRCD->SendNumeric(318, source.GetSource(), "%s :End of /WHOIS list.", params[0].c_str());