]>
Commit | Line | Data |
---|---|---|
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 "../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 | ||
18 | int lr_requestl(nick *svc, nick *np, channel *cp, nick *qnick) { | |
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, "Sorry, your 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) { | |
34 | sendnoticetouser(svc, np, "Sorry, your channel '%s' was created recently. " | |
35 | "Please try again in an hour.", cp->index->name->content); | |
36 | ||
37 | lr_noregops++; | |
38 | ||
39 | return RQ_ERROR; | |
40 | } | |
41 | ||
42 | rocount = cf_getsortedregops(cf, LR_TOPX, rolist); | |
43 | ||
44 | ro = NULL; | |
45 | ||
46 | for (i = 0; i < min(LR_TOPX, rocount); i++) { | |
47 | if (cf_cmpregopnick(rolist[i], np)) { | |
48 | ro = rolist[i]; | |
49 | break; | |
50 | } | |
51 | } | |
52 | ||
53 | if (ro == NULL) { | |
54 | sendnoticetouser(svc, np, "Sorry, you must be one of the top %d ops " | |
55 | "for the channel '%s'.", LR_TOPX, cp->index->name->content); | |
56 | ||
57 | lr_top5++; | |
58 | ||
59 | return RQ_ERROR; | |
60 | } | |
61 | ||
62 | /* treat blocked users as if their score is too low */ | |
63 | if (ro->score < LR_CFSCORE || rq_findblock(np->authname)) { | |
64 | if (rq_isspam(np)) { | |
65 | sendnoticetouser(svc, np, "Do not flood the request system. " | |
66 | "Try again in %s.", rq_longtoduration(rq_blocktime(np))); | |
67 | ||
68 | lr_floodattempts++; | |
69 | ||
70 | return RQ_ERROR; | |
71 | } | |
72 | ||
73 | sendnoticetouser(svc, np, "Sorry, you do not meet the " | |
74 | "%s request requirements; please try again in an hour, " | |
75 | "see http://www.quakenet.org/faq/faq.php?c=1&f=6#6", RQ_QNICK); | |
76 | ||
77 | lr_scoretoolow++; | |
78 | ||
79 | return RQ_ERROR; | |
80 | } | |
81 | ||
82 | ||
83 | sendmessagetouser(svc, qnick, "addchan %s #%s +jp upgrade %s", cp->index->name->content, | |
84 | np->authname, np->nick); | |
85 | ||
86 | sendnoticetouser(svc, np, "Success! %s has been added to '%s' " | |
87 | "(contact #help if you require further assistance).", | |
88 | RQ_QNICK, cp->index->name->content); | |
89 | ||
90 | return RQ_OK; | |
91 | } | |
92 | ||
93 | void lr_requeststats(nick *rqnick, nick *np) { | |
94 | sendnoticetouser(rqnick, np, "- No registered ops (Q): %d", lr_noregops); | |
95 | sendnoticetouser(rqnick, np, "- Score too low (Q): %d", lr_scoretoolow); | |
96 | sendnoticetouser(rqnick, np, "- Not in top%d (Q): %d", LR_TOPX, lr_top5); | |
97 | sendnoticetouser(rqnick, np, "- Floods (Q): %d", lr_floodattempts); | |
98 | } |