Anope IRC Services  Version 2.0
users.h
Go to the documentation of this file.
1 /*
2  *
3  * (C) 2008-2011 Robin Burchell <w00t@inspircd.org>
4  * (C) 2003-2014 Anope Team
5  * Contact us at team@anope.org
6  *
7  * Please read COPYING and README for further details.
8  *
9  * Based on the original code of Epona by Lara.
10  * Based on the original code of Services by Andy Church.
11  *
12  */
13 
14 #ifndef USERS_H
15 #define USERS_H
16 
17 #include "anope.h"
18 #include "modes.h"
19 #include "extensible.h"
20 #include "serialize.h"
21 #include "commands.h"
22 #include "account.h"
23 #include "sockets.h"
24 
26 
28 
29 extern CoreExport int OperCount;
30 extern CoreExport unsigned MaxUserCount;
31 extern CoreExport time_t MaxUserTime;
32 
33 /* Online user and channel data. */
34 class CoreExport User : public virtual Base, public Extensible, public CommandReply
35 {
36  /* true if the user was quit or killed */
37  bool quit;
38  /* Users that are in the process of quitting */
39  static std::list<User *> quitting_users;
40 
41  public:
42  typedef std::map<Anope::string, Anope::string> ModeList;
43  protected:
47  /* If the user is on the access list of the nick theyre on */
48  bool on_access;
49  /* Map of user modes and the params this user has (if any) */
50  ModeList modes;
51  /* NickCore account the user is currently loggged in as, if they are logged in */
53 
54  /* # of invalid password attempts */
55  unsigned short invalid_pw_count;
56  /* Time of last invalid password */
58 
59 
60  public: // XXX: exposing a tiny bit too much
61  /* User's current nick */
63 
64  /* User's real hostname */
66  /* User's virtual hostname */
68  /* User's cloaked hostname */
70  /* Realname */
72  /* SSL Fingerprint */
74  /* User's IP */
76  /* Server user is connected to */
78  /* When the user signed on. Set on connect and never modified. */
79  time_t signon;
80  /* Timestamp of the nick. Updated when the nick changes. */
81  time_t timestamp;
82  /* Is the user as super admin? */
84 
85  /* Channels the user is in */
86  typedef std::map<Channel *, ChanUserContainer *> ChanUserList;
87  ChanUserList chans;
88 
89  /* Last time this user sent a memo command used */
90  time_t lastmemosend;
91  /* Last time this user registered */
92  time_t lastnickreg;
93  /* Last time this user sent an email */
94  time_t lastmail;
95 
96  protected:
112  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);
113 
116  virtual ~User();
117 
118  public:
119  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);
120 
126  void ChangeNick(const Anope::string &newnick, time_t ts = Anope::CurTime);
127 
132  void SetDisplayedHost(const Anope::string &host);
133 
137  const Anope::string &GetDisplayedHost() const;
138 
142  void SetCloakedHost(const Anope::string &newhost);
143 
147  const Anope::string &GetCloakedHost() const;
148 
152  const Anope::string &GetUID() const;
153 
157  void SetVIdent(const Anope::string &ident);
158 
162  const Anope::string &GetVIdent() const;
163 
168  void SetIdent(const Anope::string &ident);
169 
174  const Anope::string &GetIdent() const;
175 
178  Anope::string GetMask() const;
179 
182  Anope::string GetDisplayedMask() const;
183 
186  void SetRealname(const Anope::string &realname);
187 
194  void SendMessage(BotInfo *source, const char *fmt, ...);
195  void SendMessage(BotInfo *source, const Anope::string &msg) anope_override;
196 
203  void Identify(NickAlias *na);
204 
208  void Login(NickCore *core);
209 
212  void Logout();
213 
217  NickCore *Account() const;
218 
223  bool IsIdentified(bool check_nick = false) const;
224 
229  bool IsRecognized(bool check_secure = true) const;
230 
234  bool IsServicesOper();
235 
240  bool HasCommand(const Anope::string &cmdstr);
241 
246  bool HasPriv(const Anope::string &privstr);
247 
250  void UpdateHost();
251 
256  bool HasMode(const Anope::string &name) const;
257 
263  void SetModeInternal(const MessageSource &setter, UserMode *um, const Anope::string &param = "");
264 
269  void RemoveModeInternal(const MessageSource &setter, UserMode *um);
270 
276  void SetMode(BotInfo *bi, UserMode *um, const Anope::string &param = "");
277 
283  void SetMode(BotInfo *bi, const Anope::string &name, const Anope::string &param = "");
284 
290  void RemoveMode(BotInfo *bi, UserMode *um, const Anope::string &param = "");
291 
297  void RemoveMode(BotInfo *bi, const Anope::string &name, const Anope::string &param = "");
298 
303  void SetModes(BotInfo *bi, const char *umodes, ...);
304 
309  void SetModesInternal(const MessageSource &source, const char *umodes, ...);
310 
314  Anope::string GetModes() const;
315 
316  const ModeList &GetModeList() const;
317 
324  ChanUserContainer *FindChannel(Channel *c) const;
325 
329  bool IsProtected();
330 
335  void Kill(const MessageSource &source, const Anope::string &reason);
336 
341  void KillInternal(const MessageSource &source, const Anope::string &reason);
342 
346  void Quit(const Anope::string &reason = "");
347 
348  bool Quitting() const;
349 
350  /* Returns a mask that will most likely match any address the
351  * user will have from that location. For IP addresses, wildcards the
352  * appropriate subnet mask (e.g. 35.1.1.1 -> 35.*; 128.2.1.1 -> 128.2.*);
353  * for named addresses, wildcards the leftmost part of the name unless the
354  * name only contains two parts. If the username begins with a ~, delete
355  * it.
356  */
357  Anope::string Mask() const;
358 
363  bool BadPassword();
364 
370  static User* Find(const Anope::string &name, bool nick_only = false);
371 
374  static void QuitUsers();
375 };
376 
377 #endif // USERS_H
Definition: bots.h:24
Definition: servers.h:42
Definition: base.h:17
Anope::string uid
Definition: users.h:46
time_t signon
Definition: users.h:79
Anope::string ident
Definition: users.h:45
Anope::string fingerprint
Definition: users.h:73
time_t lastmail
Definition: users.h:94
ChanUserList chans
Definition: users.h:87
Anope::string vident
Definition: users.h:44
Definition: users.h:34
CoreExport unsigned MaxUserCount
Definition: users.cpp:31
static std::list< User * > quitting_users
Definition: users.h:39
time_t invalid_pw_time
Definition: users.h:57
CoreExport time_t MaxUserTime
Definition: users.cpp:32
virtual void SendMessage(BotInfo *source, const Anope::string &msg)=0
CoreExport time_t CurTime
Definition: main.cpp:41
time_t lastmemosend
Definition: users.h:90
time_t lastnickreg
Definition: users.h:92
CoreExport user_map UserListByUID
Definition: users.cpp:28
std::map< Channel *, ChanUserContainer * > ChanUserList
Definition: users.h:86
time_t timestamp
Definition: users.h:81
CoreExport bool Quitting
Definition: main.cpp:34
Serialize::Reference< NickCore > nc
Definition: users.h:52
Definition: modes.h:68
#define anope_override
Definition: services.h:56
Anope::string host
Definition: users.h:65
sockaddrs ip
Definition: users.h:75
Server * server
Definition: users.h:77
std::map< Anope::string, Anope::string > ModeList
Definition: users.h:42
#define CoreExport
Definition: services.h:62
Anope::string realname
Definition: users.h:71
Anope::string nick
Definition: users.h:62
ModeList modes
Definition: users.h:50
Anope::string chost
Definition: users.h:69
static bool HasPriv(const AccessGroup &ag, const ChanAccess *access, const Anope::string &name)
Definition: access.cpp:358
Anope::string name
Definition: access.cpp:22
bool quit
Definition: users.h:37
CoreExport user_map UserListByNick
Definition: users.cpp:28
bool on_access
Definition: users.h:48
unsigned short invalid_pw_count
Definition: users.h:55
bool super_admin
Definition: users.h:83
CoreExport int OperCount
Definition: users.cpp:30
Anope::string vhost
Definition: users.h:67
Anope::hash_map< User * > user_map
Definition: users.h:25