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=999;
hooknick=(nick *)sender;
if (cargc>0) {
level=strtoul(cargv[0],NULL,10);
}
-
+
registerhook(HOOK_CORE_STATSREPLY,&handlestats);
+
triggerhook(HOOK_CORE_STATSREQUEST,(void *)level);
deregisterhook(HOOK_CORE_STATSREPLY,&handlestats);
return CMD_OK;
if (target->umodes) {
controlreply((nick *)sender,"Umode(s) : %s",printflags(target->umodes,umodeflags));
}
+ if (IsOper(target) && target->opername)
+ controlreply((nick *)sender,"Opered as : %s",target->opername->content);
if (IsAccount(target)) {
controlreply((nick *)sender,"Account : %s",target->authname);
if (target->accountts)
controlreply((nick *)sender,"AccountTS : %ld",target->accountts);
+ if (target->auth) {
+ controlreply((nick *)sender,"UserID : %ld",target->auth->userid);
+ if (target->auth->flags)
+ controlreply((nick *)sender,"AccFlags : %s",printflags(target->auth->flags,accountflags));
+ }
}
hooknick=(nick *)sender;
controlreply((nick *)sender,"You must give a reason.");
return CMD_USAGE;
}
+
+ controlwall(NO_OPER,NL_OPERATIONS,"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) {
chanban *cbp;
char buf[BUFSIZE];
char buf2[12];
- int i,j;
-
+ int i,j, ops=0, voice=0;
+ 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);
+ } else {
+ controlreply((nick *)sender,"Topic : (none)");
}
controlreply((nick *)sender,"Mode(s) : %s %s%s%s",printflags(cp->flags,cmodeflags),IsLimit(cp)?buf2:"",
IsLimit(cp)?" ":"",IsKey(cp)?cp->key->content:"");
break;
}
if (cp->users->content[j]!=nouser) {
+ if (cp->users->content[j]&CUMODE_OP)
+ ops++;
+ else if (cp->users->content[j]&CUMODE_VOICE)
+ voice++;
np=getnickbynumeric(cp->users->content[j]);
sprintf(&buf[i*18],"%c%c%-15s ",cp->users->content[j]&CUMODE_VOICE?'+':' ',
cp->users->content[j]&CUMODE_OP?'@':' ', np?np->nick:"!BUG-NONICK!");
buf[i*18]=' ';
}
}
-
+ controlreply((nick *)sender, "Users : Opped: %d, Voiced: %d", ops,voice);
for (cbp=cp->bans;cbp;cbp=cbp->next) {
controlreply((nick *)sender,"Ban : %s",bantostringdebug(cbp));
}
if (IsOper(np))
controlnotice(np, "%s", broadcast);
}
+
+void controlnswall(int noticelevel, char *format, ...) {
+ char broadcast[512];
+ va_list va;
+
+ va_start(va, format);
+ vsnprintf(broadcast, sizeof(broadcast), format, va);
+ va_end(va);
+
+ controlwall(NO_OPER, noticelevel, "%s", broadcast);
+}
+