36 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)
60 size_t old = UserListByNick.size();
61 UserListByNick[snick] =
this;
63 UserListByUID[suid] =
this;
64 if (old == UserListByNick.size())
65 Log(
LOG_DEBUG) <<
"Duplicate user " << snick <<
" in user table?";
74 Log(
this,
"connect") << (!
vhost.
empty() &&
vhost !=
host ?
"(" +
vhost +
") " :
"") <<
"(" << srealname <<
") " << (!uip.
empty() && uip !=
host ?
"[" + uip +
"] " :
"") <<
"connected to the network (" << sserver->
GetName() <<
")";
82 Log(
this,
"maxusers") <<
"connected - new maximum user count: " << UserListByNick.size();
101 if (
BotInfo *bi = dynamic_cast<BotInfo *>(target))
104 target->
Quit(reason);
116 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)
124 Collide(u, !suid.
empty() ? suid : snick,
"Nick collision");
133 Collide(u, suid,
"ID collision");
138 return new User(snick, sident, shost, svhost, sip, sserver, srealname, ts, smodes, suid, nc);
145 throw CoreException(
"User::ChangeNick() got a bad argument");
148 Log(
this,
"nick") <<
"(" << this->
realname <<
") changed nick to " << newnick;
154 this->
nick = newnick;
161 UserListByNick.erase(this->
nick);
163 this->
nick = newnick;
165 User* &other = UserListByNick[this->
nick];
179 if (na && na->
nc == this->Account())
192 throw CoreException(
"empty host? in MY services? it seems it's more likely than I thought.");
196 Log(
this,
"host") <<
"changed vhost to " << shost;
220 Log(
this,
"host") <<
"changed cloaked host to " << newhost;
242 Log(
this,
"ident") <<
"changed vident to " << sident;
257 this->
ident = sident;
259 Log(
this,
"ident") <<
"changed real ident to " << sident;
281 if (srealname.
empty())
290 Log(
this,
"realname") <<
"changed realname to " << srealname;
298 Log(
this,
"disconnect") <<
"(" << this->
realname <<
") disconnected from the network (" << this->
server->
GetName() <<
")";
310 while (!this->
chans.empty())
311 this->
chans.begin()->second->chan->DeleteUser(
this);
313 UserListByNick.erase(this->
nick);
315 UserListByUID.erase(this->uid);
328 vsnprintf(buf,
BUFSIZE - 1, translated_message, args);
344 bool send_privmsg =
Config->UsePrivmsg && ((!this->
nc &&
Config->DefPrivmsg) || (this->
nc && this->
nc->HasExt(
"MSG")));
345 sepstream sep(translated_message,
'\n',
true);
373 if (!this->
nc->o->ot->modes.empty())
375 this->
SetModes(NULL,
"%s", this->
nc->o->ot->modes.c_str());
376 this->
SendMessage(NULL,
"Changing your usermodes to \002%s\002", this->
nc->o->ot->modes.c_str());
383 this->
SendMessage(NULL,
"Changing your vhost to \002%s\002", this->
nc->o->vhost.c_str());
393 if (!core || core == this->
nc)
398 core->
users.push_back(
this);
403 Log(
this,
"account") <<
"is now identified as " << this->
nc->display;
413 Log(
this,
"account") <<
"is no longer identified as " << this->
nc->display;
415 std::list<User *>::iterator it = std::find(this->
nc->users.begin(), this->
nc->users.end(),
this);
416 if (it != this->
nc->users.end())
417 this->
nc->users.erase(it);
429 if (check_nick && this->
nc)
432 return na && *na->
nc == *this->
nc;
435 return this->
nc ?
true :
false;
444 if (!na || na->
nc->HasExt(
"NS_SECURE"))
453 if (!this->
nc || !this->
nc->IsServicesOper())
456 else if (this->
nc->o->require_oper && !this->HasMode(
"OPER"))
458 else if (!this->
nc->o->certfp.empty() && this->
fingerprint != this->
nc->o->certfp)
461 else if (!this->
nc->o->hosts.empty())
465 for (
unsigned i = 0; i < this->
nc->o->hosts.size(); ++i)
483 return this->
nc->o->ot->HasCommand(command);
490 return this->
nc->o->ot->HasPriv(priv);
515 return this->
modes.count(mname);
525 if (um->
name ==
"OPER")
531 if (!this->
nc->o->ot->modes.empty())
533 this->
SetModes(NULL,
"%s", this->
nc->o->ot->modes.c_str());
534 this->
SendMessage(NULL,
"Changing your usermodes to \002%s\002", this->
nc->o->ot->modes.c_str());
541 this->
SendMessage(NULL,
"Changing your vhost to \002%s\002", this->
nc->o->vhost.c_str());
548 if (um->
name ==
"CLOAK" || um->
name ==
"VHOST")
561 if (um->
name ==
"OPER")
564 if (um->
name ==
"CLOAK" || um->
name ==
"VHOST")
607 va_start(args, umodes);
608 vsnprintf(buf,
BUFSIZE - 1, umodes, args);
613 for (
unsigned i = 0, end = modebuf.
length(); i < end; ++i)
651 va_start(args, umodes);
652 vsnprintf(buf,
BUFSIZE - 1, umodes, args);
656 Log(
this,
"mode") <<
"changes modes to " << buf;
660 for (
unsigned i = 0, end = modebuf.
length(); i < end; ++i)
696 for (ModeList::const_iterator it = this->
modes.begin(), it_end = this->
modes.end(); it != it_end; ++it)
704 if (!it->second.empty())
705 params +=
" " + it->second;
718 User::ChanUserList::const_iterator it = this->
chans.find(c);
719 if (it != this->
chans.end())
744 Log(
this,
"killed") <<
"was killed by " << source.
GetName() <<
" (Reason: " << reason <<
")";
774 if (mident[0] ==
'~')
775 mask =
"*" + mident +
"@";
780 if (addr.
valid() && addr.
sa.sa_family == AF_INET)
782 size_t dot = mhost.
find(
'.');
787 size_t dot = mhost.
find(
'.');
789 mask +=
"*" + mhost.
substr(dot);
799 if (!
Config->GetBlock(
"options")->Get<
int>(
"badpasslimit"))
802 if (
Config->GetBlock(
"options")->Get<time_t>(
"badpasstimeout") > 0 && this->
invalid_pw_time > 0 && this->invalid_pw_time < Anope::CurTime - Config->GetBlock(
"options")->Get<time_t>(
"badpasstimeout"))
819 user_map::iterator it = UserListByUID.find(name);
820 if (it != UserListByUID.end())
827 user_map::iterator it = UserListByNick.find(name);
828 if (it != UserListByNick.end())
Serialize::Reference< NickCore > nc
bool HasMode(const Anope::string &name) const
static NickAlias * Find(const Anope::string &nick)
void SetCloakedHost(const Anope::string &newhost)
void Kill(const MessageSource &source, const Anope::string &reason)
virtual void SendVhost(User *u, const Anope::string &vident, const Anope::string &vhost)
void SetModeInternal(const MessageSource &setter, UserMode *um, const Anope::string ¶m="")
const Anope::string & GetIdent() const
bool HasCommand(const Anope::string &cmdstr)
void RemoveModeInternal(const MessageSource &setter, UserMode *um)
void SetMode(BotInfo *bi, UserMode *um, const Anope::string ¶m="")
bool IsRecognized(bool check_secure=true) const
static UserMode * FindUserModeByChar(char mode)
Anope::string fingerprint
void Quit(const Anope::string &reason="")
virtual void SendPrivmsg(const MessageSource &source, const Anope::string &dest, const char *fmt,...)
virtual void SendNotice(const MessageSource &source, const Anope::string &dest, const char *fmt,...)
Anope::string last_usermask
static 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)
virtual void SendSVSKill(const MessageSource &source, User *user, const char *fmt,...)
User(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)
ChanUserContainer * FindChannel(Channel *c) const
static void CollideKill(User *target, const Anope::string &reason)
static std::list< User * > quitting_users
Anope::string Mask() const
#define FOREACH_RESULT(ename, ret, args)
bool equals_ci(const char *_str) const
virtual void SendQuit(User *u, const char *fmt,...)
static UserMode * FindUserModeByName(const Anope::string &name)
CoreExport time_t CurTime
Anope::string GetModes() const
#define FOREACH_MOD(ename, args)
void Identify(NickAlias *na)
static void Collide(User *u, const Anope::string &id, const Anope::string &type)
static void StackerDel(User *u)
string substr(size_type pos=0, size_type n=npos) const
void SetRealname(const Anope::string &realname)
CoreExport bool Match(const string &str, const string &mask, bool case_sensitive=false, bool use_regex=false)
static const size_type npos
void SetIdent(const Anope::string &ident)
const Anope::string & GetUID() const
const Anope::string & GetDisplayedHost() const
Anope::string GetDisplayedMask() const
Serialize::Reference< NickCore > nc
bool IsIdentified(bool check_nick=false) const
Anope::string GetMask() const
bool HasPriv(const Anope::string &privstr)
void SetVIdent(const Anope::string &ident)
const Anope::string & GetVIdent() const
void ChangeNick(const Anope::string &newnick, time_t ts=Anope::CurTime)
const ModeList & GetModeList() const
void KillInternal(const MessageSource &source, const Anope::string &reason)
CoreExport IRCDProto * IRCD
std::basic_string< char, ci_char_traits, std::allocator< char > > string
CoreExport const char * Translate(const char *string)
virtual void SendKill(const MessageSource &source, const Anope::string &target, const Anope::string &reason)
std::map< Anope::string, Anope::string > ModeList
void SetDisplayedHost(const Anope::string &host)
void Login(NickCore *core)
static void StackerAdd(BotInfo *bi, Channel *c, ChannelMode *cm, bool set, const Anope::string ¶m="")
void RemoveMode(BotInfo *bi, UserMode *um, const Anope::string ¶m="")
void SetModes(BotInfo *bi, const char *umodes,...)
virtual void SendLogin(User *u, NickAlias *na)=0
static User * Find(const Anope::string &name, bool nick_only=false)
const Anope::string & GetCloakedHost() const
const Anope::string & GetName() const
NickCore * Account() const
bool GetToken(Anope::string &token)
Anope::string last_realname
void SetModesInternal(const MessageSource &source, const char *umodes,...)
const char * c_str() const
unsigned short invalid_pw_count
std::list< User * > users
void SendMessage(BotInfo *source, const char *fmt,...)
size_type find(const string &_str, size_type pos=0) const
virtual void SendOper(User *u)
Anope::string last_realhost
const Anope::string & GetName() const