sstring **chantypes;
sstring *cs_quitreason;
-const flag rcflags[] = {
- { 'a', QCFLAG_AUTOOP },
- { 'b', QCFLAG_BITCH },
- { 'c', QCFLAG_AUTOLIMIT },
- { 'e', QCFLAG_ENFORCE },
- { 'f', QCFLAG_FORCETOPIC },
- { 'g', QCFLAG_AUTOVOICE },
- { 'i', QCFLAG_INFO },
- { 'j', QCFLAG_JOINED },
- { 'k', QCFLAG_KNOWNONLY },
- { 'p', QCFLAG_PROTECT },
- { 's', QCFLAG_NOINFO },
- { 't', QCFLAG_TOPICSAVE },
- { 'v', QCFLAG_VOICEALL },
- { 'w', QCFLAG_WELCOME },
- { 'z', QCFLAG_SUSPENDED },
- { '\0', 0 } };
-
-const flag rcuflags[] = {
- { 'a', QCUFLAG_AUTOOP },
- { 'b', QCUFLAG_BANNED },
- { 'd', QCUFLAG_DENY },
- { 'g', QCUFLAG_AUTOVOICE },
- { 'i', QCUFLAG_INFO },
- { 'j', QCUFLAG_AUTOINVITE },
- { 'k', QCUFLAG_KNOWN },
- { 'm', QCUFLAG_MASTER },
- { 'n', QCUFLAG_OWNER },
- { 'o', QCUFLAG_OP },
- { 'p', QCUFLAG_PROTECT },
- { 'q', QCUFLAG_QUIET },
- { 's', QCUFLAG_NOINFO },
- { 't', QCUFLAG_TOPIC },
- { 'v', QCUFLAG_VOICE },
- { 'w', QCUFLAG_HIDEWELCOME },
- { '\0', 0 } };
-
-const flag ruflags[] = {
- { 'a', QUFLAG_ADMIN },
- { 'd', QUFLAG_DEV },
- { 'D', QUFLAG_CLEANUPEXEMPT },
- { 'g', QUFLAG_GLINE },
- { 'G', QUFLAG_DELAYEDGLINE },
- { 'h', QUFLAG_HELPER },
- { 'i', QUFLAG_INFO },
- { 'L', QUFLAG_NOAUTHLIMIT },
- { 'n', QUFLAG_NOTICE },
- { 'o', QUFLAG_OPER },
- { 'p', QUFLAG_PROTECT },
- { 'q', QUFLAG_STAFF },
- { 's', QUFLAG_NOINFO },
- { 'T', QUFLAG_TRUST },
- { 'z', QUFLAG_SUSPENDED },
- { '\0', 0 } };
-
-const flag mdflags[] = {
- { 'l', MDFLAG_LIMIT },
- { 'b', MDFLAG_BANNED },
- { 'u', MDFLAG_ACTLIMIT },
- { '\0', 0 } };
-
void chanservfreestuff();
void chanservfinishinit(int hooknum, void *arg);
+static void cs_hourlyfunc(void *arg);
DBModuleIdentifier q9dbid;
chantypes[5]=getsstring("gamesite",20);
chantypes[6]=getsstring("game",20);
chantypes[7]=getsstring("upgrade",20);
+ chantypes[8]=getsstring("partner",20);
/* And the log system */
cs_initlog();
/* Schedule the dumps */
schedulerecurring(time(NULL)+DUMPINTERVAL,0,DUMPINTERVAL,chanservdumpstuff,NULL);
+ schedulerecurring(time(NULL)+5,0,5,csdb_flushchannelcounters,NULL);
chanserv_init_status = CS_INIT_NOUSER;
chanserv_init_status = CS_INIT_READY;
triggerhook(HOOK_CHANSERV_RUNNING, NULL);
+
+ /* run every 60 minutes, first one 5 minutes after start */
+ schedulerecurring(time(NULL)+60*5,0,3600,cs_hourlyfunc,NULL);
+
Error("chanserv",ERR_INFO,"Ready to roll.");
}
void _fini() {
+ csdb_flushchannelcounters(NULL);
+
dbfreeid(q9dbid);
+ deleteallschedules(cs_hourlyfunc);
deleteallschedules(cs_timerfunc);
deleteallschedules(chanservreguser);
deleteallschedules(chanservdumpstuff);
deleteallschedules(chanservdgline);
+ deleteallschedules(csdb_flushchannelcounters);
if (chanservext>-1 && chanservnext>-1 && chanservaext>-1) {
int i;
cs_closelog();
}
+
+static void cs_hourlyfunc(void *arg) {
+ int i, total = 0, touched = 0, toorecent = 0;
+ chanindex *cip, *ncip;
+ regchan *rcp;
+ time_t t = time(NULL);
+
+ for (i=0;i<CHANNELHASHSIZE;i++) {
+ for (cip=chantable[i];cip;cip=ncip) {
+ ncip=cip->next;
+ if (!(rcp=cip->exts[chanservext]))
+ continue;
+
+ total++;
+
+ if(cip->channel && cs_ischannelactive(cip->channel, rcp)) {
+ rcp->lastactive = t;
+ if (rcp->lastcountersync < (t - COUNTERSYNCINTERVAL)) {
+ csdb_updatechannelcounters(rcp);
+ rcp->lastcountersync=t;
+ touched++;
+ } else {
+ toorecent++;
+ }
+ }
+
+ }
+ }
+ cs_log(NULL,"hourly update active completed, %d seen, %d touched, %d too recent to update.",total,touched,toorecent);
+}