bots.h

Go to the documentation of this file.
00001 /*
00002  *
00003  * Copyright (C) 2008-2011 Robin Burchell <w00t@inspircd.org>
00004  * Copyright (C) 2008-2013 Anope Team <team@anope.org>
00005  *
00006  * Please read COPYING and README for further details.
00007  *
00008  */
00009 
00010 #ifndef BOTS_H
00011 #define BOTS_H
00012 
00013 #include "users.h"
00014 #include "anope.h"
00015 #include "serialize.h"
00016 #include "commands.h"
00017 
00018 
00019 typedef Anope::map<BotInfo *> botinfo_map;
00020 
00021 extern CoreExport Serialize::Checker<botinfo_map> BotListByNick, BotListByUID;
00022 
00023 /* A service bot (NickServ, ChanServ, a BotServ bot, etc). */
00024 class CoreExport BotInfo : public User, public Serializable
00025 {
00026  public:
00027         time_t created;
00028         /* Last time this bot said something (via privmsg) */
00029         time_t lastmsg;
00030         /* Map of actual command names -> service name/permission required */
00031         CommandInfo::map commands;
00032         /* Modes the bot should have as configured in service:modes */
00033         Anope::string botmodes;
00034         /* Channels the bot should be in as configured in service:channels */
00035         std::vector<Anope::string> botchannels;
00036         /* Whether or not this bot is introduced to the network */
00037         bool introduced;
00038         /* Bot can only be assigned by irc ops */
00039         bool oper_only;
00040         /* Bot is defined in the configuration file */
00041         bool conf;
00042 
00050         BotInfo(const Anope::string &nick, const Anope::string &user = "", const Anope::string &host = "", const Anope::string &real = "", const Anope::string &bmodes = "");
00051 
00054         virtual ~BotInfo();
00055 
00056         void Serialize(Serialize::Data &data) const;
00057         static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
00058 
00059         void GenerateUID();
00060 
00064         void SetNewNick(const Anope::string &newnick);
00065 
00069         void RejoinAll();
00070 
00075         void Assign(User *u, ChannelInfo *ci);
00076 
00081         void UnAssign(User *u, ChannelInfo *ci);
00082 
00085         unsigned GetChannelCount() const;
00086 
00091         void Join(Channel *c, ChannelStatus *status = NULL);
00092 
00097         void Join(const Anope::string &chname, ChannelStatus *status = NULL);
00098 
00103         void Part(Channel *c, const Anope::string &reason = "");
00104 
00109         virtual void OnMessage(User *u, const Anope::string &message);
00110 
00117         CommandInfo& SetCommand(const Anope::string &cname, const Anope::string &sname, const Anope::string &permission = "");
00118 
00123         CommandInfo *GetCommand(const Anope::string &cname);
00124 
00130         static BotInfo* Find(const Anope::string &nick, bool nick_only = false);
00131 };
00132 
00133 extern CoreExport BotInfo *BotServ, *ChanServ, *Global, *HostServ, *MemoServ, *NickServ, *OperServ;
00134 
00135 #endif // BOTS_H