]> jfr.im git - irc/quakenet/newserv.git/blob - request/lrequest.c
ac1d53a074601ae053233e8cb1f026f5158f1a7f
[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 "../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 *lnick) {
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) {
34 sendnoticetouser(svc, np, "Error: Sorry, Your channel '%s' was created recently. Please Try again in an hour.", cp->index->name->content);
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) {
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);
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
72 sendnoticetouser(svc, np, "Sorry You do not meet the "
73 "requirements to request L. Please Try again in an hour. "
74 "(see http://www.quakenet.org/faq/faq.php?c=3&f=112 )");
75
76 lr_scoretoolow++;
77
78 return RQ_ERROR;
79 }
80
81 sendmessagetouser(svc, lnick, "addchan %s #%s %s", cp->index->name->content,
82 np->authname, np->nick);
83
84 sendnoticetouser(svc, np, "Requirements met, L should be added. Contact #help"
85 " should further assistance be required.");
86
87 return RQ_OK;
88 }
89
90 void lr_requeststats(nick *rqnick, nick *np) {
91 sendnoticetouser(rqnick, np, "- No registered ops (L): %d", lr_noregops);
92 sendnoticetouser(rqnick, np, "- Score too low (L): %d", lr_scoretoolow);
93 sendnoticetouser(rqnick, np, "- Not in top%d (L): %d", LR_TOPX, lr_top5);
94 sendnoticetouser(rqnick, np, "- Floods (L): %d", lr_floodattempts);
95 }