]> jfr.im git - irc/quakenet/newserv.git/blame - chanserv/chancmds/chanophistory.c
Merge chanserv-live into default.
[irc/quakenet/newserv.git] / chanserv / chancmds / chanophistory.c
CommitLineData
0dc8c584 1/*
2 * CMDNAME: chanophistory
3 * CMDLEVEL: QCMD_AUTHED
4 * CMDARGS: 1
5 * CMDDESC: Displays a list of who has been opped on a channel recently with account names.
6 * CMDFUNC: csc_dochanophistory
7 * CMDPROTO: int csc_dochanophistory(void *source, int cargc, char **cargv);
8 * CMDHELP: Usage: CHANOPHISTORY <channel>
9 * CMDHELP: Displays a list of users who have recently been opped on a channel by the
10 * CMDHELP: service, along with the account name responsible for the opping. Usually
11 * CMDHELP: this is the account the user being opped was using, but in the case of the
12 * CMDHELP: OP command being used to op other users, the account used by the user issuing
13 * CMDHELP: the OP command will be shown. Where:
14 * CMDHELP: channel - the channel to use
15 * CMDHELP: CHANOPHISTORY requires operator (+o) access on the named channel.
16 */
17
18#include "../chanserv.h"
19
20int csc_dochanophistory(void *source, int cargc, char **cargv) {
21 nick *sender=source;
22 chanindex *cip;
23 regchan *rcp;
24 reguser *opact;
25 unsigned int i;
26 unsigned int found=0;
27
28 if (cargc<1) {
29 chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "chanophistory");
30 return CMD_ERROR;
31 }
32
33 if (!(cip=cs_checkaccess(sender, cargv[0], CA_OPPRIV, NULL, "chanophistory",
34 QPRIV_VIEWFULLCHANLEV, 0)))
35 return CMD_ERROR;
36
37 rcp=cip->exts[chanservext];
38
39 for (i=0;i<CHANOPHISTORY;i++) {
40 unsigned int idx=(i+rcp->chanoppos)%CHANOPHISTORY;
41
42 if (!*rcp->chanopnicks[idx])
43 continue;
44
45 if (!found) {
46 chanservstdmessage(sender, QM_CHANOPHISTORYHEADER, cip->name->content);
47 found=1;
48 }
49
50 opact=findreguserbyID(rcp->chanopaccts[idx]);
51 chanservsendmessage(sender, "%-15s %-15s", rcp->chanopnicks[idx], opact?opact->username:"(unknown)");
52 }
53 if (!found) {
54 chanservstdmessage(sender, QM_NOCHANOPHISTORY, cip->name->content);
55 } else {
56 chanservstdmessage(sender, QM_ENDOFLIST);
57 }
58
59 return CMD_OK;
60}