void rq_registeruser(void) {
channel *cp;
- rqnick = registerlocaluser(RQ_REQUEST_NICK, RQ_REQUEST_USER, RQ_REQUEST_HOST,
- RQ_REQUEST_REAL, RQ_REQUEST_AUTH,
+ rqnick = registerlocaluserflags(RQ_REQUEST_NICK, RQ_REQUEST_USER, RQ_REQUEST_HOST,
+ RQ_REQUEST_REAL, RQ_REQUEST_AUTH, 1780711, 0,
UMODE_ACCOUNT | UMODE_SERVICE | UMODE_OPER,
rq_handler);
return 0;
}
-int rq_genericrequestcheck(nick *np, char *channelname, channel **cp, nick **lnick, nick **qnick) {
+int rq_genericrequestcheck(nick *np, char *channelname, channel **cp, nick **qnick) {
unsigned long *userhand;
rq_block *block;
if (!IsAccount(np)) {
- sendnoticetouser(rqnick, np, "Error: You must be authed.");
+ sendnoticetouser(rqnick, np, "Error: You must be authed to perform a service request.");
return RQ_ERROR;
}
*cp = findchannel(channelname);
if (*cp == NULL) {
- sendnoticetouser(rqnick, np, "Error: Channel %s does not exist.",
+ sendnoticetouser(rqnick, np, "Error: Channel '%s' does not exist on the network.",
channelname);
return RQ_ERROR;
}
- *lnick = getnickbynick(RQ_LNICK);
-
- if (*lnick == NULL || findserver(RQ_LSERVER) < 0) {
- sendnoticetouser(rqnick, np, "Error: %s does not seem to be online. "
- "Try again later.", RQ_LNICK);
-
- return RQ_ERROR;
- }
-
*qnick = getnickbynick(RQ_QNICK);
if (*qnick == NULL || findserver(RQ_QSERVER) < 0) {
sendnoticetouser(rqnick, np, "Error: %s does not seem to be online. "
- "Try again later.", RQ_QNICK);
+ "Please try again later.", RQ_QNICK);
return RQ_ERROR;
}
/* only say when block expires if <7 days */
if ( block->expires < getnettime() + 3600 * 24 * 7) {
sendnoticetouser(rqnick, np, "Error: You are not allowed to request a "
- "service to this channel. Keep waiting for at least %s before you try again.",
- rq_longtoduration(block->expires - getnettime()));
+ "service to '%s'. Keep waiting for at least %s before you try again.",
+ channelname, rq_longtoduration(block->expires - getnettime()));
/* give them another 5 minutes to think about it */
block->expires += 300;
rq_saveblocks();
} else {
sendnoticetouser(rqnick, np, "Error: You are not allowed to request a "
- "service to this channel.");
+ "service to '%s'.", channelname);
}
sendnoticetouser(rqnick, np, "Reason: %s", block->reason->content);
int rqcmd_request(void *user, int cargc, char **cargv) {
nick *np = (nick*)user;
- nick *lnick, *qnick;
- unsigned long *lhand, *qhand;
+ nick *qnick;
+ unsigned long *qhand;
channel *cp;
int retval;
time_t now_ts;
rq_count++;
- if (rq_genericrequestcheck(np, cargv[0], &cp, &lnick, &qnick) == RQ_ERROR) {
+ if (rq_genericrequestcheck(np, cargv[0], &cp, &qnick) == RQ_ERROR) {
rq_failed++;
return RQ_ERROR;
}
- lhand = getnumerichandlefromchanhash(cp->users, lnick->numeric);
-
qhand = getnumerichandlefromchanhash(cp->users, qnick->numeric);
if (qhand != NULL) {
retval = RQ_ERROR;
- if (lhand == NULL && qhand == NULL) {
- /* try 'instant' Q request */
- retval = qr_instantrequestq(np, cp);
- }
-
- if (retval == RQ_ERROR) {
- if (lhand == NULL) {
- /* user 'wants' L */
-
- retval = lr_requestl(rqnick, np, cp, lnick);
+ retval = lr_requestl(rqnick, np, cp, qnick);
- if (rq_logfd != NULL) {
- now[0] = '\0';
- now_ts = time(NULL);
- strftime(now, sizeof(now), "%c", localtime(&now_ts));
+ if (rq_logfd != NULL) {
+ now[0] = '\0';
+ now_ts = time(NULL);
+ strftime(now, sizeof(now), "%c", localtime(&now_ts));
- fprintf(rq_logfd, "%s: request (%s) for %s from %s: Request was %s.\n", now, RQ_LNICK, cp->index->name->content, np->nick, (retval == RQ_OK) ? "accepted" : "denied");
- fflush(rq_logfd);
- }
- } else {
- /* user 'wants' Q */
-
- retval = qr_requestq(rqnick, np, cp, lnick, qnick);
- }
+ fprintf(rq_logfd, "%s: request (%s) for %s from %s!%s@%s%s%s: Request was %s.\n",
+ now, RQ_QNICK, cp->index->name->content,
+ np->nick, np->ident, np->host->name->content, IsAccount(np)?"/":"", IsAccount(np)?np->authname:"",
+ (retval == RQ_OK) ? "accepted" : "denied");
+ fflush(rq_logfd);
}
if (retval == RQ_ERROR)
int rqcmd_requestspamscan(void *user, int cargc, char **cargv) {
nick *np = (nick*)user;
channel *cp;
- nick *lnick, *qnick, *snick;
- unsigned long *lhand, *qhand, *shand;
+ nick *qnick, *snick;
+ unsigned long *qhand, *shand;
int retval;
if (cargc < 1) {
rq_count++;
- if (rq_genericrequestcheck(np, cargv[0], &cp, &lnick, &qnick) == RQ_ERROR) {
+ if (rq_genericrequestcheck(np, cargv[0], &cp, &qnick) == RQ_ERROR) {
rq_failed++;
return RQ_ERROR;
if (snick == NULL || findserver(RQ_SSERVER) < 0) {
sendnoticetouser(rqnick, np, "Error: %s does not seem to be online. "
- "Try again later.", RQ_SNICK);
+ "Please try again later.", RQ_SNICK);
rq_failed++;
return RQ_ERROR;
}
- /* we need either L or Q */
- lhand = getnumerichandlefromchanhash(cp->users, lnick->numeric);
+ /* we need Q */
qhand = getnumerichandlefromchanhash(cp->users, qnick->numeric);
- if (lhand || qhand) {
+ if (qhand) {
/* great, now try to request */
- retval = qr_requests(rqnick, np, cp, lnick, qnick);
+ retval = qr_requests(rqnick, np, cp, qnick);
if (retval == RQ_OK)
rq_success++;
return retval;
} else {
- /* channel apparently doesn't have L or Q */
+ /* channel apparently doesn't have Q */
- sendnoticetouser(rqnick, np, "Error: You need %s or %s in order to be "
- "able to request %s.", RQ_LNICK, RQ_QNICK, RQ_SNICK);
+ sendnoticetouser(rqnick, np, "Error: You need %s in order to be "
+ "able to request %s.", RQ_QNICK, RQ_SNICK);
rq_failed++;
cp = findchannel(cargv[0]);
if (cp == NULL) {
- sendnoticetouser(rqnick, np, "Error: No such channel.");
+ sendnoticetouser(rqnick, np, "Error: Channel '%s' does not exist on the network.",
+ cargv[0]);
return CMD_ERROR;
}
hand = getnumerichandlefromchanhash(cp->users, user->numeric);
if (!hand) {
- sendnoticetouser(rqnick, np, "Error: User %s is not on channel %s.", user->nick, cargv[0]);
+ sendnoticetouser(rqnick, np, "Error: User %s is not on channel '%s'.", user->nick, cargv[0]);
return CMD_ERROR;
}
for (a=0;a<cp->users->hashsize;a++) {
if ((cp->users->content[a] != nouser) && (cp->users->content[a] & CUMODE_OP)) {
- sendnoticetouser(rqnick, np, "There are ops on channel %s. This command can only be"
+ sendnoticetouser(rqnick, np, "There are ops on channel '%s'. This command can only be"
" used if there are no ops.", cargv[0]);
return CMD_ERROR;
}
}
- if (sp_countsplitservers() > 0) {
+ if (sp_countsplitservers(SERVERTYPEFLAG_USER_STATE) > 0) {
sendnoticetouser(rqnick, np, "One or more servers are currently split. Wait until the"
" netsplit is over and try again.");