scheduleoneshot(time(NULL)+1,&controlconnect,NULL);
}
+void _fini() {
+ deleteallschedules(&controlconnect);
+ if (mynick) {
+ deregisterlocaluser(mynick,"Leaving");
+ }
+
+ deregistercontrolcmd("status",&controlstatus);
+ deregistercontrolcmd("whois",&controlwhois);
+ deregistercontrolcmd("channel",&controlchannel);
+ deregistercontrolcmd("relink",&relink);
+ deregistercontrolcmd("die",&die);
+ deregistercontrolcmd("insmod",&controlinsmod);
+ deregistercontrolcmd("rmmod",&controlrmmod);
+ deregistercontrolcmd("lsmod",&controllsmod);
+ deregistercontrolcmd("rehash",&controlrehash);
+ deregistercontrolcmd("showcommands",&controlshowcommands);
+ deregistercontrolcmd("reload",&controlreload);
+ deregistercontrolcmd("help",&controlhelpcmd);
+
+ destroycommandtree(controlcmds);
+}
+
void registercontrolhelpcmd(const char *name, int level, int maxparams, CommandHandler handler, char *help) {
addcommandhelptotree(controlcmds,name,level,maxparams,handler,help);
}
myrealname=getcopyconfigitem("control","realname","NewServ Control Service",REALLEN);
myauthname=getcopyconfigitem("control","authname","C",ACCOUNTLEN);
- mynick=registerlocaluser(cnick->content,myident->content,myhost->content,myrealname->content,myauthname->content,UMODE_SERVICE|UMODE_DEAF|UMODE_OPER|UMODE_ACCOUNT,&handlemessages);
+ mynick=registerlocaluser(cnick->content,myident->content,myhost->content,myrealname->content,myauthname->content,UMODE_SERVICE|UMODE_DEAF|UMODE_OPER|UMODE_ACCOUNT|UMODE_INV,&handlemessages);
triggerhook(HOOK_CONTROL_REGISTERED, mynick);
cp=findchannel("#twilightzone");
if (!cp) {
}
int controlstatus(void *sender, int cargc, char **cargv) {
- unsigned int level=5;
+ unsigned long level=5;
hooknick=(nick *)sender;
int controlreload(void *sender, int cargc, char **cargv) {
if (cargc<1)
return CMD_USAGE;
+
+ controlreply((nick *)sender,"Imma gonna try and reload %s",cargv[0]);
- preparereload(cargv[0]);
- controlrmmod(sender, cargc, cargv);
- controlinsmod(sender, cargc, cargv);
- reloadmarked();
+ safereload(cargv[0]);
return CMD_OK;
-}
+}
int relink(void *sender, int cargc, char **cargv) {
if (cargc<1) {
controlreply((nick *)sender,"You must give a reason.");
return CMD_USAGE;
}
+
+ controlwall(0,0,"DIE from %s: %s",((nick *)sender)->nick, cargv[0]);
- irc_send("%s SQ %s 0 :%s",mynumeric->content,myserver->content,cargv[0]);
- irc_disconnected();
+ newserv_shutdown_pending=1;
- exit(0);
+ return CMD_OK;
}
int controlchannel(void *sender, int cargc, char **cargv) {
char buf[BUFSIZE];
char buf2[12];
int i,j;
-
+ char timebuf[30];
+
if (cargc<1)
return CMD_USAGE;
}
controlreply((nick *)sender,"Channel : %s",cp->index->name->content);
+ strftime(timebuf, 30, "%d/%m/%y %H:%M", localtime(&(cp->timestamp)));
+ controlreply((nick *)sender,"C-time : %ld [%s]",cp->timestamp,timebuf);
if (cp->topic) {
controlreply((nick *)sender,"Topic : %s",cp->topic->content);
- controlreply((nick *)sender,"T-time : %ld [%s]",cp->topictime,ctime(&(cp->topictime)));
+ strftime(timebuf, 30, "%d/%m/%y %H:%M", localtime(&(cp->topictime)));
+ controlreply((nick *)sender,"T-time : %ld [%s]",cp->topictime,timebuf);
}
controlreply((nick *)sender,"Mode(s) : %s %s%s%s",printflags(cp->flags,cmodeflags),IsLimit(cp)?buf2:"",
IsLimit(cp)?" ":"",IsKey(cp)?cp->key->content:"");
buf[i*18]=' ';
}
}
-
+
for (cbp=cp->bans;cbp;cbp=cbp->next) {
controlreply((nick *)sender,"Ban : %s",bantostringdebug(cbp));
}
a->schedule = NULL;
sstring *froo = a->modulename;
- preparereload(free->content);
- rmmod(froo->content);
- insmod(froo->content);
- reloadmarked();
+ safereload(froo->content);
freesstring(froo);
}