]>
Commit | Line | Data |
---|---|---|
1dd6d55d | 1 | /* Automatically generated by refactor.pl. |
2 | * | |
3 | * | |
4 | * CMDNAME: banlist | |
5 | * CMDLEVEL: QCMD_AUTHED | |
6 | * CMDARGS: 1 | |
7 | * CMDDESC: Displays all persistent bans on a channel. | |
8 | * CMDFUNC: csc_dobanlist | |
9 | * CMDPROTO: int csc_dobanlist(void *source, int cargc, char **cargv); | |
cabd7271 | 10 | * CMDHELP: Usage: BANLIST <channel> |
11 | * CMDHELP: Displays a list of persistent and channel bans on the named channel. Each ban | |
12 | * CMDHELP: is identified by a number which can be passed to a subsequent BANDEL command. | |
13 | * CMDHELP: Note that the numbers can change if bans are added to or removed from the | |
e89c6fc6 | 14 | * CMDHELP: channel. Where: |
cabd7271 | 15 | * CMDHELP: channel - the channel to use |
16 | * CMDHELP: BANLIST requires operator (+o) access on the named channel. | |
1dd6d55d | 17 | */ |
18 | ||
19 | #include "../chanserv.h" | |
20 | #include "../../nick/nick.h" | |
21 | #include "../../lib/flags.h" | |
22 | #include "../../lib/irc_string.h" | |
23 | #include "../../channel/channel.h" | |
24 | #include "../../parser/parser.h" | |
25 | #include "../../irc/irc.h" | |
26 | #include "../../localuser/localuserchannel.h" | |
27 | #include <string.h> | |
28 | #include <stdio.h> | |
29 | ||
30 | int csc_dobanlist(void *source, int cargc, char **cargv) { | |
31 | nick *sender=source; | |
32 | chanindex *cip; | |
33 | regchan *rcp; | |
34 | regban *rbp; | |
35 | reguser *rup; | |
36 | chanban *cbp; | |
37 | int i=0; | |
38 | int exp; | |
39 | ||
40 | if (cargc<1) { | |
41 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "banlist"); | |
42 | return CMD_ERROR; | |
43 | } | |
44 | ||
45 | if(!(cip=cs_checkaccess(sender, cargv[0], CA_OPPRIV, NULL, "banlist", 0, 0))) | |
46 | return CMD_ERROR; | |
47 | ||
48 | rcp=cip->exts[chanservext]; | |
49 | ||
d0d9d182 | 50 | if (rcp->bans || (cip->channel && cip->channel->bans)) { |
1dd6d55d | 51 | chanservstdmessage(sender, QM_REGBANHEADER, cip->name->content); |
52 | for(rbp=rcp->bans;rbp;rbp=rbp->next) { | |
53 | rup=findreguserbyID(rbp->setby); | |
54 | chanservsendmessage(sender," #%-2d %-29s %-18s %-15s %s",++i,bantostring(rbp->cbp), | |
55 | rbp->expiry?longtoduration(rbp->expiry-time(NULL),0):"Permanent", | |
56 | rup?rup->username:"<unknown>", | |
57 | rbp->reason?rbp->reason->content:""); | |
58 | } | |
cabd7271 | 59 | if (cip->channel) { |
60 | for (cbp=cip->channel->bans;cbp;cbp=cbp->next) { | |
61 | for (rbp=rcp->bans;rbp;rbp=rbp->next) { | |
62 | if (banequal(rbp->cbp, cbp)) | |
63 | break; | |
64 | } | |
65 | if (!rbp) { | |
66 | if (rcp->banduration) { | |
67 | exp=(cbp->timeset + rcp->banduration) - time(NULL); | |
68 | } else { | |
69 | exp=0; | |
70 | } | |
71 | chanservsendmessage(sender, " #%-2d %-29s %-18s %-15s",++i,bantostring(cbp), | |
72 | exp ? longtoduration(exp,0) : "Permanent", | |
73 | "(channel ban)"); | |
74 | } | |
1dd6d55d | 75 | } |
76 | } | |
77 | chanservstdmessage(sender, QM_ENDOFLIST); | |
78 | } else { | |
79 | chanservstdmessage(sender, QM_NOBANS, cip->name->content); | |
80 | } | |
81 | ||
82 | return CMD_OK; | |
83 | } |