]> jfr.im git - irc/quakenet/newserv.git/blame - miscreply/privs.c
TRUSTS: require sqlite
[irc/quakenet/newserv.git] / miscreply / privs.c
CommitLineData
7bec4aeb 1/* privs.c */
2
3#include "miscreply.h"
7bec4aeb 4#include "../irc/irc.h"
5#include "../core/error.h"
7bec4aeb 6
7
8
9/* handle remote privs request
10 *
11 * <source numeric> PRIVS/PR <target user numeric>
12 *
13 * cargv[0] = target user numeric
14 * in the client protocol it is a space separated list of one or more nicks
15 * but in P10 it is always one target user numeric
16 *
17 */
18int handleprivsmsg(void *source, int cargc, char **cargv) {
19
a7697869 20 nick *snick; /* struct nick for source nick */
21 nick *tnick; /* struct nick for target nick */
22 char *sourcenum = (char *)source; /* source user numeric */
23 char *targetnum; /* target user numeric */
24 char *privs = "IDDQD IDKFA IDCLIP IDDT IDCHOPPERS"; /* privileges */
7bec4aeb 25
26 /*
27 * cheat codes from DOOM I & II
28 *
29 * IDDQD - god mode
30 * IDKFA - maximum ammo
31 * IDCLIP - walk through walls
32 * IDBEHOLD - toggle selected powerup
33 * IDDT - show entire map, show all monsters
34 * IDCHOPPERS - get chainsaw
35 *
36 */
37
38 /* check parameters */
39 if (cargc < 1) {
40 miscreply_needmoreparams(sourcenum, "PRIVS");
41 return CMD_OK;
42 }
43
44 /* get the parameter */
45 targetnum = cargv[0];
46
7bec4aeb 47 /* find source user */
48 if (!(snick = miscreply_finduser(sourcenum, "PRIVS")))
49 return CMD_OK;
50
51 /* find target user */
52 if (!(tnick = getnickbynumericstr(targetnum))) {
53 Error("miscreply", ERR_WARNING,
54 "PRIVS request from %s [%s] for unknown numeric %s",
55 snick->nick, sourcenum, targetnum);
56 return CMD_OK;
57 }
58
7bec4aeb 59 if (!IsOper(tnick))
60 privs = "";
61
62 /* send the privs */
63 /*
64 * 270 RPL_PRIVS "source 270 target nick :privs"
65 * "irc.netsplit.net 270 foobar barfoo :CHAN_LIMIT SHOW_INVIS SHOW_ALL_INVIS KILL"
66 */
a7697869 67 irc_send("%s 270 %s %s :%s", getmynumeric(), sourcenum, tnick->nick, privs);
7bec4aeb 68
69 return CMD_OK;
70}