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