summaryrefslogtreecommitdiff
path: root/include/users.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/users.h')
-rw-r--r--include/users.h94
1 files changed, 62 insertions, 32 deletions
diff --git a/include/users.h b/include/users.h
index 27fce6cf8..de9cc5b42 100644
--- a/include/users.h
+++ b/include/users.h
@@ -1,35 +1,48 @@
/*
+ * Anope IRC Services
*
- * (C) 2008-2011 Robin Burchell <w00t@inspircd.org>
- * (C) 2003-2016 Anope Team <team@anope.org>
+ * Copyright (C) 2008-2011 Robin Burchell <w00t@inspircd.org>
+ * Copyright (C) 2009-2016 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/>.
*/
-#ifndef USERS_H
-#define USERS_H
+#pragma once
#include "anope.h"
#include "modes.h"
#include "extensible.h"
#include "serialize.h"
#include "commands.h"
-#include "account.h"
#include "sockets.h"
-typedef Anope::hash_map<User *> user_map;
+using user_map = Anope::locale_hash_map<User *>;
+using uid_map = std::unordered_map<Anope::string, User *, Anope::hash, Anope::compare>;
-extern CoreExport user_map UserListByNick, UserListByUID;
+extern CoreExport user_map UserListByNick;
+extern CoreExport uid_map UserListByUID;
extern CoreExport int OperCount;
-extern CoreExport unsigned MaxUserCount;
-extern CoreExport time_t MaxUserTime;
+
+enum class UserType
+{
+ USER,
+ BOT
+};
/* Online user and channel data. */
-class CoreExport User : public virtual Base, public Extensible, public CommandReply
+class CoreExport User : public virtual Base, public virtual Extensible, public CommandReply
{
/* true if the user was quit or killed */
bool quit;
@@ -46,8 +59,8 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
bool on_access;
/* Map of user modes and the params this user has (if any) */
ModeList modes;
- /* NickCore account the user is currently loggged in as, if they are logged in */
- Serialize::Reference<NickCore> nc;
+ /* NickServ::Account account the user is currently loggged in as, if they are logged in */
+ Serialize::Reference<NickServ::Account> nc;
/* # of invalid password attempts */
unsigned short invalid_pw_count;
@@ -55,7 +68,11 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
time_t invalid_pw_time;
- public: // XXX: exposing a tiny bit too much
+ public:
+ UserType type = UserType::USER;
+
+ Logger logger;
+
/* User's current nick */
Anope::string nick;
@@ -107,14 +124,14 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
* @param suid The unique identifier of the user.
* @param nc The account the user is identified as, if any
*/
- 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);
+ 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, NickServ::Account *nc);
/** Destroy a user.
*/
virtual ~User();
public:
- 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);
+ 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, NickServ::Account *nc);
/** Update the nickname of a user record accordingly, should be
* called from ircd protocol.
@@ -186,11 +203,16 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
/**
* Send a message (notice or privmsg, depending on settings) to a user
* @param source Sender
- * @param fmt Format of the Message
- * @param ... any number of parameters
+ * @param message Format of the Message
+ * @param args any number of parameters
*/
- void SendMessage(BotInfo *source, const char *fmt, ...);
- void SendMessage(BotInfo *source, const Anope::string &msg) anope_override;
+ template<typename... Args>
+ void SendMessage(const MessageSource &source, const char *message, Args&&... args)
+ {
+ const char *translated_message = Language::Translate(this->Account(), message);
+ SendMessage(source, Anope::Format(translated_message, std::forward<Args>(args)...));
+ }
+ void SendMessage(const MessageSource &, const Anope::string &msg) override;
/** Identify the user to a nick.
* updates last_seen, logs the user in,
@@ -198,12 +220,12 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
* @param na the nick to identify to, should be the same as
* the user's current nick
*/
- void Identify(NickAlias *na);
+ void Identify(NickServ::Nick *na);
/** Login the user to an account
* @param core The account
*/
- void Login(NickCore *core);
+ void Login(NickServ::Account *core);
/** Logout the user
*/
@@ -212,7 +234,7 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
/** Get the account the user is logged in using
* @return The account or NULL
*/
- NickCore *Account() const;
+ NickServ::Account *Account() const;
/** Check if the user is identified for their nick
* @param check_nick True to check if the user is identified to the nickname they are on too
@@ -271,34 +293,34 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
* @param um The user mode
* @param Param Optional param for the mode
*/
- void SetMode(BotInfo *bi, UserMode *um, const Anope::string &param = "");
+ void SetMode(ServiceBot *bi, UserMode *um, const Anope::string &param = "");
/** Set a mode on the user
* @param bi The client setting the mode
* @param name The mode name
* @param Param Optional param for the mode
*/
- void SetMode(BotInfo *bi, const Anope::string &name, const Anope::string &param = "");
+ void SetMode(ServiceBot *bi, const Anope::string &name, const Anope::string &param = "");
/** Remove a mode on the user
* @param bi The client setting the mode
* @param um The user mode
* @param param Optional param for the mode
*/
- void RemoveMode(BotInfo *bi, UserMode *um, const Anope::string &param = "");
+ void RemoveMode(ServiceBot *bi, UserMode *um, const Anope::string &param = "");
/** Remove a mode from the user
* @param bi The client setting the mode
* @param name The mode name
* @param param Optional param for the mode
*/
- void RemoveMode(BotInfo *bi, const Anope::string &name, const Anope::string &param = "");
+ void RemoveMode(ServiceBot *bi, const Anope::string &name, const Anope::string &param = "");
/** Set a string of modes on a user
* @param bi The client setting the modes
* @param umodes The modes
*/
- void SetModes(BotInfo *bi, const char *umodes, ...);
+ void SetModes(ServiceBot *bi, const char *umodes, ...);
/** Set a string of modes on a user internally
* @param setter who/what is setting the mode
@@ -351,7 +373,7 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
* the leftmost part of the name unless the name only contains two parts.
* If the username begins with a ~, replace with *.
*/
- Anope::string Mask() const;
+ Anope::string WildMask() const;
/** Notes the usage of an incorrect password. If too many
* incorrect passwords are used the user might be killed.
@@ -371,4 +393,12 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
static void QuitUsers();
};
-#endif // USERS_H
+class LocalUser : public User
+{
+ public:
+ using User::User;
+
+ /* Last time this user said something */
+ time_t lastmsg = 0;
+};
+