]> jfr.im git - irc/quakenet/newserv.git/blob - request/lrequest.c
request: Remove user functionality.
[irc/quakenet/newserv.git] / request / lrequest.c
1 /* required modules: splitlist, chanfix(3) */
2
3 #include <stdio.h>
4 #include <string.h>
5 #include "request.h"
6 #include "lrequest.h"
7 #include "request_block.h"
8 #include "request_fasttrack.h"
9 #include "../localuser/localuser.h"
10
11 /* stats counters */
12 int lr_noregops = 0;
13 int lr_scoretoolow = 0;
14 int lr_top5 = 0;
15 int lr_floodattempts = 0;
16
17 #define min(a,b) ((a > b) ? b : a)
18
19 int lr_requestl(nick *svc, nick *np, channel *cp, nick *qnick) {
20 chanfix *cf;
21 regop *rolist[LR_TOPX], *ro;
22 int i, rocount;
23
24 if (strlen(cp->index->name->content) > LR_MAXCHANLEN) {
25 sendnoticetouser(svc, np, "Sorry, your channel name is too long. You will have to "
26 "create a channel with a name less than %d characters long.",
27 LR_MAXCHANLEN + 1);
28
29 return RQ_ERROR;
30 }
31
32 cf = cf_findchanfix(cp->index);
33
34 if(cf) {
35 rocount = cf_getsortedregops(cf, LR_TOPX, rolist);
36
37 ro = NULL;
38
39 for (i = 0; i < min(LR_TOPX, rocount); i++) {
40 if (cf_cmpregopnick(rolist[i], np)) {
41 ro = rolist[i];
42 break;
43 }
44 }
45
46 if (ro == NULL) {
47 sendnoticetouser(svc, np, "Sorry, you must be one of the top %d ops "
48 "for the channel '%s'.", LR_TOPX, cp->index->name->content);
49
50 lr_top5++;
51
52 return RQ_ERROR;
53 }
54 }
55
56 if(!rq_tryfasttrack(np)) {
57 if (cf == NULL) {
58 sendnoticetouser(svc, np, "Sorry, your channel '%s' was created recently. "
59 "Please try again in an hour.", cp->index->name->content);
60
61 lr_noregops++;
62
63 return RQ_ERROR;
64 }
65
66 /* treat blocked users as if their score is too low */
67 if (ro->score < LR_CFSCORE || rq_findblock(np->authname)) {
68 sendnoticetouser(svc, np, "Sorry, you do not meet the "
69 "%s request requirements; please try again in an hour, "
70 "see http://www.quakenet.org/faq/faq.php?c=1&f=6#6", RQ_QNICK);
71
72 lr_scoretoolow++;
73
74 return RQ_ERROR;
75 }
76 }
77
78 sendmessagetouser(svc, qnick, "addchan %s #%s +jp upgrade %s", cp->index->name->content,
79 np->authname, np->nick);
80
81 sendnoticetouser(svc, np, "Success! %s has been added to '%s' "
82 "(contact #help if you require further assistance).",
83 RQ_QNICK, cp->index->name->content);
84
85 return RQ_OK;
86 }
87
88 void lr_requeststats(nick *rqnick, nick *np) {
89 sendnoticetouser(rqnick, np, "- No registered ops (Q): %d", lr_noregops);
90 sendnoticetouser(rqnick, np, "- Score too low (Q): %d", lr_scoretoolow);
91 sendnoticetouser(rqnick, np, "- Not in top%d (Q): %d", LR_TOPX, lr_top5);
92 sendnoticetouser(rqnick, np, "- Floods (Q): %d", lr_floodattempts);
93 }