summaryrefslogtreecommitdiff
path: root/src/core/ss_main.c
diff options
context:
space:
mode:
authorcyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2008-11-30 05:50:25 +0000
committercyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2008-11-30 05:50:25 +0000
commit7f555f08e7991c5c6d10a1f1bbeda82fb5f429f3 (patch)
treefcbeeeedde9d46a54dadb494ce4d1863161ba0fd /src/core/ss_main.c
parentccb8c76295f95e0c8b6b2fd23e8007fa18cf4641 (diff)
Modified BotInfo to store a pointer to a command hash table (this is so modules like ss_main can store their own commands but still have them called by the core).
Updated the current sample of ss_main to utilize BotInfo instead of Service (which might be removed) as well as accept a HELP command. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1819 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/core/ss_main.c')
-rw-r--r--src/core/ss_main.c42
1 files changed, 34 insertions, 8 deletions
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;
}