summaryrefslogtreecommitdiff
path: root/src/users.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/users.cpp')
-rw-r--r--src/users.cpp315
1 files changed, 174 insertions, 141 deletions
diff --git a/src/users.cpp b/src/users.cpp
index 9ccfb1743..17f854ab6 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1,18 +1,25 @@
-/* Routines to maintain a list of online users.
+/*
+ * Anope IRC Services
*
- * (C) 2003-2017 Anope Team
- * Contact us at team@anope.org
+ * Copyright (C) 2003-2017 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
#include "services.h"
#include "modules.h"
#include "users.h"
-#include "account.h"
#include "protocol.h"
#include "servers.h"
#include "channels.h"
@@ -22,16 +29,18 @@
#include "language.h"
#include "sockets.h"
#include "uplink.h"
+#include "event.h"
+#include "messages.h"
+#include "modules/nickserv.h"
-user_map UserListByNick, UserListByUID;
+user_map UserListByNick;
+uid_map UserListByUID;
int OperCount = 0;
-unsigned MaxUserCount = 0;
-time_t MaxUserTime = 0;
std::list<User *> User::quitting_users;
-User::User(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &uip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const Anope::string &suid, NickCore *account) : ip(uip)
+User::User(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &uip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const Anope::string &suid, NickServ::Account *account) : ip(uip), logger(this)
{
if (snick.empty() || sident.empty() || shost.empty())
throw CoreException("Bad args passed to User::User");
@@ -53,14 +62,13 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope:
this->SetModesInternal(sserver, "%s", smodes.c_str());
this->uid = suid;
this->super_admin = false;
- this->nc = NULL;
size_t old = UserListByNick.size();
UserListByNick[snick] = this;
if (!suid.empty())
UserListByUID[suid] = this;
if (old == UserListByNick.size())
- Log(LOG_DEBUG) << "Duplicate user " << snick << " in user table?";
+ Anope::Logger.Debug("Duplicate user {0} in user table?", snick);
this->Login(account);
this->UpdateHost();
@@ -69,21 +77,13 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope:
{
++sserver->users;
if (server->IsSynced())
- Log(this, "connect") << (!vhost.empty() && vhost != host ? "(" + vhost + ") " : "") << "(" << srealname << ") " << (!uip.empty() && uip != host ? "[" + uip + "] " : "") << "connected to the network (" << sserver->GetName() << ")";
- }
-
- if (UserListByNick.size() > MaxUserCount)
- {
- MaxUserCount = UserListByNick.size();
- MaxUserTime = Anope::CurTime;
- if (sserver && sserver->IsSynced())
- Log(this, "maxusers") << "connected - new maximum user count: " << UserListByNick.size();
+ logger.Category("connect").Log(_("{0} ({1}) ({2}) [{3}] connected to the network ({4})"), this->GetMask(), vhost.empty() ? host : vhost, srealname, uip.empty() ? host : uip, sserver->GetName());
}
bool exempt = false;
if (server && server->IsULined())
exempt = true;
- FOREACH_MOD(OnUserConnect, (this, exempt));
+ EventManager::Get()->Dispatch(&Event::UserConnect::OnUserConnect, this, exempt);
}
static void CollideKill(User *target, const Anope::string &reason)
@@ -93,10 +93,10 @@ static void CollideKill(User *target, const Anope::string &reason)
else
{
// Be sure my user is really dead
- IRCD->SendQuit(target, "%s", reason.c_str());
+ IRCD->SendQuit(target, reason);
// Reintroduce my client
- if (BotInfo *bi = dynamic_cast<BotInfo *>(target))
+ if (ServiceBot *bi = dynamic_cast<ServiceBot *>(target))
bi->OnKill();
else
target->Quit(reason);
@@ -106,12 +106,12 @@ static void CollideKill(User *target, const Anope::string &reason)
static void Collide(User *u, const Anope::string &id, const Anope::string &type)
{
// Kill incoming user
- IRCD->SendKill(Me, id, type);
+ IRCD->Send<messages::Kill>(Me, id, Me->GetName() + " (" + type + ")");
// Quit colliding user
CollideKill(u, type);
}
-User* User::OnIntroduce(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &sip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const Anope::string &suid, NickCore *nc)
+User* User::OnIntroduce(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &sip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const Anope::string &suid, NickServ::Account *nc)
{
// How IRCds handle collisions varies a lot, for safety well just always kill both sides
// With properly set qlines, this can almost never happen anyway
@@ -143,7 +143,7 @@ void User::ChangeNick(const Anope::string &newnick, time_t ts)
throw CoreException("User::ChangeNick() got a bad argument");
this->super_admin = false;
- Log(this, "nick") << "(" << this->realname << ") changed nick to " << newnick;
+ logger.Category("nick").Log(_("{0} ({1}) changed nick to {2}"), this->GetMask(), this->realname, newnick);
Anope::string old = this->nick;
this->timestamp = ts;
@@ -152,9 +152,9 @@ void User::ChangeNick(const Anope::string &newnick, time_t ts)
this->nick = newnick;
else
{
- NickAlias *old_na = NickAlias::Find(this->nick);
+ NickServ::Nick *old_na = NickServ::FindNick(this->nick);
if (old_na && (this->IsIdentified(true) || this->IsRecognized()))
- old_na->last_seen = Anope::CurTime;
+ old_na->SetLastSeen(Anope::CurTime);
UserListByNick.erase(this->nick);
@@ -170,18 +170,23 @@ void User::ChangeNick(const Anope::string &newnick, time_t ts)
other = this;
on_access = false;
- NickAlias *na = NickAlias::Find(this->nick);
- if (na)
- on_access = na->nc->IsOnAccess(this);
-
- if (na && na->nc == this->Account())
+ if (NickServ::service)
{
- na->last_seen = Anope::CurTime;
- this->UpdateHost();
+ NickServ::Nick *na = NickServ::service->FindNick(this->nick);
+ if (na)
+ {
+ on_access = na->GetAccount()->IsOnAccess(this);
+
+ if (na->GetAccount() == this->Account())
+ {
+ na->SetLastSeen(Anope::CurTime);
+ this->UpdateHost();
+ }
+ }
}
}
- FOREACH_MOD(OnUserNickChange, (this, old));
+ EventManager::Get()->Dispatch(&Event::UserNickChange::OnUserNickChange, this, old);
}
void User::SetDisplayedHost(const Anope::string &shost)
@@ -191,9 +196,9 @@ void User::SetDisplayedHost(const Anope::string &shost)
this->vhost = shost;
- Log(this, "host") << "changed vhost to " << shost;
+ logger.Category("host").Log(_("{0} changed vhost to {1}"), this->GetMask(), shost);
- FOREACH_MOD(OnSetDisplayedHost, (this));
+ EventManager::Get()->Dispatch(&Event::SetDisplayedHost::OnSetDisplayedHost, this);
this->UpdateHost();
}
@@ -215,7 +220,7 @@ void User::SetCloakedHost(const Anope::string &newhost)
chost = newhost;
- Log(this, "host") << "changed cloaked host to " << newhost;
+ logger.Category("host").Log(_("{0} changed cloaked host to {1}"), this->GetMask(), newhost);
this->UpdateHost();
}
@@ -237,7 +242,7 @@ void User::SetVIdent(const Anope::string &sident)
{
this->vident = sident;
- Log(this, "ident") << "changed vident to " << sident;
+ logger.Category("ident").Log(_("{0} changed vident to {1}"), this->GetMask(), sident);
this->UpdateHost();
}
@@ -254,7 +259,7 @@ void User::SetIdent(const Anope::string &sident)
{
this->ident = sident;
- Log(this, "ident") << "changed real ident to " << sident;
+ logger.Category("ident").Log(_("{0} changed real ident to {1}"), this->GetMask(), sident);
this->UpdateHost();
}
@@ -280,26 +285,26 @@ void User::SetRealname(const Anope::string &srealname)
throw CoreException("realname empty in SetRealname");
this->realname = srealname;
- NickAlias *na = NickAlias::Find(this->nick);
+
+ //XXX event
+ NickServ::Nick *na = NickServ::FindNick(this->nick);
if (na && (this->IsIdentified(true) || this->IsRecognized()))
- na->last_realname = srealname;
+ na->SetLastRealname(srealname);
- Log(this, "realname") << "changed realname to " << srealname;
+ logger.Category("realname").Log(_("{0} changed realname to {1}"), this->GetMask(), srealname);
}
User::~User()
{
- UnsetExtensibles();
-
if (this->server != NULL)
{
if (this->server->IsSynced())
- Log(this, "disconnect") << "(" << this->realname << ") disconnected from the network (" << this->server->GetName() << ")";
+ logger.Category("disconnect").Log(_("{0} ({1}) disconnected from the network ({2})"), this->GetMask(), this->realname, this->server->GetName());
--this->server->users;
}
- FOREACH_MOD(OnPreUserLogoff, (this));
+ EventManager::Get()->Dispatch(&Event::PreUserLogoff::OnPreUserLogoff, this);
ModeManager::StackerDel(this);
this->Logout();
@@ -314,25 +319,10 @@ User::~User()
if (!this->uid.empty())
UserListByUID.erase(this->uid);
- FOREACH_MOD(OnPostUserLogoff, (this));
+ EventManager::Get()->Dispatch(&Event::PostUserLogoff::OnPostUserLogoff, this);
}
-void User::SendMessage(BotInfo *source, const char *fmt, ...)
-{
- va_list args;
- char buf[BUFSIZE] = "";
-
- const char *translated_message = Language::Translate(this, fmt);
-
- va_start(args, fmt);
- vsnprintf(buf, BUFSIZE - 1, translated_message, args);
-
- this->SendMessage(source, Anope::string(buf));
-
- va_end(args);
-}
-
-void User::SendMessage(BotInfo *source, const Anope::string &msg)
+void User::SendMessage(const MessageSource &source, const Anope::string &msg)
{
const char *translated_message = Language::Translate(this, msg.c_str());
@@ -341,54 +331,85 @@ void User::SendMessage(BotInfo *source, const Anope::string &msg)
* - The user is not registered and NSDefMsg is enabled
* - The user is registered and has set /ns set msg on
*/
- bool send_privmsg = Config->UsePrivmsg && ((!this->nc && Config->DefPrivmsg) || (this->nc && this->nc->HasExt("MSG")));
+ bool send_privmsg = Config->UsePrivmsg && ((!this->nc && Config->DefPrivmsg) || (this->nc && this->nc->IsMsg()));
sepstream sep(translated_message, '\n', true);
for (Anope::string tok; sep.GetToken(tok);)
{
- if (send_privmsg)
- IRCD->SendPrivmsg(source, this->GetUID(), "%s", tok.c_str());
- else
- IRCD->SendNotice(source, this->GetUID(), "%s", tok.c_str());
+ if (tok.empty())
+ tok = " ";
+ spacesepstream ssep(tok, true);
+ Anope::string buf;
+ for (Anope::string word; ssep.GetToken(word);)
+ {
+ Anope::string add;
+ if (word.empty()) // was two spaces
+ word = " ";
+
+ if (buf.empty() || buf[buf.length() - 1] == ' ')
+ add = word;
+ else
+ add = " " + word;
+
+ if (buf.length() + add.length() > Config->LineWrap)
+ {
+ if (send_privmsg)
+ IRCD->SendPrivmsg(source, this->GetUID(), buf);
+ else
+ IRCD->SendNotice(source, this->GetUID(), buf);
+ buf.clear();
+
+ add = word;
+ }
+
+ buf.append(add);
+ }
+
+ if (!buf.empty())
+ {
+ if (send_privmsg)
+ IRCD->SendPrivmsg(source, this->GetUID(), buf);
+ else
+ IRCD->SendNotice(source, this->GetUID(), buf);
+ }
}
}
-void User::Identify(NickAlias *na)
+void User::Identify(NickServ::Nick *na)
{
- if (this->nick.equals_ci(na->nick))
+ if (this->nick.equals_ci(na->GetNick()))
{
- na->last_usermask = this->GetIdent() + "@" + this->GetDisplayedHost();
- na->last_realhost = this->GetIdent() + "@" + this->host;
- na->last_realname = this->realname;
- na->last_seen = Anope::CurTime;
+ na->SetLastUsermask(this->GetIdent() + "@" + this->GetDisplayedHost());
+ na->SetLastRealhost(this->GetIdent() + "@" + this->host);
+ na->SetLastRealname(this->realname);
+ na->SetLastSeen(Anope::CurTime);
}
- IRCD->SendLogin(this, na);
+ IRCD->Send<messages::Login>(this, na);
- this->Login(na->nc);
+ this->Login(na->GetAccount());
- FOREACH_MOD(OnNickIdentify, (this));
+ EventManager::Get()->Dispatch(&Event::NickIdentify::OnNickIdentify, this);
- if (this->IsServicesOper())
+ Oper *oper = this->nc->GetOper();
+ if (oper != nullptr && oper->GetType() != nullptr)
{
- if (!this->nc->o->ot->modes.empty())
+ Anope::string m = oper->GetType()->modes;
+ if (!m.empty())
{
- this->SetModes(NULL, "%s", this->nc->o->ot->modes.c_str());
- this->SendMessage(NULL, "Changing your usermodes to \002%s\002", this->nc->o->ot->modes.c_str());
- UserMode *um = ModeManager::FindUserModeByName("OPER");
- if (um && !this->HasMode("OPER") && this->nc->o->ot->modes.find(um->mchar) != Anope::string::npos)
- IRCD->SendOper(this);
+ this->SetModes(NULL, "%s", m.c_str());
+ this->SendMessage(Me, "Changing your usermodes to \002{0}\002", m.c_str());
}
- if (IRCD->CanSetVHost && !this->nc->o->vhost.empty())
+ if (IRCD->CanSetVHost && !oper->GetVhost().empty())
{
- this->SendMessage(NULL, "Changing your vhost to \002%s\002", this->nc->o->vhost.c_str());
- this->SetDisplayedHost(this->nc->o->vhost);
- IRCD->SendVhost(this, "", this->nc->o->vhost);
+ this->SendMessage(Me, "Changing your vhost to \002{0}\002", oper->GetVhost());
+ this->SetDisplayedHost(oper->GetVhost());
+ IRCD->Send<messages::VhostSet>(this, "", oper->GetVhost());
}
}
}
-void User::Login(NickCore *core)
+void User::Login(NickServ::Account *core)
{
if (!core || core == this->nc)
return;
@@ -400,9 +421,9 @@ void User::Login(NickCore *core)
this->UpdateHost();
if (this->server->IsSynced())
- Log(this, "account") << "is now identified as " << this->nc->display;
+ logger.Category("account").Log(_("{0} is now identified as {1}"), this->GetMask(), this->nc->GetDisplay());
- FOREACH_MOD(OnUserLogin, (this));
+ EventManager::Get()->Dispatch(&Event::UserLogin::OnUserLogin, this);
}
void User::Logout()
@@ -410,16 +431,16 @@ void User::Logout()
if (!this->nc)
return;
- Log(this, "account") << "is no longer identified as " << this->nc->display;
+ logger.Category("account").Log(_("{0} is no longer identified as {1}"), this->GetMask(), this->nc->GetDisplay());
- std::list<User *>::iterator it = std::find(this->nc->users.begin(), this->nc->users.end(), this);
+ auto it = std::find(this->nc->users.begin(), this->nc->users.end(), this);
if (it != this->nc->users.end())
this->nc->users.erase(it);
this->nc = NULL;
}
-NickCore *User::Account() const
+NickServ::Account *User::Account() const
{
return this->nc;
}
@@ -428,8 +449,8 @@ bool User::IsIdentified(bool check_nick) const
{
if (check_nick && this->nc)
{
- NickAlias *na = NickAlias::Find(this->nick);
- return na && *na->nc == *this->nc;
+ NickServ::Nick *na = NickServ::FindNick(nick);
+ return na && na->GetAccount() == *this->nc;
}
return this->nc ? true : false;
@@ -439,9 +460,9 @@ bool User::IsRecognized(bool check_secure) const
{
if (check_secure && on_access)
{
- const NickAlias *na = NickAlias::Find(this->nick);
+ NickServ::Nick *na = NickServ::FindNick(nick);
- if (!na || na->nc->HasExt("NS_SECURE"))
+ if (!na || na->GetAccount()->IsSecure())
return false;
}
@@ -450,27 +471,38 @@ bool User::IsRecognized(bool check_secure) const
bool User::IsServicesOper()
{
- if (!this->nc || !this->nc->IsServicesOper())
+ if (!this->nc || !this->nc->GetOper())
// No opertype.
return false;
- else if (this->nc->o->require_oper && !this->HasMode("OPER"))
+
+ Oper *oper = this->nc->GetOper();
+
+ if (oper->GetType() == nullptr)
return false;
- else if (!this->nc->o->certfp.empty() && this->fingerprint != this->nc->o->certfp)
+
+ if (oper->GetRequireOper() && !this->HasMode("OPER"))
+ return false;
+
+ if (!oper->GetCertFP().empty() && this->fingerprint != oper->GetCertFP())
// Certfp mismatch
return false;
- else if (!this->nc->o->hosts.empty())
+
+ if (!oper->GetHost().empty())
{
+ std::vector<Anope::string> hosts;
+ spacesepstream(oper->GetHost()).GetTokens(hosts);
+
bool match = false;
Anope::string match_host = this->GetIdent() + "@" + this->host;
- for (unsigned i = 0; i < this->nc->o->hosts.size(); ++i)
- if (Anope::Match(match_host, this->nc->o->hosts[i]))
+ for (Anope::string h : hosts)
+ if (Anope::Match(match_host, h))
match = true;
if (match == false)
return false;
}
EventReturn MOD_RESULT;
- FOREACH_RESULT(IsServicesOper, MOD_RESULT, (this));
+ MOD_RESULT = EventManager::Get()->Dispatch(&Event::IsServicesOperEvent::IsServicesOper, this);
if (MOD_RESULT == EVENT_STOP)
return false;
@@ -480,14 +512,14 @@ bool User::IsServicesOper()
bool User::HasCommand(const Anope::string &command)
{
if (this->IsServicesOper())
- return this->nc->o->ot->HasCommand(command);
+ return this->nc->GetOper()->HasCommand(command);
return false;
}
bool User::HasPriv(const Anope::string &priv)
{
if (this->IsServicesOper())
- return this->nc->o->ot->HasPriv(priv);
+ return this->nc->GetOper()->HasPriv(priv);
return false;
}
@@ -496,19 +528,20 @@ void User::UpdateHost()
if (this->host.empty())
return;
- NickAlias *na = NickAlias::Find(this->nick);
+ //XXX event
+ NickServ::Nick *na = NickServ::FindNick(this->nick);
on_access = false;
if (na)
- on_access = na->nc->IsOnAccess(this);
+ on_access = na->GetAccount()->IsOnAccess(this);
if (na && (this->IsIdentified(true) || this->IsRecognized()))
{
Anope::string last_usermask = this->GetIdent() + "@" + this->GetDisplayedHost();
Anope::string last_realhost = this->GetIdent() + "@" + this->host;
- na->last_usermask = last_usermask;
- na->last_realhost = last_realhost;
+ na->SetLastUsermask(last_usermask);
+ na->SetLastRealhost(last_realhost);
// This is called on signon, and if users are introduced with an account it won't update
- na->last_realname = this->realname;
+ na->SetLastRealname(this->realname);
}
}
@@ -530,19 +563,18 @@ void User::SetModeInternal(const MessageSource &source, UserMode *um, const Anop
if (this->IsServicesOper())
{
- if (!this->nc->o->ot->modes.empty())
+ Oper *oper = this->nc->GetOper();
+ Anope::string m = oper->GetType()->modes;
+ if (!m.empty())
{
- this->SetModes(NULL, "%s", this->nc->o->ot->modes.c_str());
- this->SendMessage(NULL, "Changing your usermodes to \002%s\002", this->nc->o->ot->modes.c_str());
- UserMode *oper = ModeManager::FindUserModeByName("OPER");
- if (oper && !this->HasMode("OPER") && this->nc->o->ot->modes.find(oper->mchar) != Anope::string::npos)
- IRCD->SendOper(this);
+ this->SetModes(NULL, "%s", m.c_str());
+ this->SendMessage(Me, "Changing your usermodes to \002{0}\002", m);
}
- if (IRCD->CanSetVHost && !this->nc->o->vhost.empty())
+ if (IRCD->CanSetVHost && !oper->GetVhost().empty())
{
- this->SendMessage(NULL, "Changing your vhost to \002%s\002", this->nc->o->vhost.c_str());
- this->SetDisplayedHost(this->nc->o->vhost);
- IRCD->SendVhost(this, "", this->nc->o->vhost);
+ this->SendMessage(Me, "Changing your vhost to \002{0}\002", oper->GetVhost());
+ this->SetDisplayedHost(oper->GetVhost());
+ IRCD->Send<messages::VhostSet>(this, "", oper->GetVhost());
}
}
}
@@ -550,7 +582,7 @@ void User::SetModeInternal(const MessageSource &source, UserMode *um, const Anop
if (um->name == "CLOAK" || um->name == "VHOST")
this->UpdateHost();
- FOREACH_MOD(OnUserModeSet, (source, this, um->name));
+ EventManager::Get()->Dispatch(&Event::UserModeSet::OnUserModeSet, source, this, um->name);
}
void User::RemoveModeInternal(const MessageSource &source, UserMode *um)
@@ -569,10 +601,10 @@ void User::RemoveModeInternal(const MessageSource &source, UserMode *um)
this->UpdateHost();
}
- FOREACH_MOD(OnUserModeUnset, (source, this, um->name));
+ EventManager::Get()->Dispatch(&Event::UserModeUnset::OnUserModeUnset, source, this, um->name);
}
-void User::SetMode(BotInfo *bi, UserMode *um, const Anope::string &param)
+void User::SetMode(ServiceBot *bi, UserMode *um, const Anope::string &param)
{
if (!um || HasMode(um->name))
return;
@@ -581,12 +613,12 @@ void User::SetMode(BotInfo *bi, UserMode *um, const Anope::string &param)
SetModeInternal(bi, um, param);
}
-void User::SetMode(BotInfo *bi, const Anope::string &uname, const Anope::string &param)
+void User::SetMode(ServiceBot *bi, const Anope::string &uname, const Anope::string &param)
{
SetMode(bi, ModeManager::FindUserModeByName(uname), param);
}
-void User::RemoveMode(BotInfo *bi, UserMode *um, const Anope::string &param)
+void User::RemoveMode(ServiceBot *bi, UserMode *um, const Anope::string &param)
{
if (!um || !HasMode(um->name))
return;
@@ -595,12 +627,12 @@ void User::RemoveMode(BotInfo *bi, UserMode *um, const Anope::string &param)
RemoveModeInternal(bi, um);
}
-void User::RemoveMode(BotInfo *bi, const Anope::string &name, const Anope::string &param)
+void User::RemoveMode(ServiceBot *bi, const Anope::string &name, const Anope::string &param)
{
RemoveMode(bi, ModeManager::FindUserModeByName(name), param);
}
-void User::SetModes(BotInfo *bi, const char *umodes, ...)
+void User::SetModes(ServiceBot *bi, const char *umodes, ...)
{
char buf[BUFSIZE] = "";
va_list args;
@@ -655,7 +687,7 @@ void User::SetModesInternal(const MessageSource &source, const char *umodes, ...
va_end(args);
if (this->server && this->server->IsSynced() && Anope::string(buf) != "+")
- Log(this, "mode") << "changes modes to " << buf;
+ logger.Category("mode").Log(_("{0} changes mode to {1}"), this->GetMask(), buf);
spacesepstream sep(buf);
sep.GetToken(modebuf);
@@ -732,18 +764,18 @@ void User::Kill(const MessageSource &source, const Anope::string &reason)
{
Anope::string real_reason = source.GetName() + " (" + reason + ")";
- IRCD->SendSVSKill(source, this, "%s", real_reason.c_str());
+ IRCD->SendKill(source, this, real_reason);
}
void User::KillInternal(const MessageSource &source, const Anope::string &reason)
{
if (this->quit)
{
- Log(LOG_DEBUG) << "Duplicate quit for " << this->nick;
+ Anope::Logger.Debug("Duplicate quit for {0}", this->nick);
return;
}
- Log(this, "killed") << "was killed by " << source.GetName() << " (Reason: " << reason << ")";
+ logger.Category("killed").Log(_("{0} was killed by {1} (Reason: {2})"), this->GetMask(), source.GetName(), reason);
this->Quit(reason);
}
@@ -752,11 +784,11 @@ void User::Quit(const Anope::string &reason)
{
if (this->quit)
{
- Log(LOG_DEBUG) << "Duplicate quit for " << this->nick;
+ Anope::Logger.Debug("Duplicate quit for {0}", this->nick);
return;
}
- FOREACH_MOD(OnUserQuit, (this, reason));
+ EventManager::Get()->Dispatch(&Event::UserQuit::OnUserQuit, this, reason);
this->quit = true;
quitting_users.push_back(this);
@@ -767,7 +799,7 @@ bool User::Quitting() const
return this->quit;
}
-Anope::string User::Mask() const
+Anope::string User::WildMask() const
{
Anope::string mask;
const Anope::string &mident = this->GetIdent();
@@ -818,7 +850,7 @@ User* User::Find(const Anope::string &name, bool nick_only)
{
if (!nick_only && IRCD && IRCD->RequiresID)
{
- user_map::iterator it = UserListByUID.find(name);
+ uid_map::iterator it = UserListByUID.find(name);
if (it != UserListByUID.end())
return it->second;
@@ -839,3 +871,4 @@ void User::QuitUsers()
delete *it;
quitting_users.clear();
}
+