Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef COMMANDS_H
- #define COMMANDS_H
- namespace Irc
- {
- class Commands;
- class User;
- class Channel;
- enum CommandType_t
- {
- CMD_JOIN, //normal users
- CMD_PART, //normal ///
- CMD_QUIT, //normal
- CMD_NICK, //normal
- CMD_KILL, //oper
- CMD_KLINE, //oper
- CMD_GLINE, //oper
- CMD_AWAY, //normal
- CMD_WHOIS, //normal
- CMD_PRIVMSG, //normal
- CMD_TOPIC, //normal
- CMD_USER, //normal
- CMD_CMDLIST, //normal
- CMD_OPER, //oper
- CMD_KICK, //normal
- CMD_MODE, //normal
- CMD_CHAN_MODE
- };
- } //namespace Irc
- #include <string>
- #ifndef cmdInstance
- #define cmdInstance &Commands::instance()
- #endif
- #ifndef CMD_NOTIFY
- #define CMD_NOTIFY(x) cmdInstance->registerCommand(x)
- #endif
- #include <map>
- class Irc::Commands
- {
- public:
- Commands();
- ~Commands();
- static Commands instance()
- {
- static Commands i;
- return i;
- }
- void registerCommand(const char *cmd);
- bool isRegistered();
- void executeCommand(const char *cmd, bool check = true);
- //channel commands
- void join(User* user, Channel* chan, const char *msg);
- void part(User* user, Channel* chan, const char *msg);
- void topic(User* user, Channel* chan, const char *msg);
- void kick(User* user, Channel* chan, const char *msg);
- void chanMode(User* user, Channel* chan, const char* mode);
- ////odd commands
- void quit(User* user);
- void nick(User* user, const char *__nick);
- void away(User* user, const char *__msg);
- void whois(User* dest, User* from);
- void privmsg(User* from, const char *__channel, const char *__msg);
- void user(User* user, ...);
- void cmdList(User* user);
- void oper(User* user, const char *acc, const char *pass);
- void mode(User* user, const char mode);
- //oper commands
- void kill(User* dest, User* from);
- void kline(User* dest, User* from);
- void gline(User* dest, User* from);
- protected:
- typedef void(*chan_t)(User* user, Channel* chan, const char *msg);
- typedef std::map<const char*, chan_t> ChannelCommandsMap;
- typedef void(*normal_t)(User* dest, User* from);
- typedef std::map<const char*, normal_t> NormalCommandsMap;
- typedef void(*opercmd_t)(User* dest, User* oper);
- typedef std::map<const char*, opercmd_t> OperCommandsMap;
- ChannelCommandsMap m_channelCommands;
- NormalCommandsMap m_normalCommands;
- OperCommandsMap m_operCommands;
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement