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