]>
Commit | Line | Data |
---|---|---|
1dd6d55d | 1 | /* Automatically generated by refactor.pl. |
2 | * | |
3 | * | |
4 | * CMDNAME: suspendchanlist | |
5 | * CMDLEVEL: QCMD_HELPER | |
6 | * CMDARGS: 1 | |
7 | * CMDDESC: Lists suspended channels. | |
8 | * CMDFUNC: csc_dosuspendchanlist | |
9 | * CMDPROTO: int csc_dosuspendchanlist(void *source, int cargc, char **cargv); | |
94e4d2f4 CP |
10 | * CMDHELP: Usage: suspendchanlist <pattern> |
11 | * CMDHELP: Lists all suspended channels that match the specified pattern. | |
1dd6d55d | 12 | */ |
13 | ||
14 | #include "../chanserv.h" | |
15 | #include "../../nick/nick.h" | |
16 | #include "../../lib/flags.h" | |
17 | #include "../../lib/irc_string.h" | |
18 | #include "../../channel/channel.h" | |
19 | #include "../../parser/parser.h" | |
20 | #include "../../irc/irc.h" | |
21 | #include "../../localuser/localuserchannel.h" | |
22 | #include <string.h> | |
23 | #include <stdio.h> | |
24 | ||
25 | int csc_dosuspendchanlist(void *source, int cargc, char **cargv) { | |
26 | nick *sender=source; | |
27 | reguser *rup=getreguserfromnick(sender); | |
28 | chanindex *cip; | |
29 | regchan *rcp; | |
a49c6c1c | 30 | int i, seewhom; |
c1e6c982 | 31 | char *bywhom, buf[200]; |
1dd6d55d | 32 | unsigned int count=0; |
c1e6c982 | 33 | struct tm *tmp; |
1dd6d55d | 34 | if (!rup) |
35 | return CMD_ERROR; | |
36 | ||
37 | if (cargc < 1) { | |
38 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "suspendchanlist"); | |
39 | return CMD_ERROR; | |
40 | } | |
41 | ||
a49c6c1c CP |
42 | seewhom = cs_privcheck(QPRIV_VIEWSUSPENDEDBY, sender); |
43 | if(!seewhom) | |
44 | bywhom = "(hidden)"; | |
45 | ||
1dd6d55d | 46 | chanservstdmessage(sender, QM_SUSPENDCHANLISTHEADER); |
47 | for (i=0; i<CHANNELHASHSIZE; i++) { | |
48 | for (cip=chantable[i]; cip; cip=cip->next) { | |
49 | if (!(rcp=(regchan*)cip->exts[chanservext])) | |
50 | continue; | |
51 | ||
52 | if (!CIsSuspended(rcp)) | |
53 | continue; | |
54 | ||
55 | if ((rcp->suspendby != rup->ID) && match(cargv[0], cip->name->content)) | |
56 | continue; | |
a49c6c1c CP |
57 | |
58 | if(seewhom) { | |
59 | if (rcp->suspendby == rup->ID) | |
60 | bywhom=rup->username; | |
61 | else { | |
62 | reguser *trup=findreguserbyID(rcp->suspendby); | |
63 | if (trup) | |
64 | bywhom=trup->username; | |
65 | else | |
66 | bywhom="(unknown)"; | |
67 | } | |
1dd6d55d | 68 | } |
69 | count++; | |
c1e6c982 CP |
70 | |
71 | tmp=gmtime(&(rcp->suspendtime)); | |
79313d98 | 72 | strftime(buf,sizeof(buf),Q9_FORMAT_TIME,tmp); |
c1e6c982 | 73 | |
7105fd1b | 74 | chanservsendmessage(sender, "%-30s %-15s %-15s %s", cip->name->content, bywhom, buf, rcp->suspendreason?rcp->suspendreason->content:"(no reason)"); |
1dd6d55d | 75 | if (count >= 2000) { |
76 | chanservstdmessage(sender, QM_TOOMANYRESULTS, 2000, "channels"); | |
77 | return CMD_ERROR; | |
78 | } | |
79 | } | |
80 | } | |
81 | chanservstdmessage(sender, QM_RESULTCOUNT, count, "channel", (count==1)?"":"s"); | |
82 | ||
83 | return CMD_OK; | |
84 | } |