}
cmd=findcommandintree(csctcpcommands, cargv[0]+1, 1);
if (cmd) {
+ cmd->calls++;
rejoinline(cargv[1],cargc-1);
cmd->handler((void *)sender, cargc-1, &(cargv[1]));
}
break;
}
+ if ((cmd->level & QCMD_STAFF) &&
+ (!(rup=getreguserfromnick(sender)) || !UHasStaffPriv(rup))) {
+ chanservstdmessage(sender, QM_NOACCESS, cargv[0]);
+ break;
+ }
+
if ((cmd->level & QCMD_HELPER) &&
(!(rup=getreguserfromnick(sender)) || !UHasHelperPriv(rup))) {
chanservstdmessage(sender, QM_NOACCESS, cargv[0]);
break;
}
+ cmd->calls++;
+
if (cmd->maxparams < (cargc-1)) {
rejoinline(cargv[cmd->maxparams],cargc-(cmd->maxparams));
cargc=(cmd->maxparams)+1;
deletecommandfromtree(cscommands, command, handler);
}
+void chanservpartchan(channel *cp, char *reason) {
+ /* Sanity check that we exist and are on the channel.
+ *
+ * Note that we don't do any of the other usual sanity checks here; if
+ * this channel is unregged or suspended or whatever then all the more
+ * reason to get Q off it ASAP! */
+ if (!chanservnick || !cp || !cp->users || !getnumerichandlefromchanhash(cp->users, chanservnick->numeric))
+ return;
+
+ localpartchannel(chanservnick, cp, reason);
+}
+
void chanservjoinchan(channel *cp) {
regchan *rcp;
unsigned int i;
if (!chanservnick)
return;
+ /* In gerenal this function shouldn't be used any more as a reason to get
+ * Q to leave, but if it should be leaving then just part with no reason. */
if ((CIsSuspended(rcp) || !CIsJoined(rcp)) && getnumerichandlefromchanhash(cp->users, chanservnick->numeric)) {
- if(rcp->suspendreason) {
- localpartchannel(chanservnick, cp, rcp->suspendreason->content);
- } else {
- localpartchannel(chanservnick, cp, NULL);
- }
+ localpartchannel(chanservnick, cp, NULL);
}
/* Right, we are definately going to either join the channel or at least
va_list va;
nick *np;
unsigned int i=0;
-
+
va_start(va,message);
vsnprintf(buf,5000,message,va);
va_end(va);
/* Scan for users */
- for (i=0;i<NICKHASHSIZE;i++)
- for (np=nicktable[i];np;np=np->next)
- if (IsOper(np))
- chanservsendmessage(np, "%s", buf);
+ for (i=0;i<NICKHASHSIZE;i++) {
+ for (np=nicktable[i];np;np=np->next) {
+ if (!IsOper(np)) /* optimisation, if VIEWWALLMESSAGE changes change this */
+ continue;
+
+ if (!cs_privcheck(QPRIV_VIEWWALLMESSAGE, np))
+ continue;
+
+ chanservsendmessage(np, "%s", buf);
+ }
+ }
}
void chanservkillstdmessage(nick *target, int messageid, ... ) {
rup->created=time(NULL);
rup->lastauth=0;
rup->lastemailchange=0;
+ rup->lastpasschange=0;
rup->flags=QUFLAG_NOTICE;
rup->languageid=0;
rup->suspendby=0;
continue;
if ((np=getnickbynumeric(cp->users->content[i]))==NULL) {
- Error("chanserv",ERR_ERROR,"Found non-existent numeric %d on channel %s",cp->users->content[i],
+ Error("chanserv",ERR_ERROR,"Found non-existent numeric %lu on channel %s",cp->users->content[i],
cp->index->name->content);
continue;
}
continue;
if ((np=getnickbynumeric(cp->users->content[i]))==NULL) {
- Error("chanserv",ERR_ERROR,"Found numeric %d on channel %s who doesn't exist.",
+ Error("chanserv",ERR_ERROR,"Found numeric %lu on channel %s who doesn't exist.",
cp->users->content[i], cp->index->name->content);
continue;
}
localsetmodeflush(&changes, 1);
}
-void cs_removechannel(regchan *rcp) {
+void cs_removechannel(regchan *rcp, char *reason) {
int i;
chanindex *cip;
regchanuser *rcup, *nrcup;
deleteschedule(rcp->checksched, cs_timerfunc, rcp->index);
if (cip->channel) {
- rcp->flags=QCFLAG_SUSPENDED;
- chanservjoinchan(cip->channel); /* Force off the channel */
+ chanservpartchan(cip->channel, reason);
}
csdb_deletechannel(rcp);
}
cs_log(sender,"DELCHAN %s (Empty)",rcp->index->name->content);
- cs_removechannel(rcp);
+ cs_removechannel(rcp, "Last user removed - channel deleted.");
return 1;
}
}
if (!(rup=findreguserbynick(str+1)) && sender)
chanservstdmessage(sender, QM_UNKNOWNUSER, str);
- } else if (*str=='&' && vrup && UHasHelperPriv(vrup)) {
+ } else if (*str=='&' && vrup && UHasStaffPriv(vrup)) {
if (str[1]=='\0') {
if (sender)
chanservstdmessage(sender, QM_UNKNOWNUSER, str);
rcp->chanopaccts[rcp->chanoppos]=rup->ID;
rcp->chanoppos=(rcp->chanoppos+1)%CHANOPHISTORY;
}
+
+int checkreason(nick *np, char *reason) {
+ if((strlen(reason) < MIN_REASONLEN) || !strchr(reason, ' ')) {
+ chanservstdmessage(np, QM_REASONREQUIRED);
+ return 0;
+ }
+
+ return 1;
+}