Anope IRC Services  Version 2.0
bots.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2008-2011 Robin Burchell <w00t@inspircd.org>
4  * Copyright (C) 2008-2014 Anope Team <team@anope.org>
5  *
6  * Please read COPYING and README for further details.
7  *
8  */
9 
10 #ifndef BOTS_H
11 #define BOTS_H
12 
13 #include "users.h"
14 #include "anope.h"
15 #include "serialize.h"
16 #include "commands.h"
17 
18 
20 
22 
23 /* A service bot (NickServ, ChanServ, a BotServ bot, etc). */
24 class CoreExport BotInfo : public User, public Serializable
25 {
26  /* Channels this bot is assigned to */
28  public:
29  time_t created;
30  /* Last time this bot said something (via privmsg) */
31  time_t lastmsg;
32  /* Map of actual command names -> service name/permission required */
34  /* Modes the bot should have as configured in service:modes */
36  /* Channels the bot should be in as configured in service:channels */
37  std::vector<Anope::string> botchannels;
38  /* Whether or not this bot is introduced to the network */
39  bool introduced;
40  /* Bot can only be assigned by irc ops */
41  bool oper_only;
42  /* Bot is defined in the configuration file */
43  bool conf;
44 
52  BotInfo(const Anope::string &nick, const Anope::string &user = "", const Anope::string &host = "", const Anope::string &real = "", const Anope::string &bmodes = "");
53 
56  virtual ~BotInfo();
57 
58  void Serialize(Serialize::Data &data) const;
59  static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
60 
61  void GenerateUID();
62 
63  void OnKill();
64 
68  void SetNewNick(const Anope::string &newnick);
69 
72  const std::set<ChannelInfo *> &GetChannels() const;
73 
78  void Assign(User *u, ChannelInfo *ci);
79 
84  void UnAssign(User *u, ChannelInfo *ci);
85 
88  unsigned GetChannelCount() const;
89 
94  void Join(Channel *c, ChannelStatus *status = NULL);
95 
100  void Join(const Anope::string &chname, ChannelStatus *status = NULL);
101 
106  void Part(Channel *c, const Anope::string &reason = "");
107 
112  virtual void OnMessage(User *u, const Anope::string &message);
113 
120  CommandInfo& SetCommand(const Anope::string &cname, const Anope::string &sname, const Anope::string &permission = "");
121 
126  CommandInfo *GetCommand(const Anope::string &cname);
127 
133  static BotInfo* Find(const Anope::string &nick, bool nick_only = false);
134 };
135 
136 #endif // BOTS_H
Definition: bots.h:24
std::vector< Anope::string > botchannels
Definition: bots.h:37
Serialize::Checker< std::set< ChannelInfo * > > channels
Definition: bots.h:27
Definition: hashcomp.h:84
time_t lastmsg
Definition: bots.h:31
Anope::string botmodes
Definition: bots.h:35
CommandInfo::map commands
Definition: bots.h:33
Definition: users.h:34
CoreExport Serialize::Checker< botinfo_map > BotListByUID
bool introduced
Definition: bots.h:39
bool conf
Definition: bots.h:43
CoreExport Serialize::Checker< botinfo_map > BotListByNick
virtual void Serialize(Serialize::Data &data) const =0
time_t created
Definition: bots.h:29
#define CoreExport
Definition: services.h:62
bool oper_only
Definition: bots.h:41
static User * Find(const Anope::string &name, bool nick_only=false)
Definition: users.cpp:815
Anope::map< BotInfo * > botinfo_map
Definition: bots.h:19