]> jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chancmds/suspendchanlist.c
Merge.
[irc/quakenet/newserv.git] / chanserv / chancmds / suspendchanlist.c
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);
10 * CMDHELP: Usage: suspendchanlist <pattern>
11 * CMDHELP: Lists all suspended channels that match the specified pattern.
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;
30 int i, seewhom;
31 char *bywhom, buf[TIMELEN];
32 unsigned int count=0;
33 if (!rup)
34 return CMD_ERROR;
35
36 if (cargc < 1) {
37 chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "suspendchanlist");
38 return CMD_ERROR;
39 }
40
41 seewhom = cs_privcheck(QPRIV_VIEWSUSPENDEDBY, sender);
42 if(!seewhom)
43 bywhom = "(hidden)";
44
45 /* @TIMELEN */
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;
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 }
68 }
69 count++;
70
71 q9strftime(buf,sizeof(buf),rcp->suspendtime);
72
73 /* @TIMELEN */
74 chanservsendmessage(sender, "%-30s %-15s %-19s %s", cip->name->content, bywhom, buf, rcp->suspendreason?rcp->suspendreason->content:"(no reason)");
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 }