diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bots.cpp | 2 | ||||
-rw-r--r-- | src/botserv.c | 4 | ||||
-rw-r--r-- | src/core/ss_main.c | 42 |
3 files changed, 40 insertions, 8 deletions
diff --git a/src/bots.cpp b/src/bots.cpp index 90987f279..ff95d2a1f 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -18,6 +18,7 @@ BotInfo::BotInfo(const char *nnick) this->uid = ts6_uid_retrieve(); // XXX is this safe? has ts6 been setup yet? insert_bot(this); // XXX, this is ugly, but it needs to stay until hashing of bots is redone in STL. nbots++; + this->cmdTable = NULL; } BotInfo::BotInfo(const char *nnick, const char *nuser, const char *nhost, const char *nreal) @@ -30,6 +31,7 @@ BotInfo::BotInfo(const char *nnick, const char *nuser, const char *nhost, const this->uid = ts6_uid_retrieve(); // XXX is this safe? has ts6 been setup yet? insert_bot(this); // XXX, this is ugly, but it needs to stay until hashing of bots is redone in STL. nbots++; + this->cmdTable = NULL; } BotInfo::~BotInfo() diff --git a/src/botserv.c b/src/botserv.c index 9eddfe685..32c56ca45 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -116,6 +116,10 @@ void botmsgs(User * u, BotInfo * bi, char *buf) } ircdproto->SendCTCP(bi, u->nick, "PING %s", s); } + else if (cmd && bi->cmdTable) + { + mod_run_cmd(bi->nick, u, bi->cmdTable, cmd); + } } /*************************************************************************/ diff --git a/src/core/ss_main.c b/src/core/ss_main.c index 04e58b050..273a335f9 100644 --- a/src/core/ss_main.c +++ b/src/core/ss_main.c @@ -14,31 +14,57 @@ #include "module.h" -class StatServ : public Service -{ - public: - StatServ() : Service("StatServ", ServiceUser, ServiceHost, "Stats Service") - { - } -} *statserv = NULL; +BotInfo *statserv = NULL; +CommandHash *cmdTable[MAX_CMD_HASH]; int statserv_create(int argc, char **argv); +int do_help(User *u); class SSMain : public Module { public: SSMain(const std::string &modname, const std::string &creator) : Module(modname, creator) { + Command *c; EvtHook *hook; + c = createCommand("HELP", do_help, NULL, -1, -1, -1, -1, -1); + this->AddCommand(cmdTable, c, MOD_HEAD); + hook = createEventHook(EVENT_SERVER_CONNECT, statserv_create); this->AddEventHook(hook); } + ~SSMain() + { + CommandHash *current; + Command *c; + for (int i = 0; i < MAX_CMD_HASH; i++) { + for (current = cmdTable[i]; current; current = current->next) { + for (c = current->c; c; c = c->next) + this->DelCommand(cmdTable, c->name); + } + } + if (statserv) { + ircdproto->SendQuit(statserv, "Quit due to module unload."); + delete statserv; + } + } }; int statserv_create(int argc, char **argv) { - statserv = new StatServ(); + statserv = findbot("StatServ"); + if (!statserv) { + statserv = new BotInfo("StatServ", ServiceUser, ServiceHost, "Stats Service"); + ircdproto->SendClientIntroduction("StatServ", ServiceUser, ServiceHost, "Stats Service", ircd->pseudoclient_mode, statserv->uid.c_str()); + } + statserv->cmdTable = cmdTable; + return MOD_CONT; +} + +int do_help(User *u) +{ + ircdproto->SendMessage(statserv, u->nick, "This is a test of the emergency StatServ system."); return MOD_CONT; } |