]>
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" | |
6fec1818 | 8 | #include "request_fasttrack.h" |
25b7d0fa P |
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 | ||
95440fe7 | 19 | int lr_requestl(nick *svc, nick *np, channel *cp, nick *qnick) { |
25b7d0fa P |
20 | chanfix *cf; |
21 | regop *rolist[LR_TOPX], *ro; | |
22 | int i, rocount; | |
23 | ||
24 | if (strlen(cp->index->name->content) > LR_MAXCHANLEN) { | |
43d341bd | 25 | sendnoticetouser(svc, np, "Sorry, your channel name is too long. You will have to " |
25b7d0fa P |
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 | ||
6fec1818 GB |
34 | if(cf) { |
35 | rocount = cf_getsortedregops(cf, LR_TOPX, rolist); | |
25b7d0fa | 36 | |
6fec1818 | 37 | ro = NULL; |
25b7d0fa | 38 | |
6fec1818 GB |
39 | for (i = 0; i < min(LR_TOPX, rocount); i++) { |
40 | if (cf_cmpregopnick(rolist[i], np)) { | |
41 | ro = rolist[i]; | |
42 | break; | |
43 | } | |
25b7d0fa | 44 | } |
25b7d0fa | 45 | |
6fec1818 GB |
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); | |
25b7d0fa | 49 | |
6fec1818 | 50 | lr_top5++; |
25b7d0fa | 51 | |
6fec1818 GB |
52 | return RQ_ERROR; |
53 | } | |
25b7d0fa P |
54 | } |
55 | ||
6fec1818 GB |
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); | |
25b7d0fa | 60 | |
6fec1818 | 61 | lr_noregops++; |
25b7d0fa P |
62 | |
63 | return RQ_ERROR; | |
64 | } | |
65 | ||
6fec1818 GB |
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); | |
25b7d0fa | 71 | |
6fec1818 | 72 | lr_scoretoolow++; |
25b7d0fa | 73 | |
6fec1818 GB |
74 | return RQ_ERROR; |
75 | } | |
25b7d0fa | 76 | } |
95440fe7 P |
77 | |
78 | sendmessagetouser(svc, qnick, "addchan %s #%s +jp upgrade %s", cp->index->name->content, | |
25b7d0fa P |
79 | np->authname, np->nick); |
80 | ||
43d341bd C |
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); | |
25b7d0fa P |
84 | |
85 | return RQ_OK; | |
86 | } | |
87 | ||
88 | void lr_requeststats(nick *rqnick, nick *np) { | |
95440fe7 P |
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); | |
25b7d0fa | 93 | } |